Advanced Multi-Physics (AMP)
On-Line Documentation
CGSolver.h
Go to the documentation of this file.
1#ifndef included_AMP_CGSolver
2#define included_AMP_CGSolver
3
4#include "AMP/solvers/SolverStrategy.h"
5#include "AMP/solvers/SolverStrategyParameters.h"
6#include "AMP/utils/AMP_MPI.h"
7
8#include <string>
9
10namespace AMP::Solver {
11
36template<typename T = double>
38{
39public:
43 CGSolver() = default;
44
58 explicit CGSolver( std::shared_ptr<SolverStrategyParameters> params );
59
65 static std::unique_ptr<SolverStrategy>
66 createSolver( std::shared_ptr<SolverStrategyParameters> params )
67 {
68 return std::make_unique<CGSolver<T>>( params );
69 }
70
74 virtual ~CGSolver() = default;
75
76 std::string type() const override { return "CGSolver"; }
77
83 void apply( std::shared_ptr<const AMP::LinearAlgebra::Vector> f,
84 std::shared_ptr<AMP::LinearAlgebra::Vector> u ) override;
85
90 void initialize( std::shared_ptr<const SolverStrategyParameters> params ) override;
91
96 void registerOperator( std::shared_ptr<AMP::Operator::Operator> op ) override;
97
98protected:
99 void getFromInput( std::shared_ptr<AMP::Database> db );
100 void allocateScratchVectors( std::shared_ptr<const AMP::LinearAlgebra::Vector> u );
101
102private:
104
105 std::vector<T> d_gamma;
106
108
110 bool d_bFlexibleCG = false;
111
114
116 std::string d_sVariant = "pcg";
117
119 std::shared_ptr<AMP::LinearAlgebra::Vector> d_r;
120 std::shared_ptr<AMP::LinearAlgebra::Vector> d_p;
121 std::shared_ptr<AMP::LinearAlgebra::Vector> d_w;
122 std::shared_ptr<AMP::LinearAlgebra::Vector> d_z;
123
126 std::vector<std::shared_ptr<AMP::LinearAlgebra::Vector>> d_vDirs;
127};
128} // namespace AMP::Solver
129
130#endif
void allocateScratchVectors(std::shared_ptr< const AMP::LinearAlgebra::Vector > u)
std::vector< T > d_gamma
Definition CGSolver.h:105
std::shared_ptr< AMP::LinearAlgebra::Vector > d_p
Definition CGSolver.h:120
void apply(std::shared_ptr< const AMP::LinearAlgebra::Vector > f, std::shared_ptr< AMP::LinearAlgebra::Vector > u) override
static std::unique_ptr< SolverStrategy > createSolver(std::shared_ptr< SolverStrategyParameters > params)
Definition CGSolver.h:66
std::string type() const override
Return the name of the solver.
Definition CGSolver.h:76
bool d_bFlexibleCG
use flexible CG if true
Definition CGSolver.h:110
int d_max_dimension
maximum dimension of the stored search space for FCG
Definition CGSolver.h:113
virtual ~CGSolver()=default
void getFromInput(std::shared_ptr< AMP::Database > db)
std::string d_sVariant
variant being used, can be one of "pcg", "ipcg", or "fcg"
Definition CGSolver.h:116
std::shared_ptr< AMP::LinearAlgebra::Vector > d_z
Definition CGSolver.h:122
std::shared_ptr< AMP::LinearAlgebra::Vector > d_w
Definition CGSolver.h:121
std::shared_ptr< AMP::LinearAlgebra::Vector > d_r
scratch vectors required for PCG
Definition CGSolver.h:119
std::vector< std::shared_ptr< AMP::LinearAlgebra::Vector > > d_vDirs
Definition CGSolver.h:126
void initialize(std::shared_ptr< const SolverStrategyParameters > params) override
CGSolver(std::shared_ptr< SolverStrategyParameters > params)
void registerOperator(std::shared_ptr< AMP::Operator::Operator > op) override
std::shared_ptr< AMP::Solver::SolverStrategy > shared_ptr



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:41.
Comments on this page