SOFA API  b0896a42
Open source framework for multi-physics simuation
sofa::component::linearsolver::iterative::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::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >:

Detailed Description

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

Linear system solver using the conjugate gradient iterative algorithm.

Public Attributes

sofa::core::objectmodel::RenamedData< unsigned > f_maxIter
 
sofa::core::objectmodel::RenamedData< double > f_tolerance
 
sofa::core::objectmodel::RenamedData< boolf_use_precond
 
sofa::core::objectmodel::RenamedData< unsigned > f_update_step
 
sofa::core::objectmodel::RenamedData< boolf_build_precond
 
sofa::core::objectmodel::RenamedData< std::map< std::string, sofa::type::vector< double > > > f_graph
 
Data< unsigned > d_maxIter
 Maximum number of iterations after which the iterative descent of the Conjugate Gradient must stop. More...
 
Data< double > d_tolerance
 Desired accuracy of the Conjugate Gradient solution evaluating: |r|²/|b|² (ratio of current residual norm over initial residual norm) More...
 
Data< boold_use_precond
 Use a preconditioner. More...
 
SingleLink< ShewchukPCGLinearSolver, sofa::core::behavior::LinearSolver, BaseLink::FLAG_STOREPATH|BaseLink::FLAG_STRONGLINKl_preconditioner
 Link towards the linear solver used to precondition the conjugate gradient. More...
 
Data< unsigned > d_update_step
 Number of steps before the next refresh of precondtioners. More...
 
Data< boold_build_precond
 Build the preconditioners, if false build the preconditioner only at the initial step. More...
 
Data< std::map< std::string, sofa::type::vector< double > > > d_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
 
- Public Member Functions inherited from sofa::component::linearsolver::MatrixLinearSolver< TMatrix, TVector >
void resetSystem ()
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API void resetSystem ()
 
void resizeSystem (Size n)
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API void resizeSystem (Size)
 
void setSystemMBKMatrix (const core::MechanicalParams *mparams)
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API void setSystemMBKMatrix (const core::MechanicalParams *mparams)
 
void rebuildSystem (SReal, SReal)
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API void rebuildSystem (SReal massFactor, SReal forceFactor)
 
void setSystemLHVector (core::MultiVecDerivId v)
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API void setSystemLHVector (core::MultiVecDerivId v)
 
void applySystemSolution ()
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API void applySystemSolution ()
 
void applyConstraintForce (const sofa::core::ConstraintParams *, sofa::core::MultiVecDerivId, const linearalgebra::BaseVector *)
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API void applyConstraintForce (const sofa::core::ConstraintParams *, sofa::core::MultiVecDerivId, const linearalgebra::BaseVector *)
 
void computeResidual (const core::ExecParams *, linearalgebra::BaseVector *)
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API void computeResidual (const core::ExecParams *params, linearalgebra::BaseVector *f)
 
GraphScatteredVectorcreatePersistentVector ()
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API GraphScatteredVectorcreatePersistentVector ()
 
linearalgebra::BaseMatrixgetSystemBaseMatrix ()
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API linearalgebra::BaseMatrixgetSystemBaseMatrix ()
 
linearalgebra::BaseVectorgetSystemRHBaseVector ()
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API linearalgebra::BaseVectorgetSystemRHBaseVector ()
 
linearalgebra::BaseVectorgetSystemLHBaseVector ()
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API linearalgebra::BaseVectorgetSystemLHBaseVector ()
 
void checkLinearSystem ()
 
SOFA_COMPONENT_LINEARSOLVER_ITERATIVE_API void checkLinearSystem ()
 
bool addJMInvJtLocal (GraphScatteredMatrix *M, MatrixLinearSolver< GraphScatteredMatrix, GraphScatteredVector, NoThreadManager >::ResMatrixType *result, const MatrixLinearSolver< GraphScatteredMatrix, GraphScatteredVector, NoThreadManager >::JMatrixType *J, const SReal fact)
 

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
 
void cgstep_beta (Vector &p, Vector &r, double beta)
 
void cgstep_alpha (Vector &x, Vector &p, double alpha)
 
void cgstep_beta (Vector &p, Vector &r, double beta)
 
void cgstep_alpha (Vector &x, Vector &p, double alpha)
 

Attribute details

◆ d_build_precond

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

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

◆ d_graph

template<class TMatrix , class TVector >
Data<std::map < std::string, sofa::type::vector<double> > > sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::d_graph

Graph of residuals at each iteration.

◆ d_maxIter

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

Maximum number of iterations after which the iterative descent of the Conjugate Gradient must stop.

◆ d_tolerance

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

Desired accuracy of the Conjugate Gradient solution evaluating: |r|²/|b|² (ratio of current residual norm over initial residual norm)

◆ d_update_step

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

Number of steps before the next refresh of precondtioners.

◆ d_use_precond

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

Use a preconditioner.

◆ f_build_precond

template<class TMatrix , class TVector >
sofa::core::objectmodel::RenamedData<bool> sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::f_build_precond

◆ f_graph

template<class TMatrix , class TVector >
sofa::core::objectmodel::RenamedData<std::map < std::string, sofa::type::vector<double> > > sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::f_graph

◆ f_maxIter

template<class TMatrix , class TVector >
sofa::core::objectmodel::RenamedData<unsigned> sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::f_maxIter

◆ f_tolerance

template<class TMatrix , class TVector >
sofa::core::objectmodel::RenamedData<double> sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::f_tolerance

◆ f_update_step

template<class TMatrix , class TVector >
sofa::core::objectmodel::RenamedData<unsigned> sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::f_update_step

◆ f_use_precond

template<class TMatrix , class TVector >
sofa::core::objectmodel::RenamedData<bool> sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::f_use_precond

◆ l_preconditioner

Link towards the linear solver used to precondition the conjugate gradient.

Constructor details

◆ ShewchukPCGLinearSolver()

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

Function details

◆ cgstep_alpha() [1/3]

template<class TMatrix , class TVector >
void sofa::component::linearsolver::iterative::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

◆ cgstep_alpha() [2/3]

◆ cgstep_alpha() [3/3]

◆ cgstep_beta() [1/3]

template<class TMatrix , class TVector >
void sofa::component::linearsolver::iterative::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

◆ cgstep_beta() [2/3]

◆ cgstep_beta() [3/3]

◆ handleEvent()

template<class Matrix , class Vector >
void sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< Matrix, Vector >::handleEvent ( sofa::core::objectmodel::Event event)
overrideprotected

◆ init()

template<class TMatrix , class TVector >
void sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::init ( void  )
override

◆ setSystemMBKMatrix()

template<class TMatrix , class TVector >
void sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::setSystemMBKMatrix ( const core::MechanicalParams mparams)
override

◆ SOFA_CLASS()

template<class TMatrix , class TVector >
sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::SOFA_CLASS ( SOFA_TEMPLATE2(ShewchukPCGLinearSolver< TMatrix, TVector >, TMatrix, TVector)  ,
SOFA_TEMPLATE2(sofa::component::linearsolver::MatrixLinearSolver, TMatrix, TVector)   
)

◆ solve()

template<class TMatrix , class TVector >
void sofa::component::linearsolver::iterative::ShewchukPCGLinearSolver< TMatrix, TVector >::solve ( Matrix M,
Vector x,
Vector b 
)
override