SOFA API  1a4bb3e7
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

Data< unsigned > f_maxIter
 maximum number of iterations of the Conjugate Gradient solution More...
 
Data< double > f_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...
 
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 > 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::map< std::string, sofa::type::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
 
- 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

◆ f_build_precond

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

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

◆ f_graph

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

Graph of residuals at each iteration.

◆ f_maxIter

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

maximum number of iterations of the Conjugate Gradient solution

◆ f_tolerance

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

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

◆ f_update_step

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

Number of steps before the next refresh of precondtioners.

◆ f_use_precond

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

Use preconditioner.

◆ 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