Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_IdentitySolver_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_IDENTITY_SOLVER_DECL_HPP
11 #define IFPACK2_IDENTITY_SOLVER_DECL_HPP
12 
15 #include "Tpetra_Export_fwd.hpp"
16 #include <type_traits>
17 
18 namespace Ifpack2 {
19 
26 template<class MatrixType>
28  virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
29  typename MatrixType::local_ordinal_type,
30  typename MatrixType::global_ordinal_type,
31  typename MatrixType::node_type>,
32  virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
33  typename MatrixType::local_ordinal_type,
34  typename MatrixType::global_ordinal_type,
35  typename MatrixType::node_type> >
36 {
37 public:
39  typedef typename MatrixType::scalar_type scalar_type;
41  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
43  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
45  typedef typename MatrixType::node_type node_type;
46 
50  typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
52  typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
54 
55  static_assert(std::is_same<MatrixType, row_matrix_type>::value, "Ifpack2::IdentitySolver: 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 
59 
61  virtual ~IdentitySolver();
62 
66  void setParameters (const Teuchos::ParameterList& params);
67 
69  void initialize();
70 
72  inline bool isInitialized() const {
73  return(isInitialized_);
74  }
75 
77  void compute();
78 
80  inline bool isComputed() const {
81  return(isComputed_);
82  }
83 
85 
86 
93  void
94  apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
95  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
99 
102 
105 
110  void
111  applyMat (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
112  Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
113  Teuchos::ETransp mode = Teuchos::NO_TRANS) const;
114 
117 
120  return matrix_;
121  }
122 
124  double getComputeFlops() const;
125 
127  double getApplyFlops() const;
128 
130  int getNumInitialize() const;
131 
133  int getNumCompute() const;
134 
136  int getNumApply() const;
137 
139  double getInitializeTime() const;
140 
142  double getComputeTime() const;
143 
145  double getApplyTime() const;
146 
148 
150 
152  std::string description() const;
153 
156 
161  virtual void setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
162 
164 
165 private:
167  typedef Tpetra::Export<local_ordinal_type, global_ordinal_type, node_type> export_type;
168 
170 
179 
180  bool isInitialized_;
181  bool isComputed_;
182 
183  mutable int numInitialize_;
184  mutable int numCompute_;
185  mutable int numApply_;
186 
187  double initializeTime_;
188  double computeTime_;
189  double applyTime_;
190 };
191 
192 }//namespace Ifpack2
193 
194 #endif
int getNumApply() const
Return the number of calls to apply().
Definition: Ifpack2_IdentitySolver_def.hpp:144
MatrixType::node_type node_type
Node type of the input matrix.
Definition: Ifpack2_IdentitySolver_decl.hpp:45
double getComputeTime() const
Return the time spent in compute().
Definition: Ifpack2_IdentitySolver_def.hpp:154
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:60
int getNumCompute() const
Return the number of calls to compute().
Definition: Ifpack2_IdentitySolver_def.hpp:139
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Return the communicator associated with this matrix operator.
void applyMat(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) const
Apply the original input matrix.
virtual ~IdentitySolver()
Destructor.
Definition: Ifpack2_IdentitySolver_def.hpp:36
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
Apply the preconditioner to X, and put the result in Y.
Definition: Ifpack2_IdentitySolver_def.hpp:94
Teuchos::RCP< const map_type > getRangeMap() const
Return the Tpetra::Map object associated with the range of this operator.
Definition: Ifpack2_IdentitySolver_def.hpp:224
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
Type of the absolute value (magnitude) of a scalar_type value.
Definition: Ifpack2_IdentitySolver_decl.hpp:48
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
Specialization of Tpetra::Map used by this class.
Definition: Ifpack2_IdentitySolver_decl.hpp:50
bool isInitialized() const
Return true if the preconditioner has been successfully initialized.
Definition: Ifpack2_IdentitySolver_decl.hpp:72
void setParameters(const Teuchos::ParameterList &params)
Set this object&#39;s parameters.
Definition: Ifpack2_IdentitySolver_def.hpp:41
&quot;Identity&quot; preconditioner.
Definition: Ifpack2_IdentitySolver_decl.hpp:27
void initialize()
Initialize.
Definition: Ifpack2_IdentitySolver_def.hpp:46
bool isComputed() const
Return true if compute() has been called.
Definition: Ifpack2_IdentitySolver_decl.hpp:80
Teuchos::RCP< const map_type > getDomainMap() const
Return the Tpetra::Map object associated with the domain of this operator.
Definition: Ifpack2_IdentitySolver_def.hpp:214
IdentitySolver(const Teuchos::RCP< const row_matrix_type > &A)
Constructor: Takes the matrix to precondition.
Definition: Ifpack2_IdentitySolver_def.hpp:22
MatrixType::local_ordinal_type local_ordinal_type
Type of the local indices of the input matrix.
Definition: Ifpack2_IdentitySolver_decl.hpp:41
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:74
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set this preconditioner&#39;s matrix.
Definition: Ifpack2_IdentitySolver_def.hpp:235
double getComputeFlops() const
Return the number of flops in the computation phase.
Declaration of interface for preconditioners that can change their matrix after construction.
std::string description() const
Return a simple one-line description of this object.
Definition: Ifpack2_IdentitySolver_def.hpp:164
static const EVerbosityLevel verbLevel_default
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
Definition: Ifpack2_IdentitySolver_def.hpp:194
void compute()
Compute the preconditioner.
Definition: Ifpack2_IdentitySolver_def.hpp:77
Teuchos::RCP< const row_matrix_type > getMatrix() const
Return a reference to the matrix to be preconditioned.
Definition: Ifpack2_IdentitySolver_decl.hpp:119
int getNumInitialize() const
Return the number of calls to initialize().
Definition: Ifpack2_IdentitySolver_def.hpp:134
MatrixType::global_ordinal_type global_ordinal_type
Type of the global indices of the input matrix.
Definition: Ifpack2_IdentitySolver_decl.hpp:43
double getInitializeTime() const
Return the time spent in initialize().
Definition: Ifpack2_IdentitySolver_def.hpp:149
MatrixType::scalar_type scalar_type
Type of the entries of the input matrix.
Definition: Ifpack2_IdentitySolver_decl.hpp:39
double getApplyTime() const
Return the time spent in apply().
Definition: Ifpack2_IdentitySolver_def.hpp:159
double getApplyFlops() const
Return the number of flops for the application of the preconditioner.
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
Specialization of Tpetra::RowMatrix used by this class.
Definition: Ifpack2_IdentitySolver_decl.hpp:53