GEOSX
GMRESsolver.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 Total, S.A
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOSX_LINEARALGEBRA_SOLVERS_GMRESSOLVER_HPP_
20 #define GEOSX_LINEARALGEBRA_SOLVERS_GMRESSOLVER_HPP_
21 
22 #include "linearAlgebra/solvers/KrylovSolver.hpp"
23 
24 namespace geosx
25 {
26 
36 template< typename VECTOR >
37 class GMRESsolver : public KrylovSolver< VECTOR >
38 {
39 public:
40 
43 
45  using Vector = typename Base::Vector;
46 
50 
61  GMRESsolver( LinearOperator< Vector > const & matrix,
62  LinearOperator< Vector > const & precond,
63  real64 const tolerance,
64  localIndex const maxIterations,
65  integer const verbosity = 0,
66  localIndex const maxRestart = 100 );
67 
71  virtual ~GMRESsolver() override;
72 
74 
78 
85  virtual void solve( Vector const & b, Vector & x ) const override final;
86 
87  virtual string methodName() const override final
88  {
89  return "GMRES";
90  };
91 
93 
94 protected:
95 
98 
99  using Base::m_operator;
100  using Base::m_precond;
101  using Base::m_tolerance;
102  using Base::m_maxIterations;
103  using Base::m_logLevel;
104  using Base::m_result;
105  using Base::m_residualNorms;
107  using Base::logProgress;
108  using Base::logResult;
109 
112 
115 
118 };
119 
120 } // namespace geosx
121 
122 #endif //GEOSX_LINEARALGEBRA_SOLVERS_GMRESSOLVER_HPP_
typename VectorStorageHelper< VECTOR >::type VectorTemp
Alias for vector type that can be used for temporaries.
This class implements Generalized Minimized RESidual method (right-preconditioned) for monolithic and...
Definition: GMRESsolver.hpp:37
bool m_kspaceInitialized
Flag indicating whether kspace vectors have been created.
virtual string methodName() const override final
Get name of the Krylov subspace method.
Definition: GMRESsolver.hpp:87
integer m_logLevel
solver verbosity level
LinearOperator< Vector > const & m_operator
reference to the operator to be solved
LinearOperator< Vector > const & m_precond
reference to the preconditioning operator
void logProgress(localIndex const iter, real64 const rnorm) const
Output iteration progress (called by implementations).
static VectorTemp createTempVector(Vector const &src)
Helper function to create temporary vectors based on a source vector.
typename KrylovSolver< VECTOR >::VectorTemp VectorTemp
Alias for vector type that can be used for temporaries.
Definition: GMRESsolver.hpp:97
double real64
64-bit floating point type.
Definition: DataTypes.hpp:136
array1d< real64 > m_residualNorms
Absolute residual norms at each iteration (if available)
typename Base::Vector Vector
Alias for template parameter.
localIndex m_maxRestart
Number of iterations needed to restart GMRES.
real64 m_tolerance
relative residual norm reduction tolerance
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
array1d< VectorTemp > m_kspace
Storage for Krylov subspace vectors.
localIndex m_maxIterations
maximum number of Krylov iterations
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
virtual ~GMRESsolver() override
Virtual destructor.
GMRESsolver(LinearOperator< Vector > const &matrix, LinearOperator< Vector > const &precond, real64 const tolerance, localIndex const maxIterations, integer const verbosity=0, localIndex const maxRestart=100)
Solver object constructor.
void logResult() const
Output convergence result (called by implementations).
VECTOR Vector
Alias for template parameter.
LinearSolverResult m_result
results of a solve
Base class for Krylov solvers.
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55
virtual void solve(Vector const &b, Vector &x) const override final
Solve preconditioned system.