GEOS
GmresSolver.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_LINEARALGEBRA_SOLVERS_GMRESSOLVER_HPP_
21 #define GEOS_LINEARALGEBRA_SOLVERS_GMRESSOLVER_HPP_
22 
23 #include "linearAlgebra/solvers/KrylovSolver.hpp"
24 
25 namespace geos
26 {
27 
37 template< typename VECTOR >
38 class GmresSolver : public KrylovSolver< VECTOR >
39 {
40 public:
41 
44 
46  using Vector = typename Base::Vector;
47 
52 
60  LinearOperator< Vector > const & matrix,
61  LinearOperator< Vector > const & precond );
62 
64 
69 
75  virtual void solve( Vector const & b, Vector & x ) const override final;
76 
77  virtual string methodName() const override final
78  {
79  return "GMRES";
80  };
81 
83 
84 protected:
85 
88 
89  using Base::m_params;
90  using Base::m_operator;
91  using Base::m_precond;
93  using Base::m_result;
95  using Base::logProgress;
96  using Base::logResult;
97 
100 
102  bool mutable m_kspaceInitialized;
103 };
104 
105 } // namespace geos
106 
107 #endif //GEOS_LINEARALGEBRA_SOLVERS_GMRESSOLVER_HPP_
This class implements Generalized Minimized RESidual method (right-preconditioned) for monolithic and...
Definition: GmresSolver.hpp:39
virtual void solve(Vector const &b, Vector &x) const override final
Solve preconditioned system.
array1d< VectorTemp > m_kspace
Storage for Krylov subspace vectors.
Definition: GmresSolver.hpp:99
bool m_kspaceInitialized
Flag indicating whether kspace vectors have been created.
GmresSolver(LinearSolverParameters params, LinearOperator< Vector > const &matrix, LinearOperator< Vector > const &precond)
Solver object constructor.
virtual string methodName() const override final
Get name of the Krylov subspace method.
Definition: GmresSolver.hpp:77
typename KrylovSolver< VECTOR >::VectorTemp VectorTemp
Alias for vector type that can be used for temporaries.
Definition: GmresSolver.hpp:87
Base class for Krylov solvers.
LinearSolverResult m_result
results of a solve
LinearOperator< Vector > const & m_operator
reference to the operator to be solved
static VectorTemp createTempVector(Vector const &src)
Helper function to create temporary vectors based on a source vector.
void logResult() const
Output convergence result (called by implementations).
typename Base::Vector Vector
Alias for template parameter.
typename VectorStorageHelper< VECTOR >::type VectorTemp
Alias for vector type that can be used for temporaries.
LinearOperator< Vector > const & m_precond
reference to the preconditioning operator
void logProgress() const
Output iteration progress (called by implementations).
array1d< real64 > m_residualNorms
Absolute residual norms at each iteration (if available)
LinearSolverParameters m_params
parameters of the solver
VECTOR Vector
Alias for template parameter.
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:176
Set of parameters for a linear solver or preconditioner.