Loading...
Searching...
No Matches
terra::linalg::solvers::PCG< OperatorT, PreconditionerT > Class Template Reference

Preconditioned Conjugate Gradient (PCG) iterative solver for symmetric positive definite linear systems. More...

#include <pcg.hpp>

Public Types

using OperatorType = OperatorT
 Operator type to be solved.
 
using SolutionVectorType = SrcOf< OperatorType >
 Solution vector type.
 
using RHSVectorType = DstOf< OperatorType >
 Right-hand side vector type.
 
using ScalarType = typename SolutionVectorType::ScalarType
 Scalar type for computations.
 

Public Member Functions

 PCG (const IterativeSolverParameters &params, const std::shared_ptr< util::Table > &statistics, const std::vector< SolutionVectorType > &tmps)
 Construct a PCG solver with default identity preconditioner.
 
 PCG (const IterativeSolverParameters &params, const std::shared_ptr< util::Table > &statistics, const std::vector< SolutionVectorType > &tmps, const PreconditionerT preconditioner)
 Construct a PCG solver with a custom preconditioner.
 
void set_tag (const std::string &tag)
 Set a tag string for statistics output.
 
void solve_impl (OperatorType &A, SolutionVectorType &x, const RHSVectorType &b)
 Solve the linear system \( Ax = b \) using PCG. Calls the iterative solver and updates statistics.
 

Detailed Description

template<OperatorLike OperatorT, SolverLike PreconditionerT = IdentitySolver< OperatorT >>
class terra::linalg::solvers::PCG< OperatorT, PreconditionerT >

Preconditioned Conjugate Gradient (PCG) iterative solver for symmetric positive definite linear systems.

See, e.g.,

Elman, H. C., Silvester, D. J., & Wathen, A. J. (2014).
Finite elements and fast iterative solvers: with applications in incompressible fluid dynamics.
Oxford university press.

Satisfies the SolverLike concept (see solver.hpp). Supports optional preconditioning.

Template Parameters
OperatorTOperator type (must satisfy OperatorLike).
PreconditionerTPreconditioner type (must satisfy SolverLike, defaults to IdentitySolver).

Member Typedef Documentation

◆ OperatorType

template<OperatorLike OperatorT, SolverLike PreconditionerT = IdentitySolver< OperatorT >>
using terra::linalg::solvers::PCG< OperatorT, PreconditionerT >::OperatorType = OperatorT

Operator type to be solved.

◆ RHSVectorType

template<OperatorLike OperatorT, SolverLike PreconditionerT = IdentitySolver< OperatorT >>
using terra::linalg::solvers::PCG< OperatorT, PreconditionerT >::RHSVectorType = DstOf< OperatorType >

Right-hand side vector type.

◆ ScalarType

template<OperatorLike OperatorT, SolverLike PreconditionerT = IdentitySolver< OperatorT >>
using terra::linalg::solvers::PCG< OperatorT, PreconditionerT >::ScalarType = typename SolutionVectorType::ScalarType

Scalar type for computations.

◆ SolutionVectorType

template<OperatorLike OperatorT, SolverLike PreconditionerT = IdentitySolver< OperatorT >>
using terra::linalg::solvers::PCG< OperatorT, PreconditionerT >::SolutionVectorType = SrcOf< OperatorType >

Solution vector type.

Constructor & Destructor Documentation

◆ PCG() [1/2]

template<OperatorLike OperatorT, SolverLike PreconditionerT = IdentitySolver< OperatorT >>
terra::linalg::solvers::PCG< OperatorT, PreconditionerT >::PCG ( const IterativeSolverParameters params,
const std::shared_ptr< util::Table > &  statistics,
const std::vector< SolutionVectorType > &  tmps 
)
inline

Construct a PCG solver with default identity preconditioner.

Parameters
paramsIterative solver parameters.
statisticsShared pointer to statistics table.
tmpsTemporary vectors for workspace. (At least 4 vectors are required.)

◆ PCG() [2/2]

template<OperatorLike OperatorT, SolverLike PreconditionerT = IdentitySolver< OperatorT >>
terra::linalg::solvers::PCG< OperatorT, PreconditionerT >::PCG ( const IterativeSolverParameters params,
const std::shared_ptr< util::Table > &  statistics,
const std::vector< SolutionVectorType > &  tmps,
const PreconditionerT  preconditioner 
)
inline

Construct a PCG solver with a custom preconditioner.

Parameters
paramsIterative solver parameters.
statisticsShared pointer to statistics table.
tmpsTemporary vectors for workspace. (At least 4 vectors are required.)
preconditionerPreconditioner solver.

Member Function Documentation

◆ set_tag()

template<OperatorLike OperatorT, SolverLike PreconditionerT = IdentitySolver< OperatorT >>
void terra::linalg::solvers::PCG< OperatorT, PreconditionerT >::set_tag ( const std::string &  tag)
inline

Set a tag string for statistics output.

Parameters
tagTag string.

◆ solve_impl()

template<OperatorLike OperatorT, SolverLike PreconditionerT = IdentitySolver< OperatorT >>
void terra::linalg::solvers::PCG< OperatorT, PreconditionerT >::solve_impl ( OperatorType A,
SolutionVectorType x,
const RHSVectorType b 
)
inline

Solve the linear system \( Ax = b \) using PCG. Calls the iterative solver and updates statistics.

Parameters
AOperator (matrix).
xSolution vector (output).
bRight-hand side vector (input).

< Residual vector.

< Search direction vector.

< Temporary vector for A*p.

< Preconditioned residual vector.


The documentation for this class was generated from the following file: