Caribou
Public Member Functions | List of all members
SofaCaribou::solver::LinearSolver Class Referenceabstract

Detailed Description

Base interface for linear solvers.

This interface define the generic API that linear solvers in Caribou must provide.

#include <LinearSolver.h>

Inheritance diagram for SofaCaribou::solver::LinearSolver:
SofaCaribou::solver::EigenSparseSolver< EigenSolver > SofaCaribou::solver::ConjugateGradientSolver SofaCaribou::solver::EigenSparseSolver< EigenSolver_t > SofaCaribou::solver::CaribouLDLTSolver< EigenSolver > SofaCaribou::solver::LDLTSolver< EigenSolver > SofaCaribou::solver::LLTSolver< EigenSolver > SofaCaribou::solver::LUSolver< EigenSolver >

Public Member Functions

virtual sofa::defaulttype::BaseMatrix * create_new_matrix (unsigned int rows, unsigned int cols) const =0
 Creates a new BaseMatrix of size rows x cols. More...
 
virtual sofa::defaulttype::BaseVector * create_new_vector (unsigned int n) const =0
 Creates a new BaseVector of size n. More...
 
virtual bool solve (const sofa::defaulttype::BaseMatrix *A, const sofa::defaulttype::BaseVector *F, sofa::defaulttype::BaseVector *X) const =0
 Solve the linear system A [X] = F. More...
 

Member Function Documentation

◆ create_new_matrix()

virtual sofa::defaulttype::BaseMatrix* SofaCaribou::solver::LinearSolver::create_new_matrix ( unsigned int  rows,
unsigned int  cols 
) const
pure virtual

Creates a new BaseMatrix of size rows x cols.

This will be used by the ODE to create system matrices (A = mM + bB + kK). Since it is up to the linear solver to use its matrix format (sparse, full, block, etc.), it must have an API to allow other components to create a compatible matrix that will later be used by this same linear solver.

Parameters
rowsNumber of rows of the matrix.
colsNumber of columns of the matrix.
Returns
A pointer to the newly created matrix.
Note
Important: The caller of this function (for example, the ODE component) is responsible to free the memory of this newly created matrix.

◆ create_new_vector()

virtual sofa::defaulttype::BaseVector* SofaCaribou::solver::LinearSolver::create_new_vector ( unsigned int  n) const
pure virtual

Creates a new BaseVector of size n.

This will be used by the ODE to create system vectors (both the left-hand side solution vector, and the right- hand side force vector). Since it is up to the linear solver to use its vector format (sparse, full, block, etc.), it must have an API to allow other components to create a compatible vector that will later be used by this same linear solver.

Parameters
nThe number of scalar stored inside this vector.
Returns
A pointer to the newly created vector
Note
Important: The caller of this function (for example, the ODE component) is responsible to free the memory of this newly created vector.

◆ solve()

virtual bool SofaCaribou::solver::LinearSolver::solve ( const sofa::defaulttype::BaseMatrix *  A,
const sofa::defaulttype::BaseVector *  F,
sofa::defaulttype::BaseVector *  X 
) const
pure virtual

Solve the linear system A [X] = F.

Parameters
AThe assembled system matrix.
FThe right-hand side (RHS) vector.
XThe left-hand side (LHS) solution vector.
Returns
True when the system has been successfully solved, false otherwise.
Note
The system matrix and vectors are guaranteed to be of the same virtual type as the one returned by create_new_matrix() and create_new_vector, respectively, since it is these methods that created them in the first place.

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