Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 
18 namespace Ifpack2 {
19 namespace Details {
20 
21 template<class GraphType>
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 
46 template<class GraphType>
48 
49 
50 template<class GraphType>
53 {
54  return nonoverlappingGraph_->getComm ();
55 }
56 
57 
58 
59 
60 template<class GraphType>
63 {
64  return rowMap_;
65 }
66 
67 
68 template<class GraphType>
71 {
72  return colMap_;
73 }
74 
75 
76 template<class GraphType>
79 {
80  return nonoverlappingGraph_->getDomainMap ();
81 }
82 
83 
84 template<class GraphType>
87 {
88  return nonoverlappingGraph_->getRangeMap ();
89 }
90 
91 
92 template<class GraphType>
95 {
96  return nonoverlappingImporter_;
97 }
98 
99 
100 template<class GraphType>
103 {
104  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Not implemented");
105 }
106 
107 
108 template<class GraphType>
110 {
111  return numGlobalRows_;
112 }
113 
114 
115 template<class GraphType>
117 {
118  return numGlobalCols_;
119 }
120 
121 
122 template<class GraphType>
124 {
125  return nonoverlappingGraph_->getLocalNumRows () +
126  overlappingGraph_->getLocalNumRows ();
127 }
128 
129 
130 template<class GraphType>
132 {
133  return this->getLocalNumRows ();
134 }
135 
136 
137 template<class GraphType>
138 typename GraphType::global_ordinal_type
140 {
141  return nonoverlappingGraph_->getIndexBase ();
142 }
143 
144 
145 template<class GraphType>
147 {
148  return numGlobalNonzeros_;
149 }
150 
151 
152 template<class GraphType>
154 {
155  return nonoverlappingGraph_->getLocalNumEntries () +
156  overlappingGraph_->getLocalNumEntries ();
157 }
158 
159 
160 template<class GraphType>
161 size_t
163 getNumEntriesInGlobalRow (global_ordinal_type globalRow) const
164 {
165  const local_ordinal_type localRow = rowMap_->getLocalElement (globalRow);
168  } else {
169  return getNumEntriesInLocalRow (localRow);
170  }
171 }
172 
173 
174 template<class GraphType>
175 size_t
177 getNumEntriesInLocalRow (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 
189 template<class GraphType>
191 {
192  throw std::runtime_error("Ifpack2::OverlappingRowGraph::getGlobalMaxNumRowEntries() not supported.");
193 }
194 
195 
196 template<class GraphType>
198 {
199  return maxNumEntries_;
200 }
201 
202 
203 template<class GraphType>
205 {
206  return true;
207 }
208 
209 
210 template<class GraphType>
212 {
213  return true;
214 }
215 
216 
217 template<class GraphType>
219 {
220  return false;
221 }
222 
223 
224 template<class GraphType>
226 {
227  return true;
228 }
229 
230 template<class GraphType>
231 void
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);
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 
250 template<class GraphType>
251 void
253 getLocalRowCopy (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 
269 template<class GraphType>
270 void
272 getGlobalRowView (global_ordinal_type GlobalRow,
273  global_inds_host_view_type &indices) const {
274  const local_ordinal_type LocalRow = rowMap_->getLocalElement (GlobalRow);
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 
287 template<class GraphType>
288 void
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
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&#39;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