Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_Hiptmair_decl.hpp
Go to the documentation of this file.
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
13
14#ifndef IFPACK2_HIPTMAIR_DECL_HPP
15#define IFPACK2_HIPTMAIR_DECL_HPP
16
18#include "Tpetra_Map_fwd.hpp"
19#include <type_traits>
20
21namespace Teuchos {
22class ParameterList; // forward declaration
23}
24
25namespace Ifpack2 {
26
37template <class MatrixType>
38class Hiptmair : virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
39 typename MatrixType::local_ordinal_type,
40 typename MatrixType::global_ordinal_type,
41 typename MatrixType::node_type> {
42 public:
43 // \name Public typedefs
45
47 typedef typename MatrixType::scalar_type scalar_type;
48
50 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
51
53 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
54
56 typedef typename MatrixType::node_type node_type;
57
59 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
60
62 typedef Tpetra::RowMatrix<scalar_type,
67
68 static_assert(std::is_same<MatrixType, row_matrix_type>::value, "Ifpack2::Hiptmair: 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.");
69
76
78 // \name Constructors and Destructors
80
82 explicit Hiptmair(const Teuchos::RCP<const row_matrix_type>& A);
83
85 explicit Hiptmair(const Teuchos::RCP<const row_matrix_type>& A,
86 const Teuchos::RCP<const row_matrix_type>& PtAP,
87 const Teuchos::RCP<const row_matrix_type>& P,
88 const Teuchos::RCP<const row_matrix_type>& Pt = Teuchos::null);
89
91 virtual ~Hiptmair();
92
94
96
106 void setParameters(const Teuchos::ParameterList& params);
107
108 bool supportsZeroStartingSolution() { return true; }
109
110 void setZeroStartingSolution(bool zeroStartingSolution) { ZeroStartingSolution_ = zeroStartingSolution; };
111
113 void initialize();
114
116 inline bool isInitialized() const {
117 return IsInitialized_;
118 }
119
121 void compute();
122
124 inline bool isComputed() const {
125 return IsComputed_;
126 }
127
129
131
133 void
134 apply(const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
135 Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
136 Teuchos::ETransp mode = Teuchos::NO_TRANS,
137 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
138 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
139
140 void
141 applyHiptmairSmoother(const Tpetra::MultiVector<typename MatrixType::scalar_type,
142 typename MatrixType::local_ordinal_type,
143 typename MatrixType::global_ordinal_type,
144 typename MatrixType::node_type>& X,
145 Tpetra::MultiVector<typename MatrixType::scalar_type,
146 typename MatrixType::local_ordinal_type,
147 typename MatrixType::global_ordinal_type,
148 typename MatrixType::node_type>& Y) const;
149
151 void updateCachedMultiVectors(const Teuchos::RCP<const Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type>>& map1,
152 const Teuchos::RCP<const Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type>>& map2,
153 size_t numVecs) const;
154
156 Teuchos::RCP<const Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type>> getDomainMap() const;
157
159 Teuchos::RCP<const Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type>> getRangeMap() const;
160
162 bool hasTransposeApply() const;
163
165
167
169 Teuchos::RCP<const Teuchos::Comm<int>> getComm() const;
170
172 Teuchos::RCP<const Tpetra::RowMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type>> getMatrix() const;
173
175 int getNumInitialize() const;
176
178 int getNumCompute() const;
179
181 int getNumApply() const;
182
184 double getInitializeTime() const;
185
187 double getComputeTime() const;
188
190 double getApplyTime() const;
191
193 Teuchos::RCP<Ifpack2::Preconditioner<typename MatrixType::scalar_type, typename MatrixType::local_ordinal_type, typename MatrixType::global_ordinal_type, typename MatrixType::node_type>> getPrec1();
194
196 Teuchos::RCP<Ifpack2::Preconditioner<typename MatrixType::scalar_type, typename MatrixType::local_ordinal_type, typename MatrixType::global_ordinal_type, typename MatrixType::node_type>> getPrec2();
197
199
200
202 std::string description() const;
203
205 void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const;
206
208
209 private:
210 typedef Teuchos::ScalarTraits<scalar_type> STS;
211 typedef Teuchos::ScalarTraits<magnitude_type> STM;
212
214 Hiptmair(const Hiptmair<MatrixType>& RHS);
215
217 Hiptmair<MatrixType>& operator=(const Hiptmair<MatrixType>& RHS);
218
220 // A - matrix in primary space
221 // PtAP - matrix in auxiliary space
222 // P - prolongator matrix
223 Teuchos::RCP<const row_matrix_type> A_, PtAP_, P_, Pt_;
224
226 std::string precType1_, precType2_, preOrPost_;
227
229 bool ZeroStartingSolution_;
230
232 bool ImplicitTranspose_;
233
235 Teuchos::ParameterList precList1_, precList2_;
236
238 bool IsInitialized_;
240 bool IsComputed_;
242 int NumInitialize_;
244 int NumCompute_;
246 mutable int NumApply_;
248 double InitializeTime_;
250 double ComputeTime_;
252 mutable double ApplyTime_;
254 Teuchos::RCP<prec_type> ifpack2_prec1_, ifpack2_prec2_;
256 mutable Teuchos::RCP<Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>> cachedResidual1_;
257 mutable Teuchos::RCP<Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>> cachedSolution1_;
258 mutable Teuchos::RCP<Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>> cachedResidual2_;
259 mutable Teuchos::RCP<Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>> cachedSolution2_;
260};
261
262} // namespace Ifpack2
263
264#endif // IFPACK2_HIPTMAIR_DECL_HPP
Wrapper for Hiptmair smoothers.
Definition Ifpack2_Hiptmair_decl.hpp:41
Teuchos::RCP< Ifpack2::Preconditioner< typename MatrixType::scalar_type, typename MatrixType::local_ordinal_type, typename MatrixType::global_ordinal_type, typename MatrixType::node_type > > getPrec1()
Returns prec 1.
Definition Ifpack2_Hiptmair_def.hpp:209
void initialize()
Do any initialization that depends on the input matrix's structure.
Definition Ifpack2_Hiptmair_def.hpp:219
Ifpack2::Preconditioner< scalar_type, local_ordinal_type, global_ordinal_type, node_type > prec_type
Type of the Ifpack2::Preconditioner specialization from which this class inherits.
Definition Ifpack2_Hiptmair_decl.hpp:75
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, putting the result in Y.
Definition Ifpack2_Hiptmair_def.hpp:303
void setZeroStartingSolution(bool zeroStartingSolution)
Set this preconditioner's parameters.
Definition Ifpack2_Hiptmair_decl.hpp:110
int getNumCompute() const
Returns the number of calls to Compute().
Definition Ifpack2_Hiptmair_def.hpp:184
void compute()
Do any initialization that depends on the input matrix's values.
Definition Ifpack2_Hiptmair_def.hpp:260
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_Hiptmair_def.hpp:562
bool isComputed() const
Return true if compute() completed successfully, else false.
Definition Ifpack2_Hiptmair_decl.hpp:124
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition Ifpack2_Hiptmair_decl.hpp:50
std::string description() const
Return a simple one-line description of this object.
Definition Ifpack2_Hiptmair_def.hpp:530
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition Ifpack2_Hiptmair_decl.hpp:59
double getApplyTime() const
Returns the time spent in apply().
Definition Ifpack2_Hiptmair_def.hpp:204
bool isInitialized() const
Return true if initialize() completed successfully, else false.
Definition Ifpack2_Hiptmair_decl.hpp:116
Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getRangeMap() const
Tpetra::Map representing the range of this operator.
Definition Ifpack2_Hiptmair_def.hpp:162
void updateCachedMultiVectors(const Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > &map1, const Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > &map2, size_t numVecs) const
A service routine for updating the cached MultiVectors.
Definition Ifpack2_Hiptmair_def.hpp:375
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition Ifpack2_Hiptmair_decl.hpp:47
int getNumInitialize() const
Returns the number of calls to Initialize().
Definition Ifpack2_Hiptmair_def.hpp:179
int getNumApply() const
Returns the number of calls to apply().
Definition Ifpack2_Hiptmair_def.hpp:189
virtual ~Hiptmair()
Destructor.
Definition Ifpack2_Hiptmair_def.hpp:79
void setParameters(const Teuchos::ParameterList &params)
Set the preconditioner's parameters.
Definition Ifpack2_Hiptmair_def.hpp:82
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
Type of the Tpetra::RowMatrix specialization that this class uses.
Definition Ifpack2_Hiptmair_decl.hpp:66
Teuchos::RCP< Ifpack2::Preconditioner< typename MatrixType::scalar_type, typename MatrixType::local_ordinal_type, typename MatrixType::global_ordinal_type, typename MatrixType::node_type > > getPrec2()
Returns prec 2.
Definition Ifpack2_Hiptmair_def.hpp:214
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition Ifpack2_Hiptmair_decl.hpp:56
Teuchos::RCP< const Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > > getMatrix() const
Returns a reference to the matrix to be preconditioned.
Definition Ifpack2_Hiptmair_def.hpp:145
double getInitializeTime() const
Returns the time spent in Initialize().
Definition Ifpack2_Hiptmair_def.hpp:194
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Returns the operator's communicator.
Definition Ifpack2_Hiptmair_def.hpp:134
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition Ifpack2_Hiptmair_decl.hpp:53
Teuchos::RCP< const Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > > getDomainMap() const
Tpetra::Map representing the domain of this operator.
Definition Ifpack2_Hiptmair_def.hpp:151
double getComputeTime() const
Returns the time spent in Compute().
Definition Ifpack2_Hiptmair_def.hpp:199
bool hasTransposeApply() const
Whether this object's apply() method can apply the transpose (or conjugate transpose,...
Definition Ifpack2_Hiptmair_def.hpp:172
Interface for all Ifpack2 preconditioners.
Definition Ifpack2_Preconditioner.hpp:74
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:40