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
17
18namespace Ifpack2 {
19namespace Details {
20
21template<class GraphType>
23OverlappingRowGraph (const Teuchos::RCP<const row_graph_type>& nonoverlappingGraph,
24 const Teuchos::RCP<const row_graph_type>& overlappingGraph,
25 const Teuchos::RCP<const map_type>& rowMap,
26 const Teuchos::RCP<const map_type>& colMap,
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,
31 const Teuchos::RCP<const import_type>& nonoverlappingImporter,
32 const Teuchos::RCP<const import_type>& overlappingImporter) :
33 nonoverlappingGraph_ (nonoverlappingGraph),
34 overlappingGraph_ (overlappingGraph),
35 rowMap_ (rowMap),
36 colMap_ (colMap),
37 numGlobalRows_ (numGlobalRows),
38 numGlobalCols_ (numGlobalCols),
39 numGlobalNonzeros_ (numGlobalNonzeros),
40 maxNumEntries_ (maxNumEntries),
41 nonoverlappingImporter_ (nonoverlappingImporter),
42 overlappingImporter_ (overlappingImporter)
43{}
44
45
46template<class GraphType>
48
49
50template<class GraphType>
51Teuchos::RCP<const Teuchos::Comm<int> >
53{
54 return nonoverlappingGraph_->getComm ();
55}
56
57
58
59
60template<class GraphType>
61Teuchos::RCP<const Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
63{
64 return rowMap_;
65}
66
67
68template<class GraphType>
69Teuchos::RCP<const Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
71{
72 return colMap_;
73}
74
75
76template<class GraphType>
77Teuchos::RCP<const Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
79{
80 return nonoverlappingGraph_->getDomainMap ();
81}
82
83
84template<class GraphType>
85Teuchos::RCP<const Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
87{
88 return nonoverlappingGraph_->getRangeMap ();
89}
90
91
92template<class GraphType>
93Teuchos::RCP<const Tpetra::Import<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
95{
96 return nonoverlappingImporter_;
97}
98
99
100template<class GraphType>
101Teuchos::RCP<const Tpetra::Export<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type> >
103{
104 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Not implemented");
105}
106
107
108template<class GraphType>
110{
111 return numGlobalRows_;
112}
113
114
115template<class GraphType>
117{
118 return numGlobalCols_;
119}
120
121
122template<class GraphType>
124{
125 return nonoverlappingGraph_->getLocalNumRows () +
126 overlappingGraph_->getLocalNumRows ();
127}
128
129
130template<class GraphType>
132{
133 return this->getLocalNumRows ();
134}
135
136
137template<class GraphType>
138typename GraphType::global_ordinal_type
140{
141 return nonoverlappingGraph_->getIndexBase ();
142}
143
144
145template<class GraphType>
147{
148 return numGlobalNonzeros_;
149}
150
151
152template<class GraphType>
154{
155 return nonoverlappingGraph_->getLocalNumEntries () +
156 overlappingGraph_->getLocalNumEntries ();
157}
158
159
160template<class GraphType>
161size_t
163getNumEntriesInGlobalRow (global_ordinal_type globalRow) const
164{
165 const local_ordinal_type localRow = rowMap_->getLocalElement (globalRow);
166 if (localRow == Teuchos::OrdinalTraits<local_ordinal_type>::invalid ()) {
167 return Teuchos::OrdinalTraits<size_t>::invalid();
168 } else {
169 return getNumEntriesInLocalRow (localRow);
170 }
171}
172
173
174template<class GraphType>
175size_t
177getNumEntriesInLocalRow (local_ordinal_type localRow) const
178{
179 using Teuchos::as;
180 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows ();
181 if (as<size_t> (localRow) < numMyRowsA) {
182 return nonoverlappingGraph_->getNumEntriesInLocalRow (localRow);
183 } else {
184 return overlappingGraph_->getNumEntriesInLocalRow (as<local_ordinal_type> (localRow - numMyRowsA));
185 }
186}
187
188
189template<class GraphType>
191{
192 throw std::runtime_error("Ifpack2::OverlappingRowGraph::getGlobalMaxNumRowEntries() not supported.");
193}
194
195
196template<class GraphType>
198{
199 return maxNumEntries_;
200}
201
202
203template<class GraphType>
205{
206 return true;
207}
208
209
210template<class GraphType>
212{
213 return true;
214}
215
216
217template<class GraphType>
219{
220 return false;
221}
222
223
224template<class GraphType>
226{
227 return true;
228}
229
230template<class GraphType>
231void
233 getGlobalRowCopy (global_ordinal_type globalRow,
234 nonconst_global_inds_host_view_type& indices,
235 size_t& numIndices) const
236{
237 const local_ordinal_type localRow = rowMap_->getLocalElement (globalRow);
238 if (localRow == Teuchos::OrdinalTraits<local_ordinal_type>::invalid ()) {
239 numIndices = Teuchos::OrdinalTraits<size_t>::invalid ();
240 } else {
241 if (Teuchos::as<size_t> (localRow) < nonoverlappingGraph_->getLocalNumRows ()) {
242 nonoverlappingGraph_->getGlobalRowCopy (globalRow, indices, numIndices);
243 } else {
244 overlappingGraph_->getGlobalRowCopy (globalRow, indices, numIndices);
245 }
246 }
247}
248
249
250template<class GraphType>
251void
253getLocalRowCopy (local_ordinal_type localRow,
254 nonconst_local_inds_host_view_type& indices,
255 size_t& numIndices) const
256{
257 using Teuchos::as;
258 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows ();
259 if (as<size_t> (localRow) < numMyRowsA) {
260 nonoverlappingGraph_->getLocalRowCopy (localRow, indices, numIndices);
261 } else {
262 const local_ordinal_type localRowOffset =
263 localRow - as<local_ordinal_type> (numMyRowsA);
264 overlappingGraph_->getLocalRowCopy (localRowOffset, indices, numIndices);
265 }
266}
267
268
269template<class GraphType>
270void
272getGlobalRowView (global_ordinal_type GlobalRow,
273 global_inds_host_view_type &indices) const {
274 const local_ordinal_type LocalRow = rowMap_->getLocalElement (GlobalRow);
275 if (LocalRow == Teuchos::OrdinalTraits<local_ordinal_type>::invalid()) {
276 indices = global_inds_host_view_type();
277 } else {
278 if (Teuchos::as<size_t> (LocalRow) < nonoverlappingGraph_->getLocalNumRows ()) {
279 nonoverlappingGraph_->getGlobalRowView (GlobalRow, indices);
280 } else {
281 overlappingGraph_->getGlobalRowView (GlobalRow, indices);
282 }
283 }
284}
285
286
287template<class GraphType>
288void
290 getLocalRowView (local_ordinal_type LocalRow,
291 local_inds_host_view_type & indices) const {
292 using Teuchos::as;
293 const size_t numMyRowsA = nonoverlappingGraph_->getLocalNumRows ();
294 if (as<size_t> (LocalRow) < numMyRowsA) {
295 nonoverlappingGraph_->getLocalRowView (LocalRow, indices);
296 } else {
297 overlappingGraph_->getLocalRowView (LocalRow - as<local_ordinal_type> (numMyRowsA),
298 indices);
299 }
300
301}
302
303
304} // namespace Details
305} // namespace Ifpack2
306
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 > >;
310
311#endif // IFPACK2_OVERLAPPINGROWGRAPH_DEF_HPP
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 > getRangeMap() const
The Map that describes the range of this graph.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:86
virtual bool isLocallyIndexed() const
Whether this graph is locally indexed.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:211
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 bool isGloballyIndexed() const
Whether this graph is globally indexed.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:218
virtual global_size_t getGlobalNumEntries() const
The global number of entries in this graph.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:146
virtual size_t getGlobalMaxNumRowEntries() const
The maximum number of entries in any row on any process.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:190
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
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 bool isFillComplete() const
true if fillComplete() has been called, else false.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:225
virtual bool hasColMap() const
Whether this graph has a column Map.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:204
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 Teuchos::RCP< const import_type > getImporter() const
Import object (from domain Map to column Map).
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:94
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 > getColMap() const
The Map that describes the distribution of columns over processes.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:70
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 size_t getLocalNumCols() const
The number of columns owned by the calling process.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:131
virtual global_size_t getGlobalNumCols() const
The global number of columns in this graph.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:116
virtual size_t getLocalNumRows() const
The number of rows owned by the calling process.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:123
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 ~OverlappingRowGraph()
Destructor.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:47
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 Teuchos::RCP< const export_type > getExporter() const
Export object (from row Map to range Map).
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:102
virtual global_ordinal_type getIndexBase() const
The index base for global indices for this graph.
Definition Ifpack2_Details_OverlappingRowGraph_def.hpp:139
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
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
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
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41