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>
20 template <
class GraphType>
26 const Tpetra::global_size_t numGlobalRows,
27 const Tpetra::global_size_t numGlobalCols,
28 const Tpetra::global_size_t numGlobalNonzeros,
29 const size_t maxNumEntries,
32 : nonoverlappingGraph_(nonoverlappingGraph)
33 , overlappingGraph_(overlappingGraph)
36 , numGlobalRows_(numGlobalRows)
37 , numGlobalCols_(numGlobalCols)
38 , numGlobalNonzeros_(numGlobalNonzeros)
39 , maxNumEntries_(maxNumEntries)
40 , nonoverlappingImporter_(nonoverlappingImporter)
41 , overlappingImporter_(overlappingImporter) {}
43 template <
class GraphType>
46 template <
class GraphType>
49 return nonoverlappingGraph_->getComm();
52 template <
class GraphType>
58 template <
class GraphType>
64 template <
class GraphType>
67 return nonoverlappingGraph_->getDomainMap();
70 template <
class GraphType>
73 return nonoverlappingGraph_->getRangeMap();
76 template <
class GraphType>
79 return nonoverlappingImporter_;
82 template <
class GraphType>
88 template <
class GraphType>
90 return numGlobalRows_;
93 template <
class GraphType>
95 return numGlobalCols_;
98 template <
class GraphType>
100 return nonoverlappingGraph_->getLocalNumRows() +
101 overlappingGraph_->getLocalNumRows();
104 template <
class GraphType>
106 return this->getLocalNumRows();
109 template <
class GraphType>
110 typename GraphType::global_ordinal_type
112 return nonoverlappingGraph_->getIndexBase();
115 template <
class GraphType>
117 return numGlobalNonzeros_;
120 template <
class GraphType>
122 return nonoverlappingGraph_->getLocalNumEntries() +
123 overlappingGraph_->getLocalNumEntries();
126 template <
class GraphType>
130 const local_ordinal_type localRow = rowMap_->getLocalElement(globalRow);
134 return getNumEntriesInLocalRow(localRow);
138 template <
class GraphType>
143 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows();
144 if (as<size_t>(localRow) < numMyRowsA) {
145 return nonoverlappingGraph_->getNumEntriesInLocalRow(localRow);
147 return overlappingGraph_->getNumEntriesInLocalRow(as<local_ordinal_type>(localRow - numMyRowsA));
151 template <
class GraphType>
153 throw std::runtime_error(
"Ifpack2::OverlappingRowGraph::getGlobalMaxNumRowEntries() not supported.");
156 template <
class GraphType>
158 return maxNumEntries_;
161 template <
class GraphType>
166 template <
class GraphType>
171 template <
class GraphType>
176 template <
class GraphType>
181 template <
class GraphType>
184 nonconst_global_inds_host_view_type& indices,
185 size_t& numIndices)
const {
186 const local_ordinal_type localRow = rowMap_->getLocalElement(globalRow);
190 if (Teuchos::as<size_t>(localRow) < nonoverlappingGraph_->getLocalNumRows()) {
191 nonoverlappingGraph_->getGlobalRowCopy(globalRow, indices, numIndices);
193 overlappingGraph_->getGlobalRowCopy(globalRow, indices, numIndices);
198 template <
class GraphType>
201 nonconst_local_inds_host_view_type& indices,
202 size_t& numIndices)
const {
204 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows();
205 if (as<size_t>(localRow) < numMyRowsA) {
206 nonoverlappingGraph_->getLocalRowCopy(localRow, indices, numIndices);
208 const local_ordinal_type localRowOffset =
209 localRow - as<local_ordinal_type>(numMyRowsA);
210 overlappingGraph_->getLocalRowCopy(localRowOffset, indices, numIndices);
214 template <
class GraphType>
217 global_inds_host_view_type& indices)
const {
218 const local_ordinal_type LocalRow = rowMap_->getLocalElement(GlobalRow);
220 indices = global_inds_host_view_type();
222 if (Teuchos::as<size_t>(LocalRow) < nonoverlappingGraph_->getLocalNumRows()) {
223 nonoverlappingGraph_->getGlobalRowView(GlobalRow, indices);
225 overlappingGraph_->getGlobalRowView(GlobalRow, indices);
230 template <
class GraphType>
233 local_inds_host_view_type& indices)
const {
235 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows();
236 if (as<size_t>(LocalRow) < numMyRowsA) {
237 nonoverlappingGraph_->getLocalRowView(LocalRow, indices);
239 overlappingGraph_->getLocalRowView(LocalRow - as<local_ordinal_type>(numMyRowsA),
247 #define IFPACK2_DETAILS_OVERLAPPINGROWGRAPH_INSTANT(LO, GO, N) \
248 template class Ifpack2::Details::OverlappingRowGraph<Tpetra::CrsGraph<LO, GO, N> >; \
249 template class Ifpack2::Details::OverlappingRowGraph<Tpetra::RowGraph<LO, GO, N> >;
251 #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:22
#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:152
virtual Teuchos::RCP< const map_type > getRowMap() const
The Map that describes the distribution of rows over processes.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:54
virtual bool isGloballyIndexed() const
Whether this graph is globally indexed.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:172
virtual bool hasColMap() const
Whether this graph has a column Map.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:162
virtual Teuchos::RCP< const export_type > getExporter() const
Export object (from row Map to range Map).
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:84
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:232
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:200
virtual global_ordinal_type getIndexBase() const
The index base for global indices for this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:111
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:216
virtual Teuchos::RCP< const map_type > getDomainMap() const
The Map that describes the domain of this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:66
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the graph is distributed.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:48
virtual size_t getLocalNumCols() const
The number of columns owned by the calling process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:105
virtual size_t getLocalNumEntries() const
The number of entries in this graph owned by the calling process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:121
virtual ~OverlappingRowGraph()
Destructor.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:44
virtual bool isLocallyIndexed() const
Whether this graph is locally indexed.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:167
virtual bool isFillComplete() const
true if fillComplete() has been called, else false.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:177
virtual global_size_t getGlobalNumCols() const
The global number of columns in this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:94
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:141
virtual size_t getLocalNumRows() const
The number of rows owned by the calling process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:99
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:183
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:78
virtual size_t getLocalMaxNumRowEntries() const
The maximum number of entries in any row on the calling process.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:157
virtual Teuchos::RCP< const map_type > getColMap() const
The Map that describes the distribution of columns over processes.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:60
virtual global_size_t getGlobalNumRows() const
The global number of rows in this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:89
virtual Teuchos::RCP< const map_type > getRangeMap() const
The Map that describes the range of this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:72
virtual global_size_t getGlobalNumEntries() const
The global number of entries in this graph.
Definition: Ifpack2_Details_OverlappingRowGraph_def.hpp:116
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:129