10 #ifndef IFPACK2_OVERLAPPINGROWGRAPH_DEF_HPP
11 #define IFPACK2_OVERLAPPINGROWGRAPH_DEF_HPP
13 #include <Ifpack2_Details_OverlappingRowGraph_decl.hpp>
14 #include <Tpetra_Import.hpp>
15 #include <Tpetra_Export.hpp>
21 template<
class GraphType>
27 const Tpetra::global_size_t numGlobalRows,
28 const Tpetra::global_size_t numGlobalCols,
29 const Tpetra::global_size_t numGlobalNonzeros,
30 const size_t maxNumEntries,
33 nonoverlappingGraph_ (nonoverlappingGraph),
34 overlappingGraph_ (overlappingGraph),
37 numGlobalRows_ (numGlobalRows),
38 numGlobalCols_ (numGlobalCols),
39 numGlobalNonzeros_ (numGlobalNonzeros),
40 maxNumEntries_ (maxNumEntries),
41 nonoverlappingImporter_ (nonoverlappingImporter),
42 overlappingImporter_ (overlappingImporter)
46 template<
class GraphType>
50 template<
class GraphType>
54 return nonoverlappingGraph_->getComm ();
60 template<
class GraphType>
68 template<
class GraphType>
76 template<
class GraphType>
80 return nonoverlappingGraph_->getDomainMap ();
84 template<
class GraphType>
88 return nonoverlappingGraph_->getRangeMap ();
92 template<
class GraphType>
96 return nonoverlappingImporter_;
100 template<
class GraphType>
108 template<
class GraphType>
111 return numGlobalRows_;
115 template<
class GraphType>
118 return numGlobalCols_;
122 template<
class GraphType>
125 return nonoverlappingGraph_->getLocalNumRows () +
126 overlappingGraph_->getLocalNumRows ();
130 template<
class GraphType>
133 return this->getLocalNumRows ();
137 template<
class GraphType>
138 typename GraphType::global_ordinal_type
141 return nonoverlappingGraph_->getIndexBase ();
145 template<
class GraphType>
148 return numGlobalNonzeros_;
152 template<
class GraphType>
155 return nonoverlappingGraph_->getLocalNumEntries () +
156 overlappingGraph_->getLocalNumEntries ();
160 template<
class GraphType>
165 const local_ordinal_type localRow = rowMap_->getLocalElement (globalRow);
169 return getNumEntriesInLocalRow (localRow);
174 template<
class GraphType>
180 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows ();
181 if (as<size_t> (localRow) < numMyRowsA) {
182 return nonoverlappingGraph_->getNumEntriesInLocalRow (localRow);
184 return overlappingGraph_->getNumEntriesInLocalRow (as<local_ordinal_type> (localRow - numMyRowsA));
189 template<
class GraphType>
192 throw std::runtime_error(
"Ifpack2::OverlappingRowGraph::getGlobalMaxNumRowEntries() not supported.");
196 template<
class GraphType>
199 return maxNumEntries_;
203 template<
class GraphType>
210 template<
class GraphType>
217 template<
class GraphType>
224 template<
class GraphType>
230 template<
class GraphType>
234 nonconst_global_inds_host_view_type& indices,
235 size_t& numIndices)
const
237 const local_ordinal_type localRow = rowMap_->getLocalElement (globalRow);
241 if (Teuchos::as<size_t> (localRow) < nonoverlappingGraph_->getLocalNumRows ()) {
242 nonoverlappingGraph_->getGlobalRowCopy (globalRow, indices, numIndices);
244 overlappingGraph_->getGlobalRowCopy (globalRow, indices, numIndices);
250 template<
class GraphType>
254 nonconst_local_inds_host_view_type& indices,
255 size_t& numIndices)
const
258 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows ();
259 if (as<size_t> (localRow) < numMyRowsA) {
260 nonoverlappingGraph_->getLocalRowCopy (localRow, indices, numIndices);
262 const local_ordinal_type localRowOffset =
263 localRow - as<local_ordinal_type> (numMyRowsA);
264 overlappingGraph_->getLocalRowCopy (localRowOffset, indices, numIndices);
269 template<
class GraphType>
273 global_inds_host_view_type &indices)
const {
274 const local_ordinal_type LocalRow = rowMap_->getLocalElement (GlobalRow);
276 indices = global_inds_host_view_type();
278 if (Teuchos::as<size_t> (LocalRow) < nonoverlappingGraph_->getLocalNumRows ()) {
279 nonoverlappingGraph_->getGlobalRowView (GlobalRow, indices);
281 overlappingGraph_->getGlobalRowView (GlobalRow, indices);
287 template<
class GraphType>
291 local_inds_host_view_type & indices)
const {
293 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows ();
294 if (as<size_t> (LocalRow) < numMyRowsA) {
295 nonoverlappingGraph_->getLocalRowView (LocalRow, indices);
297 overlappingGraph_->getLocalRowView (LocalRow - as<local_ordinal_type> (numMyRowsA),
307 #define IFPACK2_DETAILS_OVERLAPPINGROWGRAPH_INSTANT(LO,GO,N) \
308 template class Ifpack2::Details::OverlappingRowGraph<Tpetra::CrsGraph< LO, GO, N > >; \
309 template class Ifpack2::Details::OverlappingRowGraph<Tpetra::RowGraph< LO, GO, N > >;
311 #endif // IFPACK2_OVERLAPPINGROWGRAPH_DEF_HPP
OverlappingRowGraph(const Teuchos::RCP< const row_graph_type > &nonoverlappingGraph, const Teuchos::RCP< const row_graph_type > &overlappingGraph, const Teuchos::RCP< const map_type > &rowMap, const Teuchos::RCP< const map_type > &colMap, const Tpetra::global_size_t numGlobalRows, const Tpetra::global_size_t numGlobalCols, const Tpetra::global_size_t numGlobalNonzeros, const size_t maxNumEntries, const Teuchos::RCP< const import_type > &nonoverlappingImporter, const Teuchos::RCP< const import_type > &overlappingImporter)
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:23
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual size_t getGlobalMaxNumRowEntries() const
The maximum number of entries in any row on any process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:190
virtual Teuchos::RCP< const map_type > getRowMap() const
The Map that describes the distribution of rows over processes.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:62
virtual bool isGloballyIndexed() const
Whether this graph is globally indexed.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:218
virtual bool hasColMap() const
Whether this graph has a column Map.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:204
virtual Teuchos::RCP< const export_type > getExporter() const
Export object (from row Map to range Map).
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:102
virtual void getLocalRowView(const local_ordinal_type lclRow, local_inds_host_view_type &lclColInds) const
Get a constant, nonpersisting, locally indexed view of the given row of the graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:290
virtual void getLocalRowCopy(local_ordinal_type localRow, nonconst_local_inds_host_view_type &gblColInds, size_t &numIndices) const
Copy out a list of local column indices in the given local row that are owned by the calling process...
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:253
virtual global_ordinal_type getIndexBase() const
The index base for global indices for this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:139
virtual void getGlobalRowView(const global_ordinal_type gblRow, global_inds_host_view_type &gblColInds) const
Get a const, non-persisting view of the given global row's global column indices, as a Teuchos::Array...
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:272
virtual Teuchos::RCP< const map_type > getDomainMap() const
The Map that describes the domain of this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:78
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the graph is distributed.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:52
virtual size_t getLocalNumCols() const
The number of columns owned by the calling process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:131
virtual size_t getLocalNumEntries() const
The number of entries in this graph owned by the calling process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:153
virtual ~OverlappingRowGraph()
Destructor.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:47
virtual bool isLocallyIndexed() const
Whether this graph is locally indexed.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:211
virtual bool isFillComplete() const
true if fillComplete() has been called, else false.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:225
virtual global_size_t getGlobalNumCols() const
The global number of columns in this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:116
virtual size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const
The number of entries in the given local row that are owned by the calling process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:177
virtual size_t getLocalNumRows() const
The number of rows owned by the calling process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:123
virtual void getGlobalRowCopy(global_ordinal_type globalRow, nonconst_global_inds_host_view_type &gblColInds, size_t &numIndices) const
Copy out a list of column indices in the given global row that are owned by the calling process...
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:233
TypeTo as(const TypeFrom &t)
virtual Teuchos::RCP< const import_type > getImporter() const
Import object (from domain Map to column Map).
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:94
virtual size_t getLocalMaxNumRowEntries() const
The maximum number of entries in any row on the calling process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:197
virtual Teuchos::RCP< const map_type > getColMap() const
The Map that describes the distribution of columns over processes.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:70
virtual global_size_t getGlobalNumRows() const
The global number of rows in this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:109
virtual Teuchos::RCP< const map_type > getRangeMap() const
The Map that describes the range of this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:86
virtual global_size_t getGlobalNumEntries() const
The global number of entries in this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:146
virtual size_t getNumEntriesInGlobalRow(global_ordinal_type globalRow) const
The number of entries in the given global row that are owned by the calling process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:163