Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_DatabaseSchwarz_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 
12 
13 #ifndef IFPACK2_DATABASESCHWARZ_DECL_HPP
14 #define IFPACK2_DATABASESCHWARZ_DECL_HPP
15 
18 
19 // We only need the declaration here, and only for the method
20 // getCrsMatrix. I would very much prefer that this method not exist.
21 // Furthermore, it is both unsafe (MatrixType need not be CrsMatrix)
22 // and completely redundant (just call getMatrix() and do the
23 // dynamic_cast yourself).
25 #include "Tpetra_CrsMatrix_decl.hpp"
26 
27 #include <type_traits>
28 
29 namespace Ifpack2 {
30 
62 template <class MatrixType>
63 class DatabaseSchwarz : virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
64  typename MatrixType::local_ordinal_type,
65  typename MatrixType::global_ordinal_type,
66  typename MatrixType::node_type>,
67  virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
68  typename MatrixType::local_ordinal_type,
69  typename MatrixType::global_ordinal_type,
70  typename MatrixType::node_type> > {
71  public:
73 
74 
76  typedef MatrixType matrix_type;
77 
79  typedef typename MatrixType::scalar_type scalar_type;
80 
82  typedef typename MatrixType::local_ordinal_type local_ordinal_type;
83 
85  typedef typename MatrixType::global_ordinal_type global_ordinal_type;
86 
88  typedef typename MatrixType::node_type::device_type device_type;
89 
91  typedef typename MatrixType::node_type node_type;
92 
95 
100  typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
103 
104  static_assert(std::is_same<MatrixType, row_matrix_type>::value,
105  "Ifpack2::DatabaseSchwarz: MatrixType must be a Tpetra::RowMatrix "
106  "specialization. Don't use Tpetra::CrsMatrix here.");
107 
109  typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
110 
116  typedef Tpetra::Vector<scalar_type, local_ordinal_type,
119 
121  // \name Constructors and destructors
123 
133 
145  Teuchos::ParameterList& params);
146 
148  virtual ~DatabaseSchwarz();
149 
151 
153 
155  void setParameters(const Teuchos::ParameterList& params);
156 
157  bool supportsZeroStartingSolution() { return true; }
158 
159  void setZeroStartingSolution(bool zeroStartingSolution);
160 
167  void initialize();
168 
171  inline bool isInitialized() const {
172  return IsInitialized_;
173  }
174 
177  void compute();
178 
180  inline bool isComputed() const {
181  return IsComputed_;
182  }
183 
185 
187 
189  virtual void
191 
193 
195 
198  void
199  apply(const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
200  Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
204 
207 
210 
212  bool hasTransposeApply() const;
213 
215  void
216  applyMat(const Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& X,
217  Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& Y,
218  Teuchos::ETransp mode = Teuchos::NO_TRANS) const;
219 
221 
223 
226 
229 
232 
238  getCrsMatrix() const;
239 
241  double getComputeFlops() const;
242 
244  double getApplyFlops() const;
245 
247  int getNumInitialize() const;
248 
250  int getNumCompute() const;
251 
253  int getNumApply() const;
254 
256  double getInitializeTime() const;
257 
259  double getComputeTime() const;
260 
262  double getApplyTime() const;
263 
265  size_t getNodeSmootherComplexity() const;
266 
268 
270 
272  std::string description() const;
273 
276 
278 
279  private:
281  void setParametersImpl(Teuchos::ParameterList& params);
282 
285 
287  typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
288 
291 
294 
296 
297 
299  bool IsInitialized_;
301  bool IsComputed_;
303  int NumInitialize_;
305  int NumCompute_;
310  mutable int NumApply_;
312  double InitializeTime_;
314  double ComputeTime_;
319  mutable double ApplyTime_;
321  double ComputeFlops_;
326  mutable double ApplyFlops_;
327 
329  local_ordinal_type PatchSize_;
330 
332  mutable size_t NumPatches_;
333 
335  double PatchTolerance_;
336 
338  bool SkipDatabase_;
339 
341  bool Verbose_;
342 
344  mutable std::vector<std::vector<typename row_matrix_type::local_ordinal_type> > PatchIndices_;
345 
347  mutable size_t DatabaseSize_;
348 
350  mutable std::vector<Teuchos::RCP<typename Teuchos::SerialDenseMatrix<typename row_matrix_type::local_ordinal_type, typename row_matrix_type::scalar_type> > > DatabaseMatrices_;
351 
353  std::vector<int> DatabaseIndices_;
354 
356  std::vector<magnitude_type> Weights_;
357 
359  mutable Teuchos::Array<int> ipiv_;
360 
362 }; // class DatabaseSchwarz
363 
364 } // namespace Ifpack2
365 
366 #endif // IFPACK2_DATABASESCHWARZ_DECL_HPP
Teuchos::RCP< const row_matrix_type > getMatrix() const
The matrix for which this is a preconditioner.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:142
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:82
Mix-in interface for preconditioners that can change their matrix after construction.
Definition: Ifpack2_Details_CanChangeMatrix.hpp:60
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, returning the result in Y. Y = alpha*Op(A)*X + beta*Y.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:244
Teuchos::RCP< const row_matrix_type > A_
The matrix for which this is a preconditioner.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:231
Teuchos::RCP< const map_type > getRangeMap() const
The Tpetra::Map representing the range of this operator.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:175
MatrixType::node_type::device_type device_type
The Kokkos::Device specialization used by the input MatrixType.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:88
double getApplyTime() const
The total time spent in all calls to apply().
Definition: Ifpack2_DatabaseSchwarz_def.hpp:216
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:231
int getNumApply() const
The total number of successful calls to apply().
Definition: Ifpack2_DatabaseSchwarz_def.hpp:201
void initialize()
Initialize the preconditioner.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:358
bool hasTransposeApply() const
Whether it&#39;s possible to apply the transpose of this operator.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:186
double getInitializeTime() const
The total time spent in all calls to initialize().
Definition: Ifpack2_DatabaseSchwarz_def.hpp:206
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to a Teuchos::FancyOStream.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:589
void setParameters(const Teuchos::ParameterList &params)
Set (or reset) parameters.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:84
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the matrix is distributed.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:130
Teuchos::RCP< const map_type > getDomainMap() const
The Tpetra::Map representing the domain of this operator.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:162
virtual ~DatabaseSchwarz()
Destructor.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:70
double getComputeTime() const
The total time spent in all calls to compute().
Definition: Ifpack2_DatabaseSchwarz_def.hpp:211
Tpetra::RowMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > row_matrix_type
The Tpetra::RowMatrix specialization matching MatrixType.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:102
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:94
double getApplyFlops() const
The total number of floating-point operations taken by all calls to apply().
Definition: Ifpack2_DatabaseSchwarz_def.hpp:226
void compute()
(Re)compute the left scaling, and (if applicable) estimate max and min eigenvalues of D_inv * A...
Definition: Ifpack2_DatabaseSchwarz_def.hpp:372
DatabaseSchwarz(const Teuchos::RCP< const row_matrix_type > &A)
Constructor.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:27
Teuchos::RCP< const Tpetra::CrsMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > > getCrsMatrix() const
Attempt to return the matrix A as a Tpetra::CrsMatrix.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:152
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:91
Tpetra::Vector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > vector_type
The Tpetra::Vector specialization matching MatrixType.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:118
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Change the matrix to be preconditioned.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:74
void setZeroStartingSolution(bool zeroStartingSolution)
Set this preconditioner&#39;s parameters.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:124
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:74
double getComputeFlops() const
The total number of floating-point operations taken by all calls to compute().
Definition: Ifpack2_DatabaseSchwarz_def.hpp:221
std::string description() const
A simple one-line description of this object.
Definition: Ifpack2_DatabaseSchwarz_def.hpp:560
Declaration of interface for preconditioners that can change their matrix after construction.
static const EVerbosityLevel verbLevel_default
int getNumInitialize() const
The total number of successful calls to initialize().
Definition: Ifpack2_DatabaseSchwarz_def.hpp:191
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
The Tpetra::Map specialization matching MatrixType.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:106
Overlapping Schwarz where redundant patches are not stored explicitly.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:63
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
Compute Y = Op(A)*X, where Op(A) is either A, , or .
Definition: Ifpack2_DatabaseSchwarz_def.hpp:340
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:79
bool isComputed() const
Whether compute() has been called at least once.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:180
MatrixType matrix_type
The template parameter of this class.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:76
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:85
int getNumCompute() const
The total number of successful calls to compute().
Definition: Ifpack2_DatabaseSchwarz_def.hpp:196
bool isInitialized() const
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:171