# ShewchukPCGLinearSolver

This component belongs to the category of LinearSolver, it therefore aims at solving the linear system . The ShewchukPCGLinearSolver is an iterative solver using the conjugate gardient method as implemented in the CGLinearSolver in SOFA but it adds the possibility to define a preconditioner. It must be reminded that the ShewchukPCGLinearSolver is relies on the conjugate gradient method, meaning that as all iterative approaches, no exact solution can be found. The accuracy of your solution will always depend on the conditioning of your system and your input data (iterations, tolerance and threshold).

Preconditioners are used in cases where the convergence of the system is slow, which is usually due to a ill-conditioned system (high condition number). In order to preserve accuracy, while improving performance, preconditioning methods aims at projecting a matrix (preconditioner) on the linear system , in order to get closer to the solution. The efficiency of the preconditioner will depend on the choice of the preconditioner .

The ShewchukPCGLinearSolver allows to choose the preconditioner of our choice based on an external direct linear solver: LULinearSolver, SparseLDLSolver, etc. These solvers will allow to compute and use it to compute at each iteration *k* of the conjugate gradient:

Using an appropriate preconditioner of a matrix means that has a smaller condition number than .

## Data

This LinearSolver is ruled by several breaking conditions:

**iterations**: specified the maximum number of iterations after which the iterative descent of the conjugat gradient must stop**tolerance**: defines the desired accuracy of the Conjugate Gradient solution (ratio of current residual norm over initial residual norm)"**preconditioners**: name of the linear solvers to be used as preconditioner**update_step**: number of steps before the next refresh of precondtioners**build_precond**: if false build the preconditioner only at the initial step, else building the preconditioner every*update_step*

## Usage

The ShewchukPCGLinearSolver **requires**:

- the use (above in the scene graph) of an integration scheme
- (below in the scene graph) of a MechanicalObject storing the state information that the ShewchukPCGLinearSolver will access
- and, if a preconditioning is desired, a linear solver to compute the

As for the CGLinearSolver, when using a ShewchukPCGLinearSolver, make sure you carefully chose the value of the free data field iterations, tolerance and threshold. Both tolerance and threshold data must be chosen in accordance with the dimension of the degrees of freedom (DOFs). Usually, the value of these two data is close to the square of the expected error on the DOFs.

## Example

This component is used as follows in XML format:

or using SofaPython3:

An example scene involving a ShewchukPCGLinearSolver is available in *examples/Components/solver/ShewchukPCGLinearSolver.scn*

Last modified: 13 July 2021