SOFA API  c76874b7
Open source framework for multi-physics simuation
sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector > Class Template Reference

#include <ShewchukPCGLinearSolver.h>

Linear system solver using the conjugate gradient iterative algorithm. More...

Inheritance diagram for sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >:

Detailed Description

template<class TMatrix, class TVector>
class sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >

Linear system solver using the conjugate gradient iterative algorithm.

Public Attributes

Data< unsigned > f_maxIter
 maximum number of iterations of the Conjugate Gradient solution More...
 
Data< doublef_tolerance
 desired precision of the Conjugate Gradient Solution (ratio of current residual norm over initial residual norm) More...
 
Data< boolf_use_precond
 Use preconditioner. More...
 
Data< unsigned > f_update_step
 Number of steps before the next refresh of precondtioners. More...
 
Data< boolf_build_precond
 Build the preconditioners, if false build the preconditioner only at the initial step. More...
 
Data< std::string > f_preconditioners
 If not empty: path to the solvers to use as preconditioners. More...
 
Data< std::map< std::string, sofa::helper::vector< double > > > f_graph
 Graph of residuals at each iteration. More...
 

Public Member Functions

 SOFA_CLASS (SOFA_TEMPLATE2(ShewchukPCGLinearSolver, TMatrix, TVector), SOFA_TEMPLATE2(sofa::component::linearsolver::MatrixLinearSolver, TMatrix, TVector))
 
void solve (Matrix &M, Vector &x, Vector &b) override
 
void init () override
 
void setSystemMBKMatrix (const core::MechanicalParams *mparams) override
 

Protected Member Functions

 ShewchukPCGLinearSolver ()
 
void cgstep_beta (Vector &p, Vector &r, double beta)
 
void cgstep_alpha (Vector &x, Vector &p, double alpha)
 
void handleEvent (sofa::core::objectmodel::Event *event) override
 
template<>
void cgstep_beta (Vector &p, Vector &r, double beta)
 
template<>
void cgstep_alpha (Vector &x, Vector &p, double alpha)
 
template<>
void cgstep_beta (Vector &p, Vector &r, double beta)
 
template<>
void cgstep_alpha (Vector &x, Vector &p, double alpha)
 

Attribute details

template<class TMatrix , class TVector >
Data<bool> sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::f_build_precond

Build the preconditioners, if false build the preconditioner only at the initial step.

template<class TMatrix , class TVector >
Data<std::map < std::string, sofa::helper::vector<double> > > sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::f_graph

Graph of residuals at each iteration.

template<class TMatrix , class TVector >
Data<unsigned> sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::f_maxIter

maximum number of iterations of the Conjugate Gradient solution

template<class TMatrix , class TVector >
Data< std::string > sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::f_preconditioners

If not empty: path to the solvers to use as preconditioners.

template<class TMatrix , class TVector >
Data<double> sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::f_tolerance

desired precision of the Conjugate Gradient Solution (ratio of current residual norm over initial residual norm)

template<class TMatrix , class TVector >
Data<unsigned> sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::f_update_step

Number of steps before the next refresh of precondtioners.

template<class TMatrix , class TVector >
Data<bool> sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::f_use_precond

Use preconditioner.

Constructor details

template<class TMatrix , class TVector >
sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::ShewchukPCGLinearSolver ( )
protected

Function details

template<class TMatrix , class TVector >
void sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::cgstep_alpha ( Vector x,
Vector p,
double  alpha 
)
inlineprotected

This method is separated from the rest to be able to use custom/optimized versions depending on the types of vectors. It computes: x += p*alpha, r -= q*alpha

template<class TMatrix , class TVector >
void sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::cgstep_beta ( Vector p,
Vector r,
double  beta 
)
inlineprotected

This method is separated from the rest to be able to use custom/optimized versions depending on the types of vectors. It computes: p = p*beta + r

template<class Matrix , class Vector >
void sofa::component::linearsolver::ShewchukPCGLinearSolver< Matrix, Vector >::handleEvent ( sofa::core::objectmodel::Event event)
overrideprotected
template<class TMatrix , class TVector >
void sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::init ( )
override
template<class TMatrix , class TVector >
void sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::setSystemMBKMatrix ( const core::MechanicalParams mparams)
override
template<class TMatrix , class TVector >
sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::SOFA_CLASS ( SOFA_TEMPLATE2(ShewchukPCGLinearSolver< TMatrix, TVector >, TMatrix, TVector)  ,
SOFA_TEMPLATE2(sofa::component::linearsolver::MatrixLinearSolver, TMatrix, TVector)   
)
template<class TMatrix , class TVector >
void sofa::component::linearsolver::ShewchukPCGLinearSolver< TMatrix, TVector >::solve ( Matrix M,
Vector x,
Vector b 
)
override