Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_Details_OverlappingRowGraph_def.hpp
1// @HEADER
2// *****************************************************************************
3// Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
4//
5// Copyright 2009 NTESS and the Ifpack2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef IFPACK2_OVERLAPPINGROWGRAPH_DEF_HPP
11#define IFPACK2_OVERLAPPINGROWGRAPH_DEF_HPP
12
13#include <Ifpack2_Details_OverlappingRowGraph_decl.hpp>
14#include <Tpetra_Import.hpp>
15#include <Tpetra_Export.hpp>
16
17namespace Ifpack2 {
18namespace Details {
19
20template <class GraphType>
22 OverlappingRowGraph(const Teuchos::RCP<const row_graph_type>& nonoverlappingGraph,
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)
34 , rowMap_(rowMap)
35 , colMap_(colMap)
36 , numGlobalRows_(numGlobalRows)
37 , numGlobalCols_(numGlobalCols)
38 , numGlobalNonzeros_(numGlobalNonzeros)
39 , maxNumEntries_(maxNumEntries)
40 , nonoverlappingImporter_(nonoverlappingImporter)
41 , overlappingImporter_(overlappingImporter) {}
42
43template <class GraphType>
45
46template <class GraphType>
47Teuchos::RCP<const Teuchos::Comm<int> >
49 return nonoverlappingGraph_->getComm();
50}
51
52template <class GraphType>
53Teuchos::RCP<const Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
55 return rowMap_;
56}
57
58template <class GraphType>
59Teuchos::RCP<const Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
61 return colMap_;
62}
63
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();
68}
69
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();
74}
75
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_;
80}
81
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");
86}
87
88template <class GraphType>
90 return numGlobalRows_;
91}
92
93template <class GraphType>
95 return numGlobalCols_;
96}
97
98template <class GraphType>
100 return nonoverlappingGraph_->getLocalNumRows() +
101 overlappingGraph_->getLocalNumRows();
102}
103
104template <class GraphType>
106 return this->getLocalNumRows();
107}
108
109template <class GraphType>
110typename GraphType::global_ordinal_type
112 return nonoverlappingGraph_->getIndexBase();
113}
114
115template <class GraphType>
117 return numGlobalNonzeros_;
118}
119
120template <class GraphType>
122 return nonoverlappingGraph_->getLocalNumEntries() +
123 overlappingGraph_->getLocalNumEntries();
124}
125
126template <class GraphType>
127size_t
129 getNumEntriesInGlobalRow(global_ordinal_type globalRow) const {
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();
133 } else {
134 return getNumEntriesInLocalRow(localRow);
135 }
136}
137
138template <class GraphType>
139size_t
141 getNumEntriesInLocalRow(local_ordinal_type localRow) const {
142 using Teuchos::as;
143 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows();
145 return nonoverlappingGraph_->getNumEntriesInLocalRow(localRow);
146 } else {
147 return overlappingGraph_->getNumEntriesInLocalRow(as<local_ordinal_type>(localRow - numMyRowsA));
148 }
149}
150
151template <class GraphType>
153 throw std::runtime_error("Ifpack2::OverlappingRowGraph::getGlobalMaxNumRowEntries() not supported.");
154}
155
156template <class GraphType>
158 return maxNumEntries_;
159}
160
161template <class GraphType>
163 return true;
164}
165
166template <class GraphType>
168 return true;
169}
170
171template <class GraphType>
173 return false;
174}
175
176template <class GraphType>
178 return true;
179}
180
181template <class GraphType>
183 getGlobalRowCopy(global_ordinal_type globalRow,
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();
189 } else {
190 if (Teuchos::as<size_t>(localRow) < nonoverlappingGraph_->getLocalNumRows()) {
191 nonoverlappingGraph_->getGlobalRowCopy(globalRow, indices, numIndices);
192 } else {
193 overlappingGraph_->getGlobalRowCopy(globalRow, indices, numIndices);
194 }
195 }
196}
197
198template <class GraphType>
200 getLocalRowCopy(local_ordinal_type localRow,
201 nonconst_local_inds_host_view_type& indices,
202 size_t& numIndices) const {
203 using Teuchos::as;
204 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows();
206 nonoverlappingGraph_->getLocalRowCopy(localRow, indices, numIndices);
207 } else {
208 const local_ordinal_type localRowOffset =
210 overlappingGraph_->getLocalRowCopy(localRowOffset, indices, numIndices);
211 }
212}
213
214template <class GraphType>
216 getGlobalRowView(global_ordinal_type GlobalRow,
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();
221 } else {
222 if (Teuchos::as<size_t>(LocalRow) < nonoverlappingGraph_->getLocalNumRows()) {
223 nonoverlappingGraph_->getGlobalRowView(GlobalRow, indices);
224 } else {
225 overlappingGraph_->getGlobalRowView(GlobalRow, indices);
226 }
227 }
228}
229
230template <class GraphType>
232 getLocalRowView(local_ordinal_type LocalRow,
233 local_inds_host_view_type& indices) const {
234 using Teuchos::as;
235 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows();
237 nonoverlappingGraph_->getLocalRowView(LocalRow, indices);
238 } else {
239 overlappingGraph_->getLocalRowView(LocalRow - as<local_ordinal_type>(numMyRowsA),
240 indices);
241 }
242}
243
244} // namespace Details
245} // namespace Ifpack2
246
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> >;
250
251#endif // IFPACK2_OVERLAPPINGROWGRAPH_DEF_HPP
Ifpack2's implementation of Trilinos::Details::LinearSolver interface.
Definition Ifpack2_Details_LinearSolver_decl.hpp:75
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
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40