Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_FECrsGraph_def.hpp
1// @HEADER
2// ***********************************************************************
3//
4// Tpetra: Templated Linear Algebra Services Package
5// Copyright (2008) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ************************************************************************
40// @HEADER
41
42#ifndef TPETRA_FECRSGRAPH_DEF_HPP
43#define TPETRA_FECRSGRAPH_DEF_HPP
44
45#include "Tpetra_CrsGraph.hpp"
48
49#include <type_traits>
50#include <set>
51
52namespace Tpetra {
53
54template<class LocalOrdinal, class GlobalOrdinal, class Node>
56FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
57 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
58 const size_t maxNumEntriesPerRow,
59 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
60 const Teuchos::RCP<const map_type> & domainMap,
61 const Teuchos::RCP<const map_type> & ownedRangeMap,
62 const Teuchos::RCP<Teuchos::ParameterList>& params):
63 FECrsGraph(ownedRowMap,ownedPlusSharedRowMap,maxNumEntriesPerRow,
64 domainMap.is_null() ? ownedRowMap : domainMap,
65 ownedPlusSharedToOwnedimporter,domainMap,ownedRangeMap,params)
66{
67 // Nothing else to do here
68}
69
70
71template<class LocalOrdinal, class GlobalOrdinal, class Node>
73FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
74 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
75 const size_t maxNumEntriesPerRow,
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, maxNumEntriesPerRow, params),
82 ownedRowsImporter_(ownedPlusSharedToOwnedimporter),
83 ownedDomainMap_(ownedDomainMap.is_null() ? ownedRowMap : ownedDomainMap),
84 ownedRangeMap_(ownedRangeMap.is_null() ? ownedRowMap : ownedRangeMap)
85{
86 this->domainMap_ = ownedPlusSharedDomainMap.is_null() ? ownedPlusSharedRowMap : ownedPlusSharedDomainMap;
87 Teuchos::RCP<const map_type> dummy;
88 setup(ownedRowMap,ownedPlusSharedRowMap,dummy,params);
89}
90
91template<class LocalOrdinal, class GlobalOrdinal, class Node>
93FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
94 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
95 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
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,numEntPerRow,
101 domainMap.is_null() ? ownedRowMap : domainMap,
102 ownedPlusSharedToOwnedimporter,domainMap,ownedRangeMap,params)
103{
104 // Nothing else to do here
105}
106
107template<class LocalOrdinal, class GlobalOrdinal, class Node>
109FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
110 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
111 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
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, numEntPerRow, params),
118 ownedRowsImporter_(ownedPlusSharedToOwnedimporter),
119 ownedDomainMap_(ownedDomainMap.is_null() ? ownedRowMap : ownedDomainMap),
120 ownedRangeMap_(ownedRangeMap.is_null() ? ownedRowMap : ownedRangeMap)
121{
122 this->domainMap_ = ownedPlusSharedDomainMap.is_null() ? ownedPlusSharedRowMap : ownedPlusSharedDomainMap;
123 Teuchos::RCP<const map_type> dummy;
124 setup(ownedRowMap,ownedPlusSharedRowMap,dummy,params);
125}
126
127template<class LocalOrdinal, class GlobalOrdinal, class Node>
129FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
130 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
131 const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
132 const size_t maxNumEntriesPerRow,
133 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
134 const Teuchos::RCP<const map_type> & domainMap,
135 const Teuchos::RCP<const map_type> & ownedRangeMap,
136 const Teuchos::RCP<Teuchos::ParameterList>& params):
137 FECrsGraph(ownedRowMap,ownedPlusSharedRowMap,ownedPlusSharedColMap,maxNumEntriesPerRow,
138 domainMap.is_null() ? ownedRowMap : domainMap,
139 ownedPlusSharedToOwnedimporter, domainMap, ownedRangeMap, params)
140{
141 // Nothing else to do here
142}
143
144template<class LocalOrdinal, class GlobalOrdinal, class Node>
146FECrsGraph(const Teuchos::RCP<const map_type> & ownedRowMap,
147 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
148 const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
149 const size_t maxNumEntriesPerRow,
150 const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
151 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
152 const Teuchos::RCP<const map_type> & ownedDomainMap,
153 const Teuchos::RCP<const map_type> & ownedRangeMap,
154 const Teuchos::RCP<Teuchos::ParameterList>& params):
155 crs_graph_type(ownedPlusSharedRowMap, ownedPlusSharedColMap,maxNumEntriesPerRow, params),
156 ownedRowsImporter_(ownedPlusSharedToOwnedimporter),
157 ownedDomainMap_(ownedDomainMap.is_null() ? ownedRowMap : ownedDomainMap),
158 ownedRangeMap_(ownedRangeMap.is_null() ? ownedRowMap : ownedRangeMap)
159{
160 this->domainMap_ = ownedPlusSharedDomainMap.is_null() ? ownedPlusSharedRowMap : ownedPlusSharedDomainMap;
161 setup(ownedRowMap,ownedPlusSharedRowMap, ownedPlusSharedColMap,params);
162}
163
164template<class LocalOrdinal, class GlobalOrdinal, class Node>
166FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
167 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
168 const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
169 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
170 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
171 const Teuchos::RCP<const map_type> & domainMap,
172 const Teuchos::RCP<const map_type> & ownedRangeMap,
173 const Teuchos::RCP<Teuchos::ParameterList>& params):
174 FECrsGraph(ownedRowMap,ownedPlusSharedRowMap,ownedPlusSharedColMap,numEntPerRow,
175 domainMap.is_null() ? ownedRowMap : domainMap,
176 ownedPlusSharedToOwnedimporter, domainMap, ownedRangeMap, params)
177{
178 // Nothing else to do here
179}
180
181template<class LocalOrdinal, class GlobalOrdinal, class Node>
183FECrsGraph (const Teuchos::RCP<const map_type> & ownedRowMap,
184 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
185 const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
186 const Kokkos::DualView<const size_t*, device_type>& numEntPerRow,
187 const Teuchos::RCP<const map_type> & ownedPlusSharedDomainMap,
188 const Teuchos::RCP<const import_type> & ownedPlusSharedToOwnedimporter,
189 const Teuchos::RCP<const map_type> & ownedDomainMap,
190 const Teuchos::RCP<const map_type> & ownedRangeMap,
191 const Teuchos::RCP<Teuchos::ParameterList>& params):
192 crs_graph_type(ownedPlusSharedRowMap, ownedPlusSharedColMap, numEntPerRow, params),
193 ownedRowsImporter_(ownedPlusSharedToOwnedimporter),
194 ownedDomainMap_(ownedDomainMap.is_null() ? ownedRowMap : ownedDomainMap),
195 ownedRangeMap_(ownedRangeMap.is_null() ? ownedRowMap : ownedRangeMap)
196{
197 this->domainMap_ = ownedPlusSharedDomainMap.is_null() ? ownedPlusSharedRowMap : ownedPlusSharedDomainMap;
198 setup(ownedRowMap,ownedPlusSharedRowMap, ownedPlusSharedColMap,params);
199}
200
201template<class LocalOrdinal, class GlobalOrdinal, class Node>
203setup(const Teuchos::RCP<const map_type> & ownedRowMap,
204 const Teuchos::RCP<const map_type> & ownedPlusSharedRowMap,
205 const Teuchos::RCP<const map_type> & ownedPlusSharedColMap,
206 const Teuchos::RCP<Teuchos::ParameterList>& params)
207{
208 const char tfecfFuncName[] = "FECrsGraph::setup(): ";
209
210 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(ownedRowMap.is_null (), std::runtime_error, "ownedRowMap is null.");
211 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(ownedPlusSharedRowMap.is_null (), std::runtime_error, "ownedPlusSharedRowMap is null.");
212
213 // If we have a colMap, we're local, otherwise global
214 if(ownedPlusSharedColMap.is_null()) this->allocateIndices(GlobalIndices);
215 else this->allocateIndices(LocalIndices);
216
217 activeCrsGraph_ = Teuchos::rcp(new FEWhichActive(FE_ACTIVE_OWNED_PLUS_SHARED));
218 fillState_ = Teuchos::rcp(new FillState(FillState::closed));
219
220 // Use a very strong map equivalence check
221 bool maps_are_the_same = ownedRowMap->isSameAs(*ownedPlusSharedRowMap);
222 if(!maps_are_the_same) {
223 // Make an importer if we need to, check map compatability if we don't
224 if(ownedRowsImporter_.is_null()) {
225 ownedRowsImporter_ = Teuchos::rcp(new import_type(ownedRowMap,ownedPlusSharedRowMap));
226 }
227 else {
228 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!ownedRowMap->isSameAs(*ownedRowsImporter_->getSourceMap()), std::runtime_error, "ownedRowMap does not match importer source map.");
229 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(!ownedPlusSharedRowMap->isSameAs(*ownedRowsImporter_->getTargetMap()), std::runtime_error, "ownedPlusSharedRowMap does not match importer target map.");
230 }
231
232 // Make sure the ownedPlusSharedRowMap has at least as many entries at the ownedRowMap (due to our superset requriement)
233 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( ownedRowsImporter_->getNumSameIDs() != ownedRowsImporter_->getSourceMap()->getLocalNumElements(),
234 std::runtime_error,"ownedRowMap contains entries which are not in the ownedPlusSharedRowMap.");
235
236 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( ownedRowMap->getLocalNumElements() > ownedPlusSharedRowMap->getLocalNumElements(),
237 std::runtime_error,"ownedRowMap more entries than the ownedPlusSharedRowMap.");
238
239 // The locallyFitted check is debug mode only since it is more expensive
240 const bool debug = ::Tpetra::Details::Behavior::debug ();
241 if(debug) {
242 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC( !ownedPlusSharedRowMap->isLocallyFitted(*ownedRowMap),
243 std::runtime_error,"ownedPlusSharedRowMap must be locally fitted to the ownedRowMap");
244
245 }
246 } else {
247 // We don't need the importer in this case, since the two row maps are identical (e.g., serial mode).
248 // Setting this to null helps later to detect whether there is a need for the second graph (the owned one).
249 ownedRowsImporter_ = Teuchos::null;
250 }
251}
252
253template<class LocalOrdinal, class GlobalOrdinal, class Node>
254void FECrsGraph<LocalOrdinal, GlobalOrdinal, Node>::doOwnedPlusSharedToOwned(const CombineMode CM) {
255 const char tfecfFuncName[] = "FECrsGraph::doOwnedPlusSharedToOwned(CombineMode): ";
256 if(!ownedRowsImporter_.is_null() && *activeCrsGraph_ == FE_ACTIVE_OWNED_PLUS_SHARED) {
257 Teuchos::RCP<const map_type> ownedRowMap = ownedRowsImporter_->getSourceMap();
258
259 // Do a self-export in "restricted mode"
260 this->doExport(*this,*ownedRowsImporter_,CM,true);
261
262 // Under the "if you own an element, you own at least one of its nodes" assumption,
263 // we can start by making a columnmap for ownedPlusShared
264 if(!this->hasColMap()) {
265 Teuchos::Array<int> remotePIDs (0);
266 this->makeColMap(remotePIDs);
267 }
268
269 // Now run CrsGraph's fillComplete to get the final importer
270 crs_graph_type::fillComplete(this->domainMap_,this->getRowMap());
271
272 // In debug mode, we check to make sure the "if you own an element, you own at least one of its nodes"
273 // However, we give the user the ability to bypass this check. This can be useful when dealing with mesh
274 // that are generated and partitioned by a TPL, and/or where it is so complicated to rearrange the
275 // dofs ownership that the customer app might be willing to accept a small performance hit.
276 const bool debug = ::Tpetra::Details::Behavior::debug ();
277 const bool checkColGIDsInAtLeastOneOwnedRow =
278 this->getMyNonconstParamList().is_null() ? true :
279 this->getMyNonconstParamList()->get("Check Col GIDs In At Least One Owned Row",true);
280 if (debug && checkColGIDsInAtLeastOneOwnedRow) {
281 Teuchos::RCP<const map_type> colmap = this->getColMap();
282 Teuchos::Array<bool> flag(colmap->getLocalNumElements(),false);
283 typename crs_graph_type::nonconst_local_inds_host_view_type indices("indices",this->getLocalMaxNumRowEntries());
284
285 for(size_t i=0; i<ownedRowMap->getLocalNumElements(); i++) {
286 size_t NumEntries=0;
287 this->getLocalRowCopy(i,indices,NumEntries);
288 for(size_t j=0; j<NumEntries; j++)
289 flag[indices[j]] = true;
290 }
291
292 int lclCount = 0;
293 for(size_t i=0; i<(size_t)flag.size(); i++)
294 if(!flag[i])
295 ++lclCount;
296
297 // Perform a reduction over the input comm, so that ranks with success=true won't be hanging.
298 // Note: this only ensures things don't hang
299 int gblCount = lclCount;
300 auto comm = this->getComm();
301 if (!comm.is_null()) {
302 Teuchos::reduceAll<int,int>(*comm, Teuchos::REDUCE_SUM, 1, &lclCount, &gblCount);
303 }
304 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC
305 (gblCount > 0,
306 std::invalid_argument, "if you own an element (in the finite element sense) you "
307 "must also own one of the attached nodes. This assumption has been violated in "
308 "your matrix fill on at least one MPI rank:\n"
309 " locally, there are " + std::to_string(lclCount) + " col gids not connected to any owned gid.\n"
310 " globally, there are " + std::to_string(gblCount) + " col gids not connected to any owned gid.\n"
311 "NOTE: you can disable this check by setting a parameter list with the option\n"
312 " 'Check Col GIDs In At Least One Owned Row' set to false.\n"
313 "NOTE: the parameter list must be set AFTER construction, since it would not be recognized as valid"
314 "by the base class CrsGraph.\n");
315 }
316
317 // Time to build an owned localGraph via subviews
318 inactiveCrsGraph_ = Teuchos::rcp(new crs_graph_type(*this, ownedRowMap));
319 inactiveCrsGraph_->fillComplete(ownedDomainMap_,ownedRangeMap_);
320 }
321}//end doOverlapToLocal
322
323
324template<class LocalOrdinal, class GlobalOrdinal, class Node>
325void FECrsGraph<LocalOrdinal, GlobalOrdinal, Node>::doOwnedToOwnedPlusShared(const CombineMode /* CM */) {
326 // This should be a no-op for all of our purposes
327}//end doLocalToOverlap
328
329template<class LocalOrdinal, class GlobalOrdinal, class Node>
331 if(*activeCrsGraph_ == FE_ACTIVE_OWNED_PLUS_SHARED)
332 *activeCrsGraph_ = FE_ACTIVE_OWNED;
333 else
334 *activeCrsGraph_ = FE_ACTIVE_OWNED_PLUS_SHARED;
335
336 if(inactiveCrsGraph_.is_null()) return;
337
338 this->swap(*inactiveCrsGraph_);
339
340}//end switchActiveCrsGraph
341
342
343template<class LocalOrdinal, class GlobalOrdinal, class Node>
345 const Teuchos::RCP<const map_type>& domainMap,
346 const Teuchos::RCP<const map_type>& rangeMap)
347{
348 /* What has to go on here is complicated.
349 First off, if we don't really have two graphs (e.g. the rowMaps are the same, because we're in serial or
350 doing finite differences, things are easy --- just call fillComplete().
351
352 If, we are in the parallel FE case, then:
353 Precondition: FE_ACTIVE_OWNED_PLUS_SHARED mode
354
355 Postconditions:
356 1) FE_ACTIVE_OWNED mode
357 2) The OWNED graph has been fillCompleted with an Aztec-compatible column map
358 3) rowptr & (local) colinds are aliased between the two graphs
359 4) The OWNED_PLUS_SHARED graph has been fillCompleted with a column map whose first chunk
360 is the column map for the OWNED graph.
361 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
362 the columnMap is the same for both graphs!!!
363
364 5) The OWNED_PLUS_SHARED graph has neither an importer nor exporter. Making these is expensive and we don't need them.
365 */
366 // Precondition
367 const char tfecfFuncName[] = "FECrsGraph::endFill(domainMap, rangeMap): ";
368 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(*activeCrsGraph_ != FE_ACTIVE_OWNED_PLUS_SHARED,std::runtime_error, "must be in owned+shared mode.");
369 if(ownedRowsImporter_.is_null()) {
370 // The easy case: One graph
371 switchActiveCrsGraph();
372 crs_graph_type::fillComplete(domainMap, rangeMap);
373 }
374 else {
375 // The hard case: Two graphs
376
377 // fillComplete the owned+shared graph in a way that generates the owned+shared grep w/o an importer or exporter
378 // Migrate data to the owned graph
379 doOwnedPlusSharedToOwned(Tpetra::ADD);
380
381 // Load up the owned graph
382 switchActiveCrsGraph();
383
384 }
385}
386
387
388template<class LocalOrdinal, class GlobalOrdinal, class Node>
389void FECrsGraph<LocalOrdinal, GlobalOrdinal, Node>::endFill() {
390 this->endFill(ownedDomainMap_, ownedRangeMap_);
391}
392
393
394template<class LocalOrdinal, class GlobalOrdinal, class Node>
395void FECrsGraph<LocalOrdinal, GlobalOrdinal, Node>::beginFill() {
396 const char tfecfFuncName[] = "FECrsGraph::beginFill(): ";
397
398 // Unlike FECrsMatrix and FEMultiVector, we do not allow you to call beginFill() after calling endFill()
399 // So we throw an exception if you're in owned mode
400 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(*activeCrsGraph_ == FE_ACTIVE_OWNED,std::runtime_error, "can only be called once.");
401
402}
403
404template<class LocalOrdinal, class GlobalOrdinal, class Node>
406 const char tfecfFuncName[] = "FECrsGraph::beginAssembly: ";
407 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
408 *fillState_ != FillState::closed,
409 std::runtime_error,
410 "Cannot beginAssembly, matrix is not in a closed state"
411 );
412 *fillState_ = FillState::open;
413 this->beginFill();
414}
415
416template<class LocalOrdinal, class GlobalOrdinal, class Node>
418 const char tfecfFuncName[] = "FECrsGraph::endAssembly: ";
419 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
420 *fillState_ != FillState::open,
421 std::logic_error,
422 "Cannot endAssembly, matrix is not open to fill but is closed."
423 );
424 *fillState_ = FillState::closed;
425 this->endFill();
426}
427
428template<class LocalOrdinal, class GlobalOrdinal, class Node>
430 const Teuchos::RCP<const map_type>& domainMap,
431 const Teuchos::RCP<const map_type>& rangeMap)
432{
433 const char tfecfFuncName[] = "FECrsGraph::endAssembly: ";
434 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
435 *fillState_ != FillState::open,
436 std::logic_error,
437 "Cannot endAssembly, matrix is not open to fill but is closed."
438 );
439 *fillState_ = FillState::closed;
440 this->endFill(domainMap, rangeMap);
441}
442
443template <class LocalOrdinal, class GlobalOrdinal, class Node>
444Teuchos::RCP<const Teuchos::ParameterList>
446{
447 auto valid_pl = Teuchos::rcp(new Teuchos::ParameterList("Tpetra::FECrsGraph"));
448 valid_pl->validateParametersAndSetDefaults(*crs_graph_type::getValidParameters());
449 valid_pl->set("Check Col GIDs In At Least One Owned Row",true);
450
451 return valid_pl;
452}
453
454template <class LocalOrdinal, class GlobalOrdinal, class Node>
455size_t
457 const local_ordinal_type lclRow,
458 const global_ordinal_type inputGblColInds[],
459 const size_t numInputInds
460){
461 const char tfecfFuncName[] = "FECrsGraph::insertGlobalIndices: ";
462 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
463 *fillState_ != FillState::open,
464 std::logic_error,
465 "Cannot replace global values, matrix is not open to fill but is closed."
466 );
467 return crs_graph_type::insertGlobalIndicesImpl(lclRow, inputGblColInds, numInputInds);
468}
469
470template <class LocalOrdinal, class GlobalOrdinal, class Node>
471size_t
473 const RowInfo& rowInfo,
474 const global_ordinal_type inputGblColInds[],
475 const size_t numInputInds,
476 std::function<void(const size_t, const size_t, const size_t)> fun
477){
478 const char tfecfFuncName[] = "FECrsGraph::insertGlobalIndices: ";
479 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
480 *fillState_ != FillState::open,
481 std::logic_error,
482 "Cannot replace global values, matrix is not open to fill but is closed."
483 );
484 return crs_graph_type::insertGlobalIndicesImpl(rowInfo, inputGblColInds, numInputInds, fun);
485}
486
487template <class LocalOrdinal, class GlobalOrdinal, class Node>
488void
490 const local_ordinal_type lclRow,
491 const Teuchos::ArrayView<const local_ordinal_type>& gblColInds,
492 std::function<void(const size_t, const size_t, const size_t)> fun
493){
494 const char tfecfFuncName[] = "FECrsGraph::insertLocalIndices: ";
495 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(
496 *fillState_ != FillState::open,
497 std::logic_error,
498 "Cannot replace global values, matrix is not open to fill but is closed."
499 );
500 return crs_graph_type::insertLocalIndicesImpl(lclRow, gblColInds, fun);
501}
502
503} // end namespace Tpetra
504
505
506//
507// Explicit instantiation macro
508//
509// Must be expanded from within the Tpetra namespace!
510//
511#define TPETRA_FECRSGRAPH_INSTANT(LO,GO,NODE) \
512 template class FECrsGraph<LO, GO, NODE>;
513
514
515
516#endif // TPETRA_FECRSGRAPH_DEF
Declaration of Tpetra::Details::Behavior, a class that describes Tpetra's behavior.
Declaration and definition of Tpetra::Details::getEntryOnHost.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
Teuchos::RCP< const map_type > domainMap_
The Map describing the domain of the (matrix corresponding to the) graph.
static bool debug()
Whether Tpetra is in debug mode.
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
void endAssembly()
Migrates data to the owned mode.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Default parameter list suitable for validation.
void beginAssembly()
Activates the owned+shared mode for assembly.
void switchActiveCrsGraph()
Switches which CrsGraph is active (without migrating data)
LocalOrdinal local_ordinal_type
This class' first template parameter; the type of 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.
GlobalOrdinal global_ordinal_type
This class' second template parameter; the type of global indices.
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's column Map.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
CombineMode
Rule for combining data in an Import or Export.
@ ADD
Sum new values.
Allocation information for a locally owned row in a CrsGraph or CrsMatrix.