Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
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
18namespace Ifpack2 {
19
26template <class MatrixType>
27class IdentitySolver : virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
28 typename MatrixType::local_ordinal_type,
29 typename MatrixType::global_ordinal_type,
30 typename MatrixType::node_type>,
31 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
32 typename MatrixType::local_ordinal_type,
33 typename MatrixType::global_ordinal_type,
34 typename MatrixType::node_type> > {
35 public:
37 typedef typename MatrixType::scalar_type scalar_type;
39 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
41 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
43 typedef typename MatrixType::node_type node_type;
44
46 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
48 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
50 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
53
54 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.");
55
57 IdentitySolver(const Teuchos::RCP<const row_matrix_type>& A);
58
60 virtual ~IdentitySolver();
61
65 void setParameters(const Teuchos::ParameterList& params);
66
68 void initialize();
69
71 inline bool isInitialized() const {
72 return (isInitialized_);
73 }
74
76 void compute();
77
79 inline bool isComputed() const {
80 return (isComputed_);
81 }
82
84
85
92 void
93 apply(const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
94 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
95 Teuchos::ETransp mode = Teuchos::NO_TRANS,
96 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
97 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
98
100 Teuchos::RCP<const map_type> getDomainMap() const;
101
103 Teuchos::RCP<const map_type> getRangeMap() const;
104
109 void
110 applyMat(const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
111 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
112 Teuchos::ETransp mode = Teuchos::NO_TRANS) const;
113
115 Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
116
118 Teuchos::RCP<const row_matrix_type> getMatrix() const {
119 return matrix_;
120 }
121
123 double getComputeFlops() const;
124
126 double getApplyFlops() const;
127
129 int getNumInitialize() const;
130
132 int getNumCompute() const;
133
135 int getNumApply() const;
136
138 double getInitializeTime() const;
139
141 double getComputeTime() const;
142
144 double getApplyTime() const;
145
147
149
151 std::string description() const;
152
154 void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const;
155
160 virtual void setMatrix(const Teuchos::RCP<const row_matrix_type>& A);
161
163
164 private:
166 typedef Tpetra::Export<local_ordinal_type, global_ordinal_type, node_type> export_type;
167
168 Teuchos::RCP<const row_matrix_type> matrix_;
169
177 Teuchos::RCP<const export_type> export_;
178
179 bool isInitialized_;
180 bool isComputed_;
181
182 mutable int numInitialize_;
183 mutable int numCompute_;
184 mutable int numApply_;
185
186 double initializeTime_;
187 double computeTime_;
188 double applyTime_;
189};
190
191} // namespace Ifpack2
192
193#endif
Declaration of interface for preconditioners that can change their matrix after construction.
Mix-in interface for preconditioners that can change their matrix after construction.
Definition Ifpack2_Details_CanChangeMatrix.hpp:60
"Identity" preconditioner.
Definition Ifpack2_IdentitySolver_decl.hpp:34
void initialize()
Initialize.
Definition Ifpack2_IdentitySolver_def.hpp:43
int getNumInitialize() const
Return the number of calls to initialize().
Definition Ifpack2_IdentitySolver_def.hpp:128
Teuchos::RCP< const row_matrix_type > getMatrix() const
Return a reference to the matrix to be preconditioned.
Definition Ifpack2_IdentitySolver_decl.hpp:118
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Return the communicator associated with this matrix operator.
Teuchos::RCP< const map_type > getDomainMap() const
Return the Tpetra::Map object associated with the domain of this operator.
Definition Ifpack2_IdentitySolver_def.hpp:204
double getApplyFlops() const
Return the number of flops for the application of the preconditioner.
MatrixType::node_type node_type
Node type of the input matrix.
Definition Ifpack2_IdentitySolver_decl.hpp:43
void setParameters(const Teuchos::ParameterList &params)
Set this object's parameters.
Definition Ifpack2_IdentitySolver_def.hpp:39
double getInitializeTime() const
Return the time spent in initialize().
Definition Ifpack2_IdentitySolver_def.hpp:143
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:90
int getNumCompute() const
Return the number of calls to compute().
Definition Ifpack2_IdentitySolver_def.hpp:133
double getComputeFlops() const
Return the number of flops in the computation phase.
MatrixType::local_ordinal_type local_ordinal_type
Type of the local indices of the input matrix.
Definition Ifpack2_IdentitySolver_decl.hpp:39
bool isInitialized() const
Return true if the preconditioner has been successfully initialized.
Definition Ifpack2_IdentitySolver_decl.hpp:71
double getApplyTime() const
Return the time spent in apply().
Definition Ifpack2_IdentitySolver_def.hpp:153
std::string description() const
Return a simple one-line description of this object.
Definition Ifpack2_IdentitySolver_def.hpp:158
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set this preconditioner's matrix.
Definition Ifpack2_IdentitySolver_def.hpp:225
Teuchos::RCP< const map_type > getRangeMap() const
Return the Tpetra::Map object associated with the range of this operator.
Definition Ifpack2_IdentitySolver_def.hpp:214
double getComputeTime() const
Return the time spent in compute().
Definition Ifpack2_IdentitySolver_def.hpp:148
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:186
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.
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:48
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
Type of the absolute value (magnitude) of a scalar_type value.
Definition Ifpack2_IdentitySolver_decl.hpp:46
MatrixType::global_ordinal_type global_ordinal_type
Type of the global indices of the input matrix.
Definition Ifpack2_IdentitySolver_decl.hpp:41
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:52
MatrixType::scalar_type scalar_type
Type of the entries of the input matrix.
Definition Ifpack2_IdentitySolver_decl.hpp:37
int getNumApply() const
Return the number of calls to apply().
Definition Ifpack2_IdentitySolver_def.hpp:138
virtual ~IdentitySolver()
Destructor.
Definition Ifpack2_IdentitySolver_def.hpp:35
void compute()
Compute the preconditioner.
Definition Ifpack2_IdentitySolver_def.hpp:73
bool isComputed() const
Return true if compute() has been called.
Definition Ifpack2_IdentitySolver_decl.hpp:79
Interface for all Ifpack2 preconditioners.
Definition Ifpack2_Preconditioner.hpp:74
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40