Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_IdentitySolver_decl.hpp
1/*@HEADER
2// ***********************************************************************
3//
4// Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
5// Copyright (2009) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40//@HEADER
41*/
42
43#ifndef IFPACK2_IDENTITY_SOLVER_DECL_HPP
44#define IFPACK2_IDENTITY_SOLVER_DECL_HPP
45
48#include "Tpetra_Export_fwd.hpp"
49#include <type_traits>
50
51namespace Ifpack2 {
52
59template<class MatrixType>
61 virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
62 typename MatrixType::local_ordinal_type,
63 typename MatrixType::global_ordinal_type,
64 typename MatrixType::node_type>,
65 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
66 typename MatrixType::local_ordinal_type,
67 typename MatrixType::global_ordinal_type,
68 typename MatrixType::node_type> >
69{
70public:
72 typedef typename MatrixType::scalar_type scalar_type;
74 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
76 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
78 typedef typename MatrixType::node_type node_type;
79
81 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
83 typedef Tpetra::Map<local_ordinal_type, global_ordinal_type, node_type> map_type;
85 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
87
88 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.");
89
91 IdentitySolver (const Teuchos::RCP<const row_matrix_type>& A);
92
94 virtual ~IdentitySolver();
95
99 void setParameters (const Teuchos::ParameterList& params);
100
102 void initialize();
103
105 inline bool isInitialized() const {
106 return(isInitialized_);
107 }
108
110 void compute();
111
113 inline bool isComputed() const {
114 return(isComputed_);
115 }
116
118
119
126 void
127 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
128 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
129 Teuchos::ETransp mode = Teuchos::NO_TRANS,
130 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
131 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
132
134 Teuchos::RCP<const map_type> getDomainMap () const;
135
137 Teuchos::RCP<const map_type> getRangeMap () const;
138
143 void
144 applyMat (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
145 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
146 Teuchos::ETransp mode = Teuchos::NO_TRANS) const;
147
149 Teuchos::RCP<const Teuchos::Comm<int> > getComm () const;
150
152 Teuchos::RCP<const row_matrix_type> getMatrix () const {
153 return matrix_;
154 }
155
157 double getComputeFlops() const;
158
160 double getApplyFlops() const;
161
163 int getNumInitialize() const;
164
166 int getNumCompute() const;
167
169 int getNumApply() const;
170
172 double getInitializeTime() const;
173
175 double getComputeTime() const;
176
178 double getApplyTime() const;
179
181
183
185 std::string description() const;
186
188 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
189
194 virtual void setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
195
197
198private:
200 typedef Tpetra::Export<local_ordinal_type, global_ordinal_type, node_type> export_type;
201
202 Teuchos::RCP<const row_matrix_type> matrix_;
203
211 Teuchos::RCP<const export_type> export_;
212
213 bool isInitialized_;
214 bool isComputed_;
215
216 mutable int numInitialize_;
217 mutable int numCompute_;
218 mutable int numApply_;
219
220 double initializeTime_;
221 double computeTime_;
222 double applyTime_;
223};
224
225}//namespace Ifpack2
226
227#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:93
"Identity" preconditioner.
Definition: Ifpack2_IdentitySolver_decl.hpp:69
void initialize()
Initialize.
Definition: Ifpack2_IdentitySolver_def.hpp:79
int getNumInitialize() const
Return the number of calls to initialize().
Definition: Ifpack2_IdentitySolver_def.hpp:167
Teuchos::RCP< const row_matrix_type > getMatrix() const
Return a reference to the matrix to be preconditioned.
Definition: Ifpack2_IdentitySolver_decl.hpp:152
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:247
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:78
void setParameters(const Teuchos::ParameterList &params)
Set this object's parameters.
Definition: Ifpack2_IdentitySolver_def.hpp:74
double getInitializeTime() const
Return the time spent in initialize().
Definition: Ifpack2_IdentitySolver_def.hpp:182
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:127
int getNumCompute() const
Return the number of calls to compute().
Definition: Ifpack2_IdentitySolver_def.hpp:172
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:74
bool isInitialized() const
Return true if the preconditioner has been successfully initialized.
Definition: Ifpack2_IdentitySolver_decl.hpp:105
double getApplyTime() const
Return the time spent in apply().
Definition: Ifpack2_IdentitySolver_def.hpp:192
std::string description() const
Return a simple one-line description of this object.
Definition: Ifpack2_IdentitySolver_def.hpp:197
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set this preconditioner's matrix.
Definition: Ifpack2_IdentitySolver_def.hpp:268
Teuchos::RCP< const map_type > getRangeMap() const
Return the Tpetra::Map object associated with the range of this operator.
Definition: Ifpack2_IdentitySolver_def.hpp:257
double getComputeTime() const
Return the time spent in compute().
Definition: Ifpack2_IdentitySolver_def.hpp:187
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:227
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:83
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
Type of the absolute value (magnitude) of a scalar_type value.
Definition: Ifpack2_IdentitySolver_decl.hpp:81
MatrixType::global_ordinal_type global_ordinal_type
Type of the global indices of the input matrix.
Definition: Ifpack2_IdentitySolver_decl.hpp:76
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:86
MatrixType::scalar_type scalar_type
Type of the entries of the input matrix.
Definition: Ifpack2_IdentitySolver_decl.hpp:72
int getNumApply() const
Return the number of calls to apply().
Definition: Ifpack2_IdentitySolver_def.hpp:177
virtual ~IdentitySolver()
Destructor.
Definition: Ifpack2_IdentitySolver_def.hpp:69
void compute()
Compute the preconditioner.
Definition: Ifpack2_IdentitySolver_def.hpp:110
bool isComputed() const
Return true if compute() has been called.
Definition: Ifpack2_IdentitySolver_decl.hpp:113
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:108
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:74