Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
Ifpack2_Details_Amesos2Wrapper_decl.hpp
Go to the documentation of this file.
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
50
51#ifndef IFPACK2_DETAILS_AMESOS2WRAPPER_DECL_HPP
52#define IFPACK2_DETAILS_AMESOS2WRAPPER_DECL_HPP
53
54#include "Ifpack2_ConfigDefs.hpp"
55
56#ifdef HAVE_IFPACK2_AMESOS2
57
60#include "Tpetra_CrsMatrix.hpp"
61#include <type_traits>
62
63namespace Teuchos {
64 // forward declaration
65 class ParameterList;
66}
67
68namespace Trilinos {
69namespace Details {
70 template<class MV, class OP, class NormType>
71 class LinearSolver; // forward declaration
72} // namespace Details
73} // namespace Trilinos
74
75
76namespace Ifpack2 {
77namespace Details {
101template<class MatrixType>
103 virtual public Ifpack2::Preconditioner<typename MatrixType::scalar_type,
104 typename MatrixType::local_ordinal_type,
105 typename MatrixType::global_ordinal_type,
106 typename MatrixType::node_type>,
107 virtual public Ifpack2::Details::CanChangeMatrix<Tpetra::RowMatrix<typename MatrixType::scalar_type,
108 typename MatrixType::local_ordinal_type,
109 typename MatrixType::global_ordinal_type,
110 typename MatrixType::node_type> >
111{
112public:
114
115
117 typedef typename MatrixType::scalar_type scalar_type;
118
120 typedef typename MatrixType::local_ordinal_type local_ordinal_type;
121
123 typedef typename MatrixType::global_ordinal_type global_ordinal_type;
124
126 typedef typename MatrixType::node_type node_type;
127
129 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType magnitude_type;
130
132 typedef Tpetra::RowMatrix<scalar_type,
136
137 static_assert(std::is_same<MatrixType, row_matrix_type>::value,
138 "Ifpack2::Details::Amesos2Wrapper: Please use MatrixType = Tpetra::RowMatrix.");
139
141 typedef Tpetra::Map<local_ordinal_type,
144
146 typedef Tpetra::CrsMatrix<scalar_type,
151
153
159 explicit Amesos2Wrapper (const Teuchos::RCP<const row_matrix_type>& A);
160
162 virtual ~Amesos2Wrapper();
163
165
167
169 void setParameters (const Teuchos::ParameterList& params);
170
183 void initialize ();
184
186 inline bool isInitialized() const {
187 return IsInitialized_;
188 }
189
201 void compute();
202
204 inline bool isComputed() const {
205 return IsComputed_;
206 }
207
209
211
234 virtual void
235 setMatrix (const Teuchos::RCP<const row_matrix_type>& A);
236
238
240
256 void
257 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
258 Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
259 Teuchos::ETransp mode = Teuchos::NO_TRANS,
260 scalar_type alpha = Teuchos::ScalarTraits<scalar_type>::one(),
261 scalar_type beta = Teuchos::ScalarTraits<scalar_type>::zero()) const;
262
264 Teuchos::RCP<const map_type> getDomainMap () const;
265
267 Teuchos::RCP<const map_type> getRangeMap () const;
268
270 bool hasTransposeApply () const;
271
273
275
277 Teuchos::RCP<const Teuchos::Comm<int> > getComm () const;
278
280 Teuchos::RCP<const row_matrix_type> getMatrix () const;
281
283 int getNumInitialize () const;
284
286 int getNumCompute () const;
287
289 int getNumApply () const;
290
292 double getInitializeTime () const;
293
295 double getComputeTime () const;
296
298 double getApplyTime () const;
299
301
303
305 std::string description () const;
306
308 void
309 describe (Teuchos::FancyOStream &out,
310 const Teuchos::EVerbosityLevel verbLevel =
311 Teuchos::Describable::verbLevel_default) const;
313
314private:
315 typedef Teuchos::ScalarTraits<scalar_type> STS;
316 typedef Teuchos::ScalarTraits<magnitude_type> STM;
317 typedef typename Teuchos::Array<local_ordinal_type>::size_type size_type;
318
320 typedef Tpetra::MultiVector<scalar_type, local_ordinal_type, global_ordinal_type, node_type> MV;
322 typedef Tpetra::Operator<scalar_type, local_ordinal_type, global_ordinal_type, node_type> OP;
323
326
329
331 Teuchos::RCP<Trilinos::Details::LinearSolver<MV, OP, typename MV::mag_type> > solver_;
332
338 static Teuchos::RCP<const row_matrix_type>
339 makeLocalFilter (const Teuchos::RCP<const row_matrix_type>& A);
340
342 //Teuchos::RCP<const MatrixType> A_;
343 Teuchos::RCP<const row_matrix_type> A_;
344
353 Teuchos::RCP<const crs_matrix_type> A_local_crs_;
354
356 // \name Parameters (set by setParameters())
358
361 Teuchos::RCP<const Teuchos::ParameterList> parameterList_;
362
364 // \name Other internal data
366
368 double InitializeTime_;
370 double ComputeTime_;
372 mutable double ApplyTime_;
374 int NumInitialize_;
376 int NumCompute_;
378 mutable int NumApply_;
380 bool IsInitialized_;
382 bool IsComputed_;
385 std::string SolverName_;
387}; // class Amesos2Wrapper
388
389} // namespace Details
390} // namespace Ifpack2
391
392#endif // HAVE_IFPACK2_AMESOS2
393
394#endif // IFPACK2_DETAILS_AMESOS2WRAPPER_DECL_HPP
Declaration of interface for preconditioners that can change their matrix after construction.
Wrapper class for direct solvers in Amesos2.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:111
double getComputeTime() const
The total time in seconds spent in successful calls to compute().
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:202
Teuchos::RCP< const map_type > getRangeMap() const
Tpetra::Map representing the range of this operator.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:161
Tpetra::Map< local_ordinal_type, global_ordinal_type, node_type > map_type
Type of the Tpetra::Map specialization that this class uses.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:143
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
The type of the magnitude (absolute value) of a matrix entry.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:129
Teuchos::RCP< const row_matrix_type > getMatrix() const
The input matrix; the matrix to be preconditioned.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:142
MatrixType::scalar_type scalar_type
The type of the entries of the input MatrixType.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:117
int getNumInitialize() const
The total number of successful calls to initialize().
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:178
double getApplyTime() const
The total time in seconds spent in successful calls to apply().
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:208
int getNumApply() const
The total number of successful calls to apply().
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:190
MatrixType::local_ordinal_type local_ordinal_type
The type of local indices in the input MatrixType.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:120
bool isComputed() const
True if compute() completed successfully, else false.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:204
MatrixType::node_type node_type
The Node type used by the input MatrixType.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:126
virtual ~Amesos2Wrapper()
Destructor.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:82
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to the given output stream.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:553
MatrixType::global_ordinal_type global_ordinal_type
The type of global indices in the input MatrixType.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:123
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, resulting in Y.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:414
std::string description() const
A one-line description of this object.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:513
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_Details_Amesos2Wrapper_decl.hpp:135
bool isInitialized() const
Returns true if the preconditioner has been successfully initialized.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:186
void initialize()
Compute the preordering and symbolic factorization of the matrix.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:275
int getNumCompute() const
The total number of successful calls to compute().
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:184
void setParameters(const Teuchos::ParameterList &params)
Set parameters.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:86
Tpetra::CrsMatrix< scalar_type, local_ordinal_type, global_ordinal_type, node_type > crs_matrix_type
Type of the Tpetra::CrsMatrix specialization that this class uses.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:149
Teuchos::RCP< const map_type > getDomainMap() const
Tpetra::Map representing the domain of this operator.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:149
void compute()
Compute the numeric factorization of the matrix.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:381
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
The input matrix's communicator.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:131
double getInitializeTime() const
The total time in seconds spent in successful calls to initialize().
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:196
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Change the matrix to be preconditioned.
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:213
bool hasTransposeApply() const
Whether this object's apply() method can apply the transpose (or conjugate transpose,...
Definition: Ifpack2_Details_Amesos2Wrapper_def.hpp:172
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
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:74