Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_OverlappingRowMatrix_decl.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_OVERLAPPINGROWMATRIX_DECL_HPP
11 #define IFPACK2_OVERLAPPINGROWMATRIX_DECL_HPP
12 
13 #include "Ifpack2_Details_RowMatrix.hpp"
14 #include "Tpetra_CrsMatrix_decl.hpp" // only need the declaration here
15 #include "Tpetra_Import_decl.hpp"
16 #include "Tpetra_Map_decl.hpp"
17 #include <type_traits>
18 
19 namespace Ifpack2 {
20 
24 template<class MatrixType>
26  virtual public Ifpack2::Details::RowMatrix<MatrixType> {
27 public:
29 
30  typedef typename MatrixType::scalar_type scalar_type;
31  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
32  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
33  typedef typename MatrixType::node_type node_type;
34  typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
35  typedef typename MatrixType::global_inds_host_view_type global_inds_host_view_type;
36  typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
37  typedef typename MatrixType::values_host_view_type values_host_view_type;
38 
39  typedef typename MatrixType::nonconst_global_inds_host_view_type nonconst_global_inds_host_view_type;
40  typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
41  typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
42 
43  using row_matrix_type = Tpetra::RowMatrix<scalar_type, local_ordinal_type,
44  global_ordinal_type, node_type>;
45  using crs_matrix_type = Tpetra::CrsMatrix<scalar_type, local_ordinal_type,
46  global_ordinal_type, node_type>;
47 
48  // device typedefs
49  typedef typename MatrixType::node_type::device_type device_type;
50  typedef typename device_type::execution_space execution_space;
51  typedef typename MatrixType::local_inds_device_view_type local_inds_device_view_type;
52  typedef typename MatrixType::global_inds_device_view_type global_inds_device_view_type;
53  typedef typename MatrixType::values_device_view_type values_device_view_type;
54 
55  static_assert(std::is_same<MatrixType, row_matrix_type>::value, "Ifpack2::OverlappingRowMatrix: The template parameter MatrixType must be a Tpetra::RowMatrix specialization. Please don't use Tpetra::CrsMatrix (a subclass of Tpetra::RowMatrix) here anymore. The constructor can take either a RowMatrix or a CrsMatrix just fine.");
56 
57  typedef typename row_matrix_type::mag_type mag_type;
58 
60 
62 
74  const int overlapLevel);
75 
77  ~OverlappingRowMatrix () = default;
78 
80 
82 
85 
86 
89  getRowMap () const;
90 
93  getColMap () const;
94 
99  getDomainMap () const;
100 
105  getRangeMap () const;
106 
109  getGraph () const;
110 
112  virtual global_size_t getGlobalNumRows () const;
113 
115  virtual global_size_t getGlobalNumCols () const;
116 
118  virtual size_t getLocalNumRows () const;
119 
125  virtual size_t getLocalNumCols () const;
126 
128  virtual global_ordinal_type getIndexBase () const;
129 
131  virtual global_size_t getGlobalNumEntries () const;
132 
134  virtual size_t getLocalNumEntries () const;
135 
145  virtual size_t getNumEntriesInGlobalRow (global_ordinal_type globalRow) const;
146 
156  virtual size_t getNumEntriesInLocalRow (local_ordinal_type localRow) const;
157 
159  virtual size_t getGlobalMaxNumRowEntries () const;
160 
162  virtual size_t getLocalMaxNumRowEntries() const;
163 
165  virtual local_ordinal_type getBlockSize () const;
166 
168  virtual bool hasColMap() const;
169 
171  virtual bool isLocallyIndexed () const;
172 
174  virtual bool isGloballyIndexed () const;
175 
177  virtual bool isFillComplete() const;
178 
180  virtual bool supportsRowViews() const;
181 
183 
185 
187 
197  virtual void
198  getGlobalRowCopy (global_ordinal_type GlobalRow,
199  nonconst_global_inds_host_view_type &Indices,
200  nonconst_values_host_view_type &Values,
201  size_t& NumEntries) const;
202 
204 
214  virtual void
215  getLocalRowCopy (local_ordinal_type LocalRow,
216  nonconst_local_inds_host_view_type &Indices,
217  nonconst_values_host_view_type &Values,
218  size_t& NumEntries) const;
219 
221 
230  virtual void
231  getGlobalRowView (global_ordinal_type GlobalRow,
232  global_inds_host_view_type &indices,
233  values_host_view_type &values) const;
234 
236 
245  virtual void
246  getLocalRowView (local_ordinal_type LocalRow,
247  local_inds_host_view_type & indices,
248  values_host_view_type & values) const;
249 
251 
253  virtual
254  void getLocalDiagCopy (Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &diag) const;
255 
257 
259 
269  virtual void
270  leftScale (const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
271 
281  virtual void
282  rightScale (const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
283 
285 
288  virtual mag_type
289  getFrobeniusNorm () const;
290 
292 
299  virtual void
300  apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
301  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
303  scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
304  scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
305 
307  virtual bool hasTransposeApply() const;
308 
309  virtual void
310  importMultiVector (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
311  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &OvX,
312  Tpetra::CombineMode CM = Tpetra::INSERT);
313 
314  virtual void
315  exportMultiVector (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &OvX,
316  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
317  Tpetra::CombineMode CM = Tpetra::ADD);
318 
319  std::string description() const;
320 
321  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const;
322 
323  Teuchos::RCP<const crs_matrix_type> getUnderlyingMatrix() const;
324 
325  Teuchos::RCP<const crs_matrix_type> getExtMatrix() const;
326 
327  Kokkos::View<size_t*, typename OverlappingRowMatrix<MatrixType>::device_type> getExtHaloStarts() const;
328  typename Kokkos::View<size_t*, typename OverlappingRowMatrix<MatrixType>::device_type>::HostMirror getExtHaloStartsHost() const;
329 
330  void doExtImport();
331 
332 private:
333  typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
334  typedef Tpetra::Import<local_ordinal_type, global_ordinal_type, node_type> import_type;
335  typedef Tpetra::Export<local_ordinal_type, global_ordinal_type, node_type> export_type;
336  typedef Tpetra::RowGraph<local_ordinal_type, global_ordinal_type, node_type> row_graph_type;
337  typedef Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> vector_type;
338 
341 
342  Tpetra::global_size_t NumGlobalRows_;
343  Tpetra::global_size_t NumGlobalNonzeros_;
344  size_t MaxNumEntries_;
345  int OverlapLevel_;
346 
347  // Wrapper matrix objects
351 
355  Teuchos::RCP<const import_type> ExtImporter_;
356  Kokkos::View<size_t*, device_type> ExtHaloStarts_;
357  typename Kokkos::View<size_t*, device_type>::HostMirror ExtHaloStarts_h;
358 
362  mutable nonconst_local_inds_host_view_type Indices_;
364  mutable nonconst_values_host_view_type Values_;
365 
366 
367 }; // class OverlappingRowMatrix
368 
369 } // namespace Ifpack2
370 
371 #endif // IFPACK2_OVERLAPPINGROWMATRIX_DECL_HPP
~OverlappingRowMatrix()=default
Destructor.
virtual bool isGloballyIndexed() const
Whether this matrix is globally indexed.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:382
All Ifpack2 implementations of Tpetra::RowMatrix must inherit from this class.
Definition: Ifpack2_Details_RowMatrix.hpp:30
virtual mag_type getFrobeniusNorm() const
Returns the Frobenius norm of the matrix.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:513
virtual bool isFillComplete() const
true if fillComplete() has been called, else false.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:389
virtual void getLocalRowCopy(local_ordinal_type LocalRow, nonconst_local_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const
Extract a list of entries in a specified local row of the graph. Put into storage allocated by callin...
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:409
virtual void leftScale(const Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &x)
Scales the RowMatrix on the left with the Vector x.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:496
virtual size_t getLocalMaxNumRowEntries() const
The maximum number of entries in any row on the calling process.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:356
virtual size_t getLocalNumRows() const
The number of rows owned by the calling process.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:284
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the matrix is distributed.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:211
virtual Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getRowMap() const
The Map that describes the distribution of rows over processes.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:221
virtual global_size_t getGlobalNumRows() const
The global number of rows in this matrix.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:270
virtual global_size_t getGlobalNumCols() const
The global number of columns in this matrix.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:277
virtual bool isLocallyIndexed() const
Whether this matrix is locally indexed.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:375
virtual void getGlobalRowCopy(global_ordinal_type GlobalRow, nonconst_global_inds_host_view_type &Indices, nonconst_values_host_view_type &Values, size_t &NumEntries) const
Extract a list of entries in a specified global row of this matrix. Put into pre-allocated storage...
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:398
virtual local_ordinal_type getBlockSize() const
The number of degrees of freedom per mesh point.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:362
virtual Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getRangeMap() const
The Map that describes the range of this matrix.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:255
virtual size_t getLocalNumCols() const
The number of columns owned by the calling process.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:291
virtual Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getDomainMap() const
The Map that describes the domain of this matrix.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:239
virtual void getLocalRowView(local_ordinal_type LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const
Extract a const, non-persisting view of local indices in a specified row of the matrix.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:446
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_OverlappingRowMatrix_def.hpp:322
virtual global_size_t getGlobalNumEntries() const
The global number of entries in this matrix.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:306
virtual bool hasTransposeApply() const
Whether this operator&#39;s apply() method can apply the adjoint (transpose).
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:580
virtual global_ordinal_type getIndexBase() const
The index base for global indices for this matrix.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:299
virtual bool hasColMap() const
Whether this matrix has a column Map.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:368
virtual void getGlobalRowView(global_ordinal_type GlobalRow, global_inds_host_view_type &indices, values_host_view_type &values) const
Extract a const, non-persisting view of global indices in a specified row of the matrix.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:427
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_OverlappingRowMatrix_def.hpp:336
virtual void rightScale(const Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &x)
Scales the RowMatrix on the right with the Vector x.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:505
virtual Teuchos::RCP< const Tpetra::RowGraph< local_ordinal_type, global_ordinal_type, node_type > > getGraph() const
This matrix&#39;s graph.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:263
virtual void getLocalDiagCopy(Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &diag) const
Get a copy of the diagonal entries owned by this node, with local row indices.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:463
Sparse matrix (Tpetra::RowMatrix subclass) with ghost rows.
Definition: Ifpack2_OverlappingRowMatrix_decl.hpp:25
OverlappingRowMatrix(const Teuchos::RCP< const row_matrix_type > &A, const int overlapLevel)
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:27
virtual void apply(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const
Computes the operator-multivector application.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:522
virtual size_t getLocalNumEntries() const
The number of entries in this matrix owned by the calling process.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:313
virtual Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getColMap() const
The Map that describes the distribution of columns over processes.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:230
virtual bool supportsRowViews() const
true if row views are supported, else false.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:587
virtual size_t getGlobalMaxNumRowEntries() const
The maximum number of entries in any row on any process.
Definition: Ifpack2_OverlappingRowMatrix_def.hpp:349