Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_DatabaseSchwarz_decl.hpp
Go to the documentation of this file.
1/*
2@HEADER
3// ***********************************************************************
4//
5// Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
6// Copyright (2009) Sandia Corporation
7//
8// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9// license for use of this work by or on behalf of the U.S. Government.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39//
40// ***********************************************************************
41//@HEADER
42*/
43
46
47#ifndef IFPACK2_DATABASESCHWARZ_DECL_HPP
48#define IFPACK2_DATABASESCHWARZ_DECL_HPP
49
52
53// We only need the declaration here, and only for the method
54// getCrsMatrix. I would very much prefer that this method not exist.
55// Furthermore, it is both unsafe (MatrixType need not be CrsMatrix)
56// and completely redundant (just call getMatrix() and do the
57// dynamic_cast yourself).
58#include "Teuchos_SerialDenseMatrix.hpp"
59#include "Tpetra_CrsMatrix_decl.hpp"
60
61#include <type_traits>
62
63namespace Ifpack2 {
64
96template<class MatrixType>
98 virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
99 typename MatrixType::local_ordinal_type,
100 typename MatrixType::global_ordinal_type,
101 typename MatrixType::node_type>,
102 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
103 typename MatrixType::local_ordinal_type,
104 typename MatrixType::global_ordinal_type,
105 typename MatrixType::node_type> >
106{
107public:
109
110
112 typedef MatrixType matrix_type;
113
115 typedef typename MatrixType::scalar_type scalar_type;
116
118 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
119
121 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
122
124 typedef typename MatrixType::node_type::device_type device_type;
125
127 typedef typename MatrixType::node_type node_type;
128
130 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
131
136 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
138
139 static_assert (std::is_same<MatrixType, row_matrix_type>::value,
140 "Ifpack2::DatabaseSchwarz: MatrixType must be a Tpetra::RowMatrix "
141 "specialization. Don't use Tpetra::CrsMatrix here.");
142
144 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
145
151 typedef Tpetra::Vector<scalar_type, local_ordinal_type,
153
155 // \name Constructors and destructors
157
166 explicit DatabaseSchwarz(const Teuchos::RCP<const row_matrix_type>& A);
167
178 DatabaseSchwarz (const Teuchos::RCP<const row_matrix_type>& A,
179 Teuchos::ParameterList& params);
180
182 virtual ~DatabaseSchwarz();
183
185
187
189 void setParameters(const Teuchos::ParameterList& params);
190
191 bool supportsZeroStartingSolution() { return true; }
192
193 void setZeroStartingSolution(bool zeroStartingSolution);
194
201 void initialize();
202
205 inline bool isInitialized() const {
206 return IsInitialized_;
207 }
208
211 void compute();
212
214 inline bool isComputed() const {
215 return IsComputed_;
216 }
217
219
221
223 virtual void
224 setMatrix(const Teuchos::RCP<const row_matrix_type>& A);
225
227
229
232 void
233 apply(const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
234 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
235 Teuchos::ETransp mode = Teuchos::NO_TRANS,
236 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
237 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
238
240 Teuchos::RCP<const map_type> getDomainMap() const;
241
243 Teuchos::RCP<const map_type> getRangeMap() const;
244
246 bool hasTransposeApply() const;
247
249 void
250 applyMat(const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
251 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
252 Teuchos::ETransp mode = Teuchos::NO_TRANS) const;
253
255
257
259 Teuchos::RCP<const Teuchos::Comm<int> > getComm() const;
260
262 Teuchos::RCP<const row_matrix_type> getMatrix() const;
263
265 Teuchos::RCP<const row_matrix_type> A_;
266
271 Teuchos::RCP<const Tpetra::CrsMatrix<scalar_type, local_ordinal_type, global_ordinal_type, node_type> >
272 getCrsMatrix() const;
273
275 double getComputeFlops() const;
276
278 double getApplyFlops() const;
279
281 int getNumInitialize() const;
282
284 int getNumCompute() const;
285
287 int getNumApply() const;
288
290 double getInitializeTime() const;
291
293 double getComputeTime() const;
294
296 double getApplyTime() const;
297
299 size_t getNodeSmootherComplexity() const;
300
302
304
306 std::string description() const;
307
309 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
310
312
313private:
314
316 void setParametersImpl(Teuchos::ParameterList& params);
317
319 typedef Teuchos::ScalarTraits<typename MatrixType::scalar_type> STS;
320
322 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
323
326
329
331
332
334 bool IsInitialized_;
336 bool IsComputed_;
338 int NumInitialize_;
340 int NumCompute_;
345 mutable int NumApply_;
347 double InitializeTime_;
349 double ComputeTime_;
354 mutable double ApplyTime_;
356 double ComputeFlops_;
361 mutable double ApplyFlops_;
362
364 local_ordinal_type PatchSize_;
365
367 mutable size_t NumPatches_;
368
370 double PatchTolerance_;
371
373 bool SkipDatabase_;
374
376 bool Verbose_;
377
379 mutable std::vector<std::vector<typename row_matrix_type::local_ordinal_type> > PatchIndices_;
380
382 mutable size_t DatabaseSize_;
383
385 mutable std::vector<Teuchos::RCP<typename Teuchos::SerialDenseMatrix<typename row_matrix_type::local_ordinal_type,typename row_matrix_type::scalar_type> > > DatabaseMatrices_;
386
388 std::vector<int> DatabaseIndices_;
389
391 std::vector<magnitude_type> Weights_;
392
394 mutable Teuchos::Array<int> ipiv_;
395
397}; // class DatabaseSchwarz
398
399} // namespace Ifpack2
400
401#endif // IFPACK2_DATABASESCHWARZ_DECL_HPP
402
Declaration of interface for preconditioners that can change their matrix after construction.
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:306
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:202
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition Ifpack2_DatabaseSchwarz_decl.hpp:127
void setParameters(const Teuchos::ParameterList &params)
Set (or reset) parameters.
Definition Ifpack2_DatabaseSchwarz_def.hpp:126
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
The Tpetra::Map specialization matching MatrixType.
Definition Ifpack2_DatabaseSchwarz_decl.hpp:144
bool isInitialized() const
Definition Ifpack2_DatabaseSchwarz_decl.hpp:205
bool hasTransposeApply() const
Whether it's possible to apply the transpose of this operator.
Definition Ifpack2_DatabaseSchwarz_def.hpp:238
MatrixType matrix_type
The template parameter of this class.
Definition Ifpack2_DatabaseSchwarz_decl.hpp:112
double getComputeFlops() const
The total number of floating-point operations taken by all calls to compute().
Definition Ifpack2_DatabaseSchwarz_def.hpp:280
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:651
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:400
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition Ifpack2_DatabaseSchwarz_decl.hpp:130
size_t getNodeSmootherComplexity() const
Get a rough estimate of cost per iteration.
Definition Ifpack2_DatabaseSchwarz_def.hpp:291
int getNumApply() const
The total number of successful calls to apply().
Definition Ifpack2_DatabaseSchwarz_def.hpp:256
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition Ifpack2_DatabaseSchwarz_decl.hpp:121
DatabaseSchwarz(const Teuchos::RCP< const row_matrix_type > &A)
Constructor.
Definition Ifpack2_DatabaseSchwarz_def.hpp:61
bool isComputed() const
Whether compute() has been called at least once.
Definition Ifpack2_DatabaseSchwarz_decl.hpp:214
Teuchos::RCP< const map_type > getDomainMap() const
The Tpetra::Map representing the domain of this operator.
Definition Ifpack2_DatabaseSchwarz_def.hpp:212
virtual ~DatabaseSchwarz()
Destructor.
Definition Ifpack2_DatabaseSchwarz_def.hpp:108
void setZeroStartingSolution(bool zeroStartingSolution)
Set this preconditioner's parameters.
Definition Ifpack2_DatabaseSchwarz_def.hpp:170
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition Ifpack2_DatabaseSchwarz_decl.hpp:118
int getNumCompute() const
The total number of successful calls to compute().
Definition Ifpack2_DatabaseSchwarz_def.hpp:250
double getComputeTime() const
The total time spent in all calls to compute().
Definition Ifpack2_DatabaseSchwarz_def.hpp:268
double getApplyTime() const
The total time spent in all calls to apply().
Definition Ifpack2_DatabaseSchwarz_def.hpp:274
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Change the matrix to be preconditioned.
Definition Ifpack2_DatabaseSchwarz_def.hpp:113
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition Ifpack2_DatabaseSchwarz_decl.hpp:115
Teuchos::RCP< const row_matrix_type > A_
The matrix for which this is a preconditioner.
Definition Ifpack2_DatabaseSchwarz_decl.hpp:265
MatrixType::node_type::device_type device_type
The Kokkos::Device specialization used by the input MatrixType.
Definition Ifpack2_DatabaseSchwarz_decl.hpp:124
double getInitializeTime() const
The total time spent in all calls to initialize().
Definition Ifpack2_DatabaseSchwarz_def.hpp:262
Teuchos::RCP< const map_type > getRangeMap() const
The Tpetra::Map representing the range of this operator.
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:434
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The communicator over which the matrix is distributed.
Definition Ifpack2_DatabaseSchwarz_def.hpp:177
int getNumInitialize() const
The total number of successful calls to initialize().
Definition Ifpack2_DatabaseSchwarz_def.hpp:244
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:152
double getApplyFlops() const
The total number of floating-point operations taken by all calls to apply().
Definition Ifpack2_DatabaseSchwarz_def.hpp:286
std::string description() const
A simple one-line description of this object.
Definition Ifpack2_DatabaseSchwarz_def.hpp:620
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:137
void initialize()
Initialize the preconditioner.
Definition Ifpack2_DatabaseSchwarz_def.hpp:419
Teuchos::RCP< const row_matrix_type > getMatrix() const
The matrix for which this is a preconditioner.
Definition Ifpack2_DatabaseSchwarz_def.hpp:190
Mix-in interface for preconditioners that can change their matrix after construction.
Definition Ifpack2_Details_CanChangeMatrix.hpp:93
Interface for all Ifpack2 preconditioners.
Definition Ifpack2_Preconditioner.hpp:108
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:74