Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_FECrsGraph_def.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Tpetra: Templated Linear Algebra Services Package
4 //
5 // Copyright 2008 NTESS and the Tpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TPETRA_FECRSGRAPH_DEF_HPP
11 #define TPETRA_FECRSGRAPH_DEF_HPP
12 
13 #include "Tpetra_CrsGraph.hpp"
16 
17 #include <type_traits>
18 #include <set>
19 
20 namespace Tpetra {
21 
22 template<class LocalOrdinal, class GlobalOrdinal, class Node>
24 FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
25  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
26  const size_t maxNumEntriesPerRow,
27  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
28  const Teuchos::RCP<const map_type> & domainMap,
29  const Teuchos::RCP<const map_type> & ownedRangeMap,
30  const Teuchos::RCP<Teuchos::ParameterList>& params):
31  FECrsGraph(ownedRowMap,ownedPlusSharedRowMap,maxNumEntriesPerRow,
32  domainMap.is_null() ? ownedRowMap : domainMap,
33  ownedPlusSharedToOwnedimporter,domainMap,ownedRangeMap,params)
34 {
35  // Nothing else to do here
36 }
37 
38 
39 template<class LocalOrdinal, class GlobalOrdinal, class Node>
41 FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
42  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
43  const size_t maxNumEntriesPerRow,
44  const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
45  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
46  const Teuchos::RCP<const map_type> & ownedDomainMap,
47  const Teuchos::RCP<const map_type> & ownedRangeMap,
48  const Teuchos::RCP<Teuchos::ParameterList>& params):
49  crs_graph_type(ownedPlusSharedRowMap, maxNumEntriesPerRow, params),
50  ownedRowsImporter_(ownedPlusSharedToOwnedimporter),
51  ownedDomainMap_(ownedDomainMap.is_null() ? ownedRowMap : ownedDomainMap),
52  ownedRangeMap_(ownedRangeMap.is_null() ? ownedRowMap : ownedRangeMap)
53 {
54  this->domainMap_ = ownedPlusSharedDomainMap.is_null() ? ownedPlusSharedRowMap : ownedPlusSharedDomainMap;
55  Teuchos::RCP<const map_type> dummy;
56  setup(ownedRowMap,ownedPlusSharedRowMap,dummy,params);
57 }
58 
59 template<class LocalOrdinal, class GlobalOrdinal, class Node>
61 FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
62  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
63  const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
64  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
65  const Teuchos::RCP<const map_type> & domainMap,
66  const Teuchos::RCP<const map_type> & ownedRangeMap,
67  const Teuchos::RCP<Teuchos::ParameterList>& params):
68  FECrsGraph(ownedRowMap,ownedPlusSharedRowMap,numEntPerRow,
69  domainMap.is_null() ? ownedRowMap : domainMap,
70  ownedPlusSharedToOwnedimporter,domainMap,ownedRangeMap,params)
71 {
72  // Nothing else to do here
73 }
74 
75 template<class LocalOrdinal, class GlobalOrdinal, class Node>
77 FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
78  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
79  const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
80  const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
81  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
82  const Teuchos::RCP<const map_type> & ownedDomainMap,
83  const Teuchos::RCP<const map_type> & ownedRangeMap,
84  const Teuchos::RCP<Teuchos::ParameterList>& params):
85  crs_graph_type( ownedPlusSharedRowMap, numEntPerRow, params),
86  ownedRowsImporter_(ownedPlusSharedToOwnedimporter),
87  ownedDomainMap_(ownedDomainMap.is_null() ? ownedRowMap : ownedDomainMap),
88  ownedRangeMap_(ownedRangeMap.is_null() ? ownedRowMap : ownedRangeMap)
89 {
90  this->domainMap_ = ownedPlusSharedDomainMap.is_null() ? ownedPlusSharedRowMap : ownedPlusSharedDomainMap;
91  Teuchos::RCP<const map_type> dummy;
92  setup(ownedRowMap,ownedPlusSharedRowMap,dummy,params);
93 }
94 
95 template<class LocalOrdinal, class GlobalOrdinal, class Node>
97 FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
98  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
99  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
100  const size_t maxNumEntriesPerRow,
101  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
102  const Teuchos::RCP<const map_type> & domainMap,
103  const Teuchos::RCP<const map_type> & ownedRangeMap,
104  const Teuchos::RCP<Teuchos::ParameterList>& params):
105  FECrsGraph(ownedRowMap,ownedPlusSharedRowMap,ownedPlusSharedColMap,maxNumEntriesPerRow,
106  domainMap.is_null() ? ownedRowMap : domainMap,
107  ownedPlusSharedToOwnedimporter, domainMap, ownedRangeMap, params)
108 {
109  // Nothing else to do here
110 }
111 
112 template<class LocalOrdinal, class GlobalOrdinal, class Node>
114 FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
115  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
116  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
117  const size_t maxNumEntriesPerRow,
118  const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
119  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
120  const Teuchos::RCP<const map_type> & ownedDomainMap,
121  const Teuchos::RCP<const map_type> & ownedRangeMap,
122  const Teuchos::RCP<Teuchos::ParameterList>& params):
123  crs_graph_type(ownedPlusSharedRowMap, ownedPlusSharedColMap,maxNumEntriesPerRow, params),
124  ownedRowsImporter_(ownedPlusSharedToOwnedimporter),
125  ownedDomainMap_(ownedDomainMap.is_null() ? ownedRowMap : ownedDomainMap),
126  ownedRangeMap_(ownedRangeMap.is_null() ? ownedRowMap : ownedRangeMap)
127 {
128  this->domainMap_ = ownedPlusSharedDomainMap.is_null() ? ownedPlusSharedRowMap : ownedPlusSharedDomainMap;
129  setup(ownedRowMap,ownedPlusSharedRowMap, ownedPlusSharedColMap,params);
130 }
131 
132 template<class LocalOrdinal, class GlobalOrdinal, class Node>
134 FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
135  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
136  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
137  const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
138  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
139  const Teuchos::RCP<const map_type> & domainMap,
140  const Teuchos::RCP<const map_type> & ownedRangeMap,
141  const Teuchos::RCP<Teuchos::ParameterList>& params):
142  FECrsGraph(ownedRowMap,ownedPlusSharedRowMap,ownedPlusSharedColMap,numEntPerRow,
143  domainMap.is_null() ? ownedRowMap : domainMap,
144  ownedPlusSharedToOwnedimporter, domainMap, ownedRangeMap, params)
145 {
146  // Nothing else to do here
147 }
148 
149 template<class LocalOrdinal, class GlobalOrdinal, class Node>
151 FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
152  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
153  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
154  const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
155  const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
156  const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
157  const Teuchos::RCP<const map_type> & ownedDomainMap,
158  const Teuchos::RCP<const map_type> & ownedRangeMap,
159  const Teuchos::RCP<Teuchos::ParameterList>& params):
160  crs_graph_type(ownedPlusSharedRowMap, ownedPlusSharedColMap, numEntPerRow, params),
161  ownedRowsImporter_(ownedPlusSharedToOwnedimporter),
162  ownedDomainMap_(ownedDomainMap.is_null() ? ownedRowMap : ownedDomainMap),
163  ownedRangeMap_(ownedRangeMap.is_null() ? ownedRowMap : ownedRangeMap)
164 {
165  this->domainMap_ = ownedPlusSharedDomainMap.is_null() ? ownedPlusSharedRowMap : ownedPlusSharedDomainMap;
166  setup(ownedRowMap,ownedPlusSharedRowMap, ownedPlusSharedColMap,params);
167 }
168 
169 template<class LocalOrdinal, class GlobalOrdinal, class Node>
171 setup(const Teuchos::RCP<const map_type> & ownedRowMap,
172  const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
173  const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
174  const Teuchos::RCP<Teuchos::ParameterList>& params)
175 {
176  const char tfecfFuncName[] = "FECrsGraph::setup(): ";
177 
178  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(ownedRowMap.is_null (), std::runtime_error, "ownedRowMap is null.");
179  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(ownedPlusSharedRowMap.is_null (), std::runtime_error, "ownedPlusSharedRowMap is null.");
180 
181  // If we have a colMap, we're local, otherwise global
182  if(ownedPlusSharedColMap.is_null()) this->allocateIndices(GlobalIndices);
183  else this->allocateIndices(LocalIndices);
184 
185  activeCrsGraph_ = Teuchos::rcp(new FE::WhichActive(FE::ACTIVE_OWNED_PLUS_SHARED));
186  fillState_ = Teuchos::rcp(new FE::FillState(FE::FillState::closed));
187 
188  // Use a very strong map equivalence check
189  bool maps_are_the_same = ownedRowMap->isSameAs(*ownedPlusSharedRowMap);
190  if(!maps_are_the_same) {
191  // Make an importer if we need to, check map compatability if we don't
192  if(ownedRowsImporter_.is_null()) {
193  ownedRowsImporter_ = Teuchos::rcp(new import_type(ownedRowMap,ownedPlusSharedRowMap));
194  }
195  else {
196  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!ownedRowMap->isSameAs(*ownedRowsImporter_->getSourceMap()), std::runtime_error, "ownedRowMap does not match importer source map.");
197  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!ownedPlusSharedRowMap->isSameAs(*ownedRowsImporter_->getTargetMap()), std::runtime_error, "ownedPlusSharedRowMap does not match importer target map.");
198  }
199 
200  // Make sure the ownedPlusSharedRowMap has at least as many entries at the ownedRowMap (due to our superset requriement)
201  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( ownedRowsImporter_->getNumSameIDs() != ownedRowsImporter_->getSourceMap()->getLocalNumElements(),
202  std::runtime_error,"ownedRowMap contains entries which are not in the ownedPlusSharedRowMap.");
203 
204  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( ownedRowMap->getLocalNumElements() > ownedPlusSharedRowMap->getLocalNumElements(),
205  std::runtime_error,"ownedRowMap more entries than the ownedPlusSharedRowMap.");
206 
207  // The locallyFitted check is debug mode only since it is more expensive
208  const bool debug = ::Tpetra::Details::Behavior::debug ();
209  if(debug) {
210  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( !ownedPlusSharedRowMap->isLocallyFitted(*ownedRowMap),
211  std::runtime_error,"ownedPlusSharedRowMap must be locally fitted to the ownedRowMap");
212 
213  }
214  } else {
215  // We don't need the importer in this case, since the two row maps are identical (e.g., serial mode).
216  // Setting this to null helps later to detect whether there is a need for the second graph (the owned one).
217  ownedRowsImporter_ = Teuchos::null;
218  }
219 }
220 
221 template<class LocalOrdinal, class GlobalOrdinal, class Node>
222 void FECrsGraph<LocalOrdinal, GlobalOrdinal, Node>::doOwnedPlusSharedToOwned(const CombineMode CM) {
223  const char tfecfFuncName[] = "FECrsGraph::doOwnedPlusSharedToOwned(CombineMode): ";
224  if(!ownedRowsImporter_.is_null() && *activeCrsGraph_ == FE::ACTIVE_OWNED_PLUS_SHARED) {
225  Teuchos::RCP<const map_type> ownedRowMap = ownedRowsImporter_->getSourceMap();
226 
227  // Do a self-export in "restricted mode"
228  this->doExport(*this,*ownedRowsImporter_,CM,true);
229 
230  // Under the "if you own an element, you own at least one of its nodes" assumption,
231  // we can start by making a columnmap for ownedPlusShared
232  if(!this->hasColMap()) {
233  Teuchos::Array<int> remotePIDs (0);
234  this->makeColMap(remotePIDs);
235  }
236 
237  // Now run CrsGraph's fillComplete to get the final importer
238  crs_graph_type::fillComplete(this->domainMap_,this->getRowMap());
239 
240  // In debug mode, we check to make sure the "if you own an element, you own at least one of its nodes"
241  // However, we give the user the ability to bypass this check. This can be useful when dealing with mesh
242  // that are generated and partitioned by a TPL, and/or where it is so complicated to rearrange the
243  // dofs ownership that the customer app might be willing to accept a small performance hit.
244  const bool debug = ::Tpetra::Details::Behavior::debug ();
245  const bool checkColGIDsInAtLeastOneOwnedRow =
246  this->getMyNonconstParamList().is_null() ? true :
247  this->getMyNonconstParamList()->get("Check Col GIDs In At Least One Owned Row",true);
248  if (debug && checkColGIDsInAtLeastOneOwnedRow) {
249  Teuchos::RCP<const map_type> colmap = this->getColMap();
250  Teuchos::Array<bool> flag(colmap->getLocalNumElements(),false);
251  typename crs_graph_type::nonconst_local_inds_host_view_type indices("indices",this->getLocalMaxNumRowEntries());
252 
253  for(size_t i=0; i<ownedRowMap->getLocalNumElements(); i++) {
254  size_t NumEntries=0;
255  this->getLocalRowCopy(i,indices,NumEntries);
256  for(size_t j=0; j<NumEntries; j++)
257  flag[indices[j]] = true;
258  }
259 
260  int lclCount = 0;
261  for(size_t i=0; i<(size_t)flag.size(); i++)
262  if(!flag[i])
263  ++lclCount;
264 
265  // Perform a reduction over the input comm, so that ranks with success=true won't be hanging.
266  // Note: this only ensures things don't hang
267  int gblCount = lclCount;
268  auto comm = this->getComm();
269  if (!comm.is_null()) {
270  Teuchos::reduceAll<int,int>(*comm, Teuchos::REDUCE_SUM, 1, &lclCount, &gblCount);
271  }
272  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
273  (gblCount > 0,
274  std::invalid_argument, "if you own an element (in the finite element sense) you "
275  "must also own one of the attached nodes. This assumption has been violated in "
276  "your matrix fill on at least one MPI rank:\n"
277  " locally, there are " + std::to_string(lclCount) + " col gids not connected to any owned gid.\n"
278  " globally, there are " + std::to_string(gblCount) + " col gids not connected to any owned gid.\n"
279  "NOTE: you can disable this check by setting a parameter list with the option\n"
280  " 'Check Col GIDs In At Least One Owned Row' set to false.\n"
281  "NOTE: the parameter list must be set AFTER construction, since it would not be recognized as valid"
282  "by the base class CrsGraph.\n");
283  }
284 
285  // Time to build an owned localGraph via subviews
286  inactiveCrsGraph_ = Teuchos::rcp(new crs_graph_type(*this, ownedRowMap));
287  inactiveCrsGraph_->fillComplete(ownedDomainMap_,ownedRangeMap_);
288  }
289 }//end doOverlapToLocal
290 
291 
292 template<class LocalOrdinal, class GlobalOrdinal, class Node>
293 void FECrsGraph<LocalOrdinal, GlobalOrdinal, Node>::doOwnedToOwnedPlusShared(const CombineMode /* CM */) {
294  // This should be a no-op for all of our purposes
295 }//end doLocalToOverlap
296 
297 template<class LocalOrdinal, class GlobalOrdinal, class Node>
299  if(*activeCrsGraph_ == FE::ACTIVE_OWNED_PLUS_SHARED)
300  *activeCrsGraph_ = FE::ACTIVE_OWNED;
301  else
302  *activeCrsGraph_ = FE::ACTIVE_OWNED_PLUS_SHARED;
303 
304  if(inactiveCrsGraph_.is_null()) return;
305 
306  this->swap(*inactiveCrsGraph_);
307 
308 }//end switchActiveCrsGraph
309 
310 
311 template<class LocalOrdinal, class GlobalOrdinal, class Node>
313  const Teuchos::RCP<const map_type>& domainMap,
314  const Teuchos::RCP<const map_type>& rangeMap)
315 {
316  /* What has to go on here is complicated.
317  First off, if we don't really have two graphs (e.g. the rowMaps are the same, because we're in serial or
318  doing finite differences, things are easy --- just call fillComplete().
319 
320  If, we are in the parallel FE case, then:
321  Precondition: FE::ACTIVE_OWNED_PLUS_SHARED mode
322 
323  Postconditions:
324  1) FE::ACTIVE_OWNED mode
325  2) The OWNED graph has been fillCompleted with an Aztec-compatible column map
326  3) rowptr & (local) colinds are aliased between the two graphs
327  4) The OWNED_PLUS_SHARED graph has been fillCompleted with a column map whose first chunk
328  is the column map for the OWNED graph.
329  If we assume that (a) if you own an element, you also own at least one of the connected nodes and (b) elements are cliques, then
330  the columnMap is the same for both graphs!!!
331 
332  5) The OWNED_PLUS_SHARED graph has neither an importer nor exporter. Making these is expensive and we don't need them.
333  */
334  // Precondition
335  const char tfecfFuncName[] = "FECrsGraph::endFill(domainMap, rangeMap): ";
336  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(*activeCrsGraph_ != FE::ACTIVE_OWNED_PLUS_SHARED,std::runtime_error, "must be in owned+shared mode.");
337  if(ownedRowsImporter_.is_null()) {
338  // The easy case: One graph
339  switchActiveCrsGraph();
340  crs_graph_type::fillComplete(domainMap, rangeMap);
341  }
342  else {
343  // The hard case: Two graphs
344 
345  // fillComplete the owned+shared graph in a way that generates the owned+shared grep w/o an importer or exporter
346  // Migrate data to the owned graph
347  doOwnedPlusSharedToOwned(Tpetra::ADD);
348 
349  // Load up the owned graph
350  switchActiveCrsGraph();
351 
352  }
353 }
354 
355 
356 template<class LocalOrdinal, class GlobalOrdinal, class Node>
357 void FECrsGraph<LocalOrdinal, GlobalOrdinal, Node>::endFill() {
358  this->endFill(ownedDomainMap_, ownedRangeMap_);
359 }
360 
361 
362 template<class LocalOrdinal, class GlobalOrdinal, class Node>
363 void FECrsGraph<LocalOrdinal, GlobalOrdinal, Node>::beginFill() {
364  const char tfecfFuncName[] = "FECrsGraph::beginFill(): ";
365 
366  // Unlike FECrsMatrix and FEMultiVector, we do not allow you to call beginFill() after calling endFill()
367  // So we throw an exception if you're in owned mode
368  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(*activeCrsGraph_ == FE::ACTIVE_OWNED,std::runtime_error, "can only be called once.");
369 
370 }
371 
372 template<class LocalOrdinal, class GlobalOrdinal, class Node>
374  const char tfecfFuncName[] = "FECrsGraph::beginAssembly: ";
375  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
376  *fillState_ != FE::FillState::closed,
377  std::runtime_error,
378  "Cannot beginAssembly, matrix is not in a closed state"
379  );
380  *fillState_ = FE::FillState::open;
381  this->beginFill();
382 }
383 
384 template<class LocalOrdinal, class GlobalOrdinal, class Node>
386  const char tfecfFuncName[] = "FECrsGraph::endAssembly: ";
387  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
388  *fillState_ != FE::FillState::open,
389  std::logic_error,
390  "Cannot endAssembly, matrix is not open to fill but is closed."
391  );
392  *fillState_ = FE::FillState::closed;
393  this->endFill();
394 }
395 
396 template<class LocalOrdinal, class GlobalOrdinal, class Node>
398  const Teuchos::RCP<const map_type>& domainMap,
399  const Teuchos::RCP<const map_type>& rangeMap)
400 {
401  const char tfecfFuncName[] = "FECrsGraph::endAssembly: ";
402  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
403  *fillState_ != FE::FillState::open,
404  std::logic_error,
405  "Cannot endAssembly, matrix is not open to fill but is closed."
406  );
407  *fillState_ = FE::FillState::closed;
408  this->endFill(domainMap, rangeMap);
409 }
410 
411 template <class LocalOrdinal, class GlobalOrdinal, class Node>
412 Teuchos::RCP<const Teuchos::ParameterList>
414 {
415  auto valid_pl = Teuchos::rcp(new Teuchos::ParameterList("Tpetra::FECrsGraph"));
416  valid_pl->validateParametersAndSetDefaults(*crs_graph_type::getValidParameters());
417  valid_pl->set("Check Col GIDs In At Least One Owned Row",true);
418 
419  return valid_pl;
420 }
421 
422 template <class LocalOrdinal, class GlobalOrdinal, class Node>
423 size_t
425  const local_ordinal_type lclRow,
426  const global_ordinal_type inputGblColInds[],
427  const size_t numInputInds
428 ){
429  const char tfecfFuncName[] = "FECrsGraph::insertGlobalIndices: ";
430  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
431  *fillState_ != FE::FillState::open,
432  std::logic_error,
433  "Cannot replace global values, matrix is not open to fill but is closed."
434  );
435  return crs_graph_type::insertGlobalIndicesImpl(lclRow, inputGblColInds, numInputInds);
436 }
437 
438 template <class LocalOrdinal, class GlobalOrdinal, class Node>
439 size_t
441  const RowInfo& rowInfo,
442  const global_ordinal_type inputGblColInds[],
443  const size_t numInputInds,
444  std::function<void(const size_t, const size_t, const size_t)> fun
445 ){
446  const char tfecfFuncName[] = "FECrsGraph::insertGlobalIndices: ";
447  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
448  *fillState_ != FE::FillState::open,
449  std::logic_error,
450  "Cannot replace global values, matrix is not open to fill but is closed."
451  );
452  return crs_graph_type::insertGlobalIndicesImpl(rowInfo, inputGblColInds, numInputInds, fun);
453 }
454 
455 template <class LocalOrdinal, class GlobalOrdinal, class Node>
456 void
458  const local_ordinal_type lclRow,
459  const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
460  std::function<void(const size_t, const size_t, const size_t)> fun
461 ){
462  const char tfecfFuncName[] = "FECrsGraph::insertLocalIndices: ";
463  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
464  *fillState_ != FE::FillState::open,
465  std::logic_error,
466  "Cannot replace global values, matrix is not open to fill but is closed."
467  );
468  return crs_graph_type::insertLocalIndicesImpl(lclRow, gblColInds, fun);
469 }
470 
471 } // end namespace Tpetra
472 
473 
474 //
475 // Explicit instantiation macro
476 //
477 // Must be expanded from within the Tpetra namespace!
478 //
479 #define TPETRA_FECRSGRAPH_INSTANT(LO,GO,NODE) \
480  template class FECrsGraph<LO, GO, NODE>;
481 
482 
483 
484 #endif // TPETRA_FECRSGRAPH_DEF
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
GlobalOrdinal global_ordinal_type
The type of the graph&#39;s global indices.
void endAssembly()
Migrates data to the owned mode.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Default parameter list suitable for validation.
FECrsGraph(const Teuchos::RCP< const map_type > &ownedRowMap, const Teuchos::RCP< const map_type > &ownedPlusSharedRowMap, const size_t maxNumEntriesPerRow, const Teuchos::RCP< const import_type > &ownedPlusSharedToOwnedimporter=Teuchos::null, const Teuchos::RCP< const map_type > &domainMap=Teuchos::null, const Teuchos::RCP< const map_type > &ownedRangeMap=Teuchos::null, const Teuchos::RCP< Teuchos::ParameterList > &params=Teuchos::null)
Constructorfor globally-indexed assembly specifying a single upper bound for the number of entries in...
static bool debug()
Whether Tpetra is in debug mode.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.
Teuchos::RCP< const map_type > domainMap_
The Map describing the domain of the (matrix corresponding to the) graph.
CombineMode
Rule for combining data in an Import or Export.
Sum new values.
LocalOrdinal local_ordinal_type
The type of the graph&#39;s local indices.
size_t insertGlobalIndicesImpl(const local_ordinal_type lclRow, const global_ordinal_type inputGblColInds[], const size_t numInputInds)
Insert global indices, using an input local row index.
void switchActiveCrsGraph()
Switches which CrsGraph is active (without migrating data)
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
int makeColMap(Teuchos::RCP< const Tpetra::Map< LO, GO, NT > > &colMap, Teuchos::Array< int > &remotePIDs, const Teuchos::RCP< const Tpetra::Map< LO, GO, NT > > &domMap, const RowGraph< LO, GO, NT > &graph, const bool sortEachProcsGids=true, std::ostream *errStrm=NULL)
Make the graph&#39;s column Map.
void beginAssembly()
Activates the owned+shared mode for assembly.
Declaration and definition of Tpetra::Details::getEntryOnHost.
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra&#39;s behavior.