GEOSX
CgSolver.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 TotalEnergies
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 GEOS_LINEARALGEBRA_SOLVERS_CGSOLVER_HPP_
20 #define GEOS_LINEARALGEBRA_SOLVERS_CGSOLVER_HPP_
21 
22 #include "linearAlgebra/solvers/KrylovSolver.hpp"
23 
24 namespace geos
25 {
26 
36 template< typename VECTOR >
37 class CgSolver : public KrylovSolver< VECTOR >
38 {
39 public:
40 
43 
45  using Vector = typename Base::Vector;
46 
51 
59  LinearOperator< Vector > const & A,
60  LinearOperator< Vector > const & M );
61 
63 
68 
74  virtual void solve( Vector const & b, Vector & x ) const override final;
75 
76  virtual string methodName() const override final
77  {
78  return "CG";
79  };
80 
82 
83 protected:
84 
87 
88  using Base::m_params;
89  using Base::m_operator;
90  using Base::m_precond;
91  using Base::m_result;
94  using Base::logProgress;
95  using Base::logResult;
96 
97 };
98 
99 } // namespace GEOSX
100 
101 #endif /*GEOS_LINEARALGEBRA_SOLVERS_CGSOLVER_HPP_*/
This class implements Conjugate Gradient method for monolithic and block linear operators.
Definition: CgSolver.hpp:38
virtual string methodName() const override final
Get name of the Krylov subspace method.
Definition: CgSolver.hpp:76
virtual void solve(Vector const &b, Vector &x) const override final
Solve preconditioned system.
typename KrylovSolver< VECTOR >::VectorTemp VectorTemp
Alias for vector type that can be used for temporaries.
Definition: CgSolver.hpp:86
CgSolver(LinearSolverParameters params, LinearOperator< Vector > const &A, LinearOperator< Vector > const &M)
Constructor.
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.
Set of parameters for a linear solver or preconditioner.