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 {
22 class ParameterList; // forward declaration
23}
24
25namespace Ifpack2 {
26
37 template<class MatrixType>
38 class Hiptmair :
39 virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
40 typename MatrixType::local_ordinal_type,
41 typename MatrixType::global_ordinal_type,
42 typename MatrixType::node_type>
43 {
44 public:
45 // \name Public typedefs
47
49 typedef typename MatrixType::scalar_type scalar_type;
50
52 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
53
55 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
56
58 typedef typename MatrixType::node_type node_type;
59
61 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
62
64 typedef Tpetra::RowMatrix<scalar_type,
68
69 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.");
70
76
78 // \name Constructors and Destructors
80
82 explicit Hiptmair (const Teuchos::RCP<const row_matrix_type>& A);
83
84
86 explicit Hiptmair (const Teuchos::RCP<const row_matrix_type>& A,
87 const Teuchos::RCP<const row_matrix_type>& PtAP,
88 const Teuchos::RCP<const row_matrix_type>& P,
89 const Teuchos::RCP<const row_matrix_type>& Pt=Teuchos::null);
90
92 virtual ~Hiptmair ();
93
95
97
107 void setParameters (const Teuchos::ParameterList& params);
108
109 bool supportsZeroStartingSolution() { return true; }
110
111 void setZeroStartingSolution (bool zeroStartingSolution) { ZeroStartingSolution_ = zeroStartingSolution; };
112
114 void initialize ();
115
117 inline bool isInitialized () const {
118 return IsInitialized_;
119 }
120
122 void compute ();
123
125 inline bool isComputed() const {
126 return IsComputed_;
127 }
128
130
132
134 void
135 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
136 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
137 Teuchos::ETransp mode = Teuchos::NO_TRANS,
138 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
139 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
140
141 void
142 applyHiptmairSmoother(const Tpetra::MultiVector<typename MatrixType::scalar_type,
143 typename MatrixType::local_ordinal_type,
144 typename MatrixType::global_ordinal_type,
145 typename MatrixType::node_type>& X,
146 Tpetra::MultiVector<typename MatrixType::scalar_type,
147 typename MatrixType::local_ordinal_type,
148 typename MatrixType::global_ordinal_type,
149 typename MatrixType::node_type>& Y) const;
150
152 void updateCachedMultiVectors(const Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> >& map1,
153 const Teuchos::RCP<const Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type>>& map2,
154 size_t numVecs) const;
155
157 Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > getDomainMap() const;
158
160 Teuchos::RCP<const Tpetra::Map<local_ordinal_type,global_ordinal_type,node_type> > getRangeMap() const;
161
163 bool hasTransposeApply() const;
164
166
168
170 Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
171
173 Teuchos::RCP<const Tpetra::RowMatrix<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > getMatrix() const;
174
176 int getNumInitialize() const;
177
179 int getNumCompute() const;
180
182 int getNumApply() const;
183
185 double getInitializeTime() const;
186
188 double getComputeTime() const;
189
191 double getApplyTime() const;
192
194 Teuchos::RCP<Ifpack2::Preconditioner<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> > getPrec1();
195
197 Teuchos::RCP<Ifpack2::Preconditioner<typename MatrixType::scalar_type,typename MatrixType::local_ordinal_type,typename MatrixType::global_ordinal_type,typename MatrixType::node_type> > getPrec2();
198
200
201
203 std::string description() const;
204
206 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
207
209
210 private:
211 typedef Teuchos::ScalarTraits<scalar_type> STS;
212 typedef Teuchos::ScalarTraits<magnitude_type> STM;
213
215 Hiptmair (const Hiptmair<MatrixType>& RHS);
216
218 Hiptmair<MatrixType>& operator= (const Hiptmair<MatrixType>& RHS);
219
221 // A - matrix in primary space
222 // PtAP - matrix in auxiliary space
223 // P - prolongator matrix
224 Teuchos::RCP<const row_matrix_type> A_, PtAP_, P_, Pt_;
225
227 std::string precType1_, precType2_, preOrPost_;
228
230 bool ZeroStartingSolution_;
231
233 bool ImplicitTranspose_;
234
236 Teuchos::ParameterList precList1_, precList2_;
237
239 bool IsInitialized_;
241 bool IsComputed_;
243 int NumInitialize_;
245 int NumCompute_;
247 mutable int NumApply_;
249 double InitializeTime_;
251 double ComputeTime_;
253 mutable double ApplyTime_;
255 Teuchos::RCP<prec_type> ifpack2_prec1_, ifpack2_prec2_;
257 mutable Teuchos::RCP<Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > cachedResidual1_;
258 mutable Teuchos::RCP<Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > cachedSolution1_;
259 mutable Teuchos::RCP<Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > cachedResidual2_;
260 mutable Teuchos::RCP<Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> > cachedSolution2_;
261 };
262
263} // namespace Ifpack2
264
265#endif // IFPACK2_HIPTMAIR_DECL_HPP
Wrapper for Hiptmair smoothers.
Definition Ifpack2_Hiptmair_decl.hpp:43
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:224
void initialize()
Do any initialization that depends on the input matrix's structure.
Definition Ifpack2_Hiptmair_def.hpp:236
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:322
void setZeroStartingSolution(bool zeroStartingSolution)
Set this preconditioner's parameters.
Definition Ifpack2_Hiptmair_decl.hpp:111
int getNumCompute() const
Returns the number of calls to Compute().
Definition Ifpack2_Hiptmair_def.hpp:194
void compute()
Do any initialization that depends on the input matrix's values.
Definition Ifpack2_Hiptmair_def.hpp:279
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:597
bool isComputed() const
Return true if compute() completed successfully, else false.
Definition Ifpack2_Hiptmair_decl.hpp:125
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition Ifpack2_Hiptmair_decl.hpp:52
std::string description() const
Return a simple one-line description of this object.
Definition Ifpack2_Hiptmair_def.hpp:562
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition Ifpack2_Hiptmair_decl.hpp:61
double getApplyTime() const
Returns the time spent in apply().
Definition Ifpack2_Hiptmair_def.hpp:218
bool isInitialized() const
Return true if initialize() completed successfully, else false.
Definition Ifpack2_Hiptmair_decl.hpp:117
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:169
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:396
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition Ifpack2_Hiptmair_decl.hpp:49
Hiptmair(const Teuchos::RCP< const row_matrix_type > &A)
Constructor that takes 1 Tpetra matrix (assumes we'll get the rest off the parameter list).
Definition Ifpack2_Hiptmair_def.hpp:57
int getNumInitialize() const
Returns the number of calls to Initialize().
Definition Ifpack2_Hiptmair_def.hpp:188
int getNumApply() const
Returns the number of calls to apply().
Definition Ifpack2_Hiptmair_def.hpp:200
virtual ~Hiptmair()
Destructor.
Definition Ifpack2_Hiptmair_def.hpp:81
void setParameters(const Teuchos::ParameterList &params)
Set the preconditioner's parameters.
Definition Ifpack2_Hiptmair_def.hpp:84
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:67
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:230
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition Ifpack2_Hiptmair_decl.hpp:58
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:150
double getInitializeTime() const
Returns the time spent in Initialize().
Definition Ifpack2_Hiptmair_def.hpp:206
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Returns the operator's communicator.
Definition Ifpack2_Hiptmair_def.hpp:139
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition Ifpack2_Hiptmair_decl.hpp:55
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:157
double getComputeTime() const
Returns the time spent in Compute().
Definition Ifpack2_Hiptmair_def.hpp:212
bool hasTransposeApply() const
Whether this object's apply() method can apply the transpose (or conjugate transpose,...
Definition Ifpack2_Hiptmair_def.hpp:180
Interface for all Ifpack2 preconditioners.
Definition Ifpack2_Preconditioner.hpp:75
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41