Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_ReorderFilter_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_REORDERFILTER_DECL_HPP
11 #define IFPACK2_REORDERFILTER_DECL_HPP
12 
13 #include "Ifpack2_ConfigDefs.hpp"
14 #include "Ifpack2_Details_RowMatrix.hpp"
15 #include <type_traits>
16 
17 namespace Ifpack2 {
18 
35 template<class MatrixType>
37  virtual public Ifpack2::Details::RowMatrix<MatrixType> {
38 public:
39  typedef typename MatrixType::scalar_type scalar_type;
40  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
41  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
42  typedef typename MatrixType::node_type node_type;
43  typedef typename MatrixType::global_inds_host_view_type global_inds_host_view_type;
44  typedef typename MatrixType::local_inds_host_view_type local_inds_host_view_type;
45  typedef typename MatrixType::values_host_view_type values_host_view_type;
46 
47  typedef typename MatrixType::nonconst_global_inds_host_view_type nonconst_global_inds_host_view_type;
48  typedef typename MatrixType::nonconst_local_inds_host_view_type nonconst_local_inds_host_view_type;
49  typedef typename MatrixType::nonconst_values_host_view_type nonconst_values_host_view_type;
50 
51  typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
52  typedef Tpetra::RowMatrix<scalar_type,
53  local_ordinal_type,
54  global_ordinal_type,
55  node_type> row_matrix_type;
56 
57  static_assert(std::is_same<MatrixType, row_matrix_type>::value, "Ifpack2::ReorderFilter: 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.");
58 
59  typedef Tpetra::Map<local_ordinal_type,
60  global_ordinal_type,
61  node_type> map_type;
62 
63  typedef typename row_matrix_type::mag_type mag_type;
64 
66 
67 
85  const Teuchos::ArrayRCP<local_ordinal_type>& reverseperm);
86 
88  virtual ~ReorderFilter ();
89 
91 
93 
96 
97 
100 
102  virtual Teuchos::RCP<const map_type> getColMap() const;
103 
106 
109 
112 
114  virtual global_size_t getGlobalNumRows() const;
115 
117  virtual global_size_t getGlobalNumCols() const;
118 
120  virtual size_t getLocalNumRows() const;
121 
123  virtual size_t getLocalNumCols() const;
124 
126  virtual global_ordinal_type getIndexBase() const;
127 
129  virtual global_size_t getGlobalNumEntries() const;
130 
132  virtual size_t getLocalNumEntries() const;
133 
135  virtual local_ordinal_type getBlockSize () const;
136 
143  virtual size_t getNumEntriesInGlobalRow (global_ordinal_type globalRow) const;
144 
151  virtual size_t getNumEntriesInLocalRow (local_ordinal_type localRow) const;
152 
154  virtual size_t getGlobalMaxNumRowEntries() const;
155 
157  virtual size_t getLocalMaxNumRowEntries() const;
158 
160  virtual bool hasColMap() const;
161 
163  virtual bool isLocallyIndexed() const;
164 
166  virtual bool isGloballyIndexed() const;
167 
169  virtual bool isFillComplete() const;
170 
172  virtual bool supportsRowViews() const;
173 
175 
177 
178 
180 
190  virtual void
191  getGlobalRowCopy (global_ordinal_type GlobalRow,
192  nonconst_global_inds_host_view_type &Indices,
193  nonconst_values_host_view_type &Values,
194  size_t& NumEntries) const;
195 
197 
207  virtual void
208  getLocalRowCopy (local_ordinal_type LocalRow,
209  nonconst_local_inds_host_view_type &Indices,
210  nonconst_values_host_view_type &Values,
211  size_t& NumEntries) const;
212 
214 
222  virtual void
223  getGlobalRowView (global_ordinal_type GlobalRow,
224  global_inds_host_view_type &indices,
225  values_host_view_type &values) const;
226 
228 
237  virtual void
238  getLocalRowView (local_ordinal_type LocalRow,
239  local_inds_host_view_type & indices,
240  values_host_view_type & values) const;
241 
243 
245  virtual void getLocalDiagCopy(Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &diag) const;
246 
248 
250 
251 
261  virtual void leftScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
262 
272  virtual void rightScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x);
273 
275 
278  virtual mag_type getFrobeniusNorm() const;
279 
301  virtual void
302  apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
303  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
305  scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
306  scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
307 
309  virtual bool hasTransposeApply() const;
310 
312  virtual void permuteOriginalToReordered(const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &originalX,
313  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const;
314 
315  template <class DomainScalar, class RangeScalar>
316  void
317  permuteOriginalToReorderedTempl (const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &originalX,
318  Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const;
319 
321  virtual void permuteReorderedToOriginal(const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &reorderedX,
322  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &originalY) const;
323 
324  template <class DomainScalar, class RangeScalar>
325  void permuteReorderedToOriginalTempl(const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedX,
326  Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &originalY) const;
328 
329 private:
336 
338  mutable nonconst_local_inds_host_view_type Indices_;
340  mutable nonconst_values_host_view_type Values_;
341 };// class ReorderFilter
342 
343 }// namespace Ifpack2
344 
345 #endif /* IFPACK2_REORDERFILTER_DECL_HPP */
virtual size_t getLocalNumRows() const
Returns the number of rows owned on the calling node.
Definition: Ifpack2_ReorderFilter_def.hpp:140
Wraps a Tpetra::RowMatrix in a filter that reorders local rows and columns.
Definition: Ifpack2_ReorderFilter_decl.hpp:36
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_ReorderFilter_def.hpp:447
virtual Teuchos::RCP< const map_type > getRowMap() const
Returns the Map that describes the row distribution in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:69
virtual bool supportsRowViews() const
Returns true if RowViews are supported.
Definition: Ifpack2_ReorderFilter_def.hpp:440
virtual size_t getGlobalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on all nodes.
Definition: Ifpack2_ReorderFilter_def.hpp:217
virtual Teuchos::RCP< const map_type > getDomainMap() const
Returns the Map that describes the domain distribution in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:93
virtual global_size_t getGlobalNumRows() const
Returns the number of global rows in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:126
virtual size_t getLocalNumCols() const
Returns the number of columns needed to apply the forward operator on this node, i.e., the number of elements listed in the column map.
Definition: Ifpack2_ReorderFilter_def.hpp:147
virtual Teuchos::RCP< const map_type > getColMap() const
Returns the Map that describes the column distribution in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:81
ReorderFilter(const Teuchos::RCP< const row_matrix_type > &A, const Teuchos::ArrayRCP< local_ordinal_type > &perm, const Teuchos::ArrayRCP< local_ordinal_type > &reverseperm)
Constructor.
Definition: Ifpack2_ReorderFilter_def.hpp:25
virtual Teuchos::RCP< const map_type > getRangeMap() const
Returns the Map that describes the range distribution in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:105
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_ReorderFilter_def.hpp:332
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
, where Op(A) is either A, , or .
Definition: Ifpack2_ReorderFilter_def.hpp:376
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_ReorderFilter_def.hpp:260
virtual bool isGloballyIndexed() const
If matrix indices are in the global range, this function returns true. Otherwise, this function retur...
Definition: Ifpack2_ReorderFilter_def.hpp:245
virtual Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The matrix&#39;s communicator.
Definition: Ifpack2_ReorderFilter_def.hpp:59
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_ReorderFilter_def.hpp:353
virtual size_t getNumEntriesInLocalRow(local_ordinal_type localRow) const
The current number of entries in this matrix, stored on the calling process, in the row whose local i...
Definition: Ifpack2_ReorderFilter_def.hpp:201
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_ReorderFilter_def.hpp:342
virtual bool hasColMap() const
Indicates whether this matrix has a well-defined column map.
Definition: Ifpack2_ReorderFilter_def.hpp:231
virtual size_t getNumEntriesInGlobalRow(global_ordinal_type globalRow) const
The current number of entries in this matrix, stored on the calling process, in the row whose global ...
Definition: Ifpack2_ReorderFilter_def.hpp:181
virtual global_size_t getGlobalNumCols() const
Returns the number of global columns in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:133
virtual bool hasTransposeApply() const
Whether apply() can apply the transpose or conjugate transpose.
Definition: Ifpack2_ReorderFilter_def.hpp:433
virtual size_t getLocalNumEntries() const
Returns the local number of entries in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:168
virtual global_ordinal_type getIndexBase() const
Returns the index base for global indices for this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:154
virtual global_size_t getGlobalNumEntries() const
Returns the global number of entries in this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:161
virtual size_t getLocalMaxNumRowEntries() const
Returns the maximum number of entries across all rows/columns on this node.
Definition: Ifpack2_ReorderFilter_def.hpp:224
virtual bool isFillComplete() const
Returns true if fillComplete() has been called.
Definition: Ifpack2_ReorderFilter_def.hpp:252
virtual void permuteReorderedToOriginal(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &reorderedX, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &originalY) const
Permute multivector: reordered-to-original.
Definition: Ifpack2_ReorderFilter_def.hpp:484
virtual Teuchos::RCP< const Tpetra::RowGraph< local_ordinal_type, global_ordinal_type, node_type > > getGraph() const
Returns the RowGraph associated with this matrix.
Definition: Ifpack2_ReorderFilter_def.hpp:119
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_ReorderFilter_def.hpp:361
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_ReorderFilter_def.hpp:368
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_ReorderFilter_def.hpp:292
virtual void permuteOriginalToReordered(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &originalX, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &reorderedY) const
Permute multivector: original-to-reordered.
Definition: Ifpack2_ReorderFilter_def.hpp:456
virtual ~ReorderFilter()
Destructor.
Definition: Ifpack2_ReorderFilter_def.hpp:55
virtual bool isLocallyIndexed() const
If matrix indices are in the local range, this function returns true. Otherwise, this function return...
Definition: Ifpack2_ReorderFilter_def.hpp:238
virtual local_ordinal_type getBlockSize() const
The number of degrees of freedom per mesh point.
Definition: Ifpack2_ReorderFilter_def.hpp:174