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