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>
20template <
class GraphType>
23 const Teuchos::RCP<const row_graph_type>& overlappingGraph,
24 const Teuchos::RCP<const map_type>& rowMap,
25 const Teuchos::RCP<const map_type>& colMap,
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,
30 const Teuchos::RCP<const import_type>& nonoverlappingImporter,
31 const Teuchos::RCP<const import_type>& overlappingImporter)
32 : nonoverlappingGraph_(nonoverlappingGraph)
33 , overlappingGraph_(overlappingGraph)
36 , numGlobalRows_(numGlobalRows)
37 , numGlobalCols_(numGlobalCols)
38 , numGlobalNonzeros_(numGlobalNonzeros)
39 , maxNumEntries_(maxNumEntries)
40 , nonoverlappingImporter_(nonoverlappingImporter)
41 , overlappingImporter_(overlappingImporter) {}
43template <
class GraphType>
46template <
class GraphType>
47Teuchos::RCP<const Teuchos::Comm<int> >
49 return nonoverlappingGraph_->getComm();
52template <
class GraphType>
53Teuchos::RCP<const Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
58template <
class GraphType>
59Teuchos::RCP<const Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
64template <
class GraphType>
65Teuchos::RCP<const Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
67 return nonoverlappingGraph_->getDomainMap();
70template <
class GraphType>
71Teuchos::RCP<const Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
73 return nonoverlappingGraph_->getRangeMap();
76template <
class GraphType>
77Teuchos::RCP<const Tpetra::Import<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
79 return nonoverlappingImporter_;
82template <
class GraphType>
83Teuchos::RCP<const Tpetra::Export<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
85 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Not implemented");
88template <
class GraphType>
90 return numGlobalRows_;
93template <
class GraphType>
95 return numGlobalCols_;
98template <
class GraphType>
100 return nonoverlappingGraph_->getLocalNumRows() +
101 overlappingGraph_->getLocalNumRows();
104template <
class GraphType>
109template <
class GraphType>
110typename GraphType::global_ordinal_type
112 return nonoverlappingGraph_->getIndexBase();
115template <
class GraphType>
117 return numGlobalNonzeros_;
120template <
class GraphType>
122 return nonoverlappingGraph_->getLocalNumEntries() +
123 overlappingGraph_->getLocalNumEntries();
126template <
class GraphType>
130 const local_ordinal_type localRow = rowMap_->getLocalElement(globalRow);
131 if (localRow == Teuchos::OrdinalTraits<local_ordinal_type>::invalid()) {
132 return Teuchos::OrdinalTraits<size_t>::invalid();
138template <
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));
151template <
class GraphType>
153 throw std::runtime_error(
"Ifpack2::OverlappingRowGraph::getGlobalMaxNumRowEntries() not supported.");
156template <
class GraphType>
158 return maxNumEntries_;
161template <
class GraphType>
166template <
class GraphType>
171template <
class GraphType>
176template <
class GraphType>
181template <
class GraphType>
184 nonconst_global_inds_host_view_type& indices,
185 size_t& numIndices)
const {
186 const local_ordinal_type localRow = rowMap_->getLocalElement(globalRow);
187 if (localRow == Teuchos::OrdinalTraits<local_ordinal_type>::invalid()) {
188 numIndices = Teuchos::OrdinalTraits<size_t>::invalid();
190 if (Teuchos::as<size_t>(localRow) < nonoverlappingGraph_->getLocalNumRows()) {
191 nonoverlappingGraph_->getGlobalRowCopy(globalRow, indices, numIndices);
193 overlappingGraph_->getGlobalRowCopy(globalRow, indices, numIndices);
198template <
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);
214template <
class GraphType>
217 global_inds_host_view_type& indices)
const {
218 const local_ordinal_type LocalRow = rowMap_->getLocalElement(GlobalRow);
219 if (LocalRow == Teuchos::OrdinalTraits<local_ordinal_type>::invalid()) {
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);
230template <
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> >;
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 > getRangeMap() const
The Map that describes the range of this graph.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:72
virtual bool isLocallyIndexed() const
Whether this graph is locally indexed.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:167
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 bool isGloballyIndexed() const
Whether this graph is globally indexed.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:172
virtual global_size_t getGlobalNumEntries() const
The global number of entries in this graph.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:116
virtual size_t getGlobalMaxNumRowEntries() const
The maximum number of entries in any row on any process.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:152
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
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 bool isFillComplete() const
true if fillComplete() has been called, else false.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:177
virtual bool hasColMap() const
Whether this graph has a column Map.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:162
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 Teuchos::RCP< const import_type > getImporter() const
Import object (from domain Map to column Map).
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:78
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 > getColMap() const
The Map that describes the distribution of columns over processes.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:60
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 size_t getLocalNumCols() const
The number of columns owned by the calling process.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:105
virtual global_size_t getGlobalNumCols() const
The global number of columns in this graph.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:94
virtual size_t getLocalNumRows() const
The number of rows owned by the calling process.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:99
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 ~OverlappingRowGraph()
Destructor.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:44
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 Teuchos::RCP< const export_type > getExporter() const
Export object (from row Map to range Map).
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:84
virtual global_ordinal_type getIndexBase() const
The index base for global indices for this graph.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:111
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
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
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
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40