CEPS  24.01
Cardiac ElectroPhysiology Simulator
LinearSystem Class Reference

Detailed Description

Linear system Ax=b to be solved.

Store and solve a linear equation of the form Ax = b, where A is a square matrix, b and x are column vectors. Underlying implementation depends on compilation options. For now, only PETSc KSP is supported.

Definition at line 52 of file LinearSystem.hpp.

#include <LinearSystem.hpp>

Inheritance diagram for LinearSystem:
[legend]

Public Member Functions

 LinearSystem ()
 Default constructor. More...
 
 LinearSystem (InputParameters *params)
 Constructor with inputs from strings (file) More...
 
 ~LinearSystem () override
 Destructor. More...
 
void setupWithParameters (InputParameters *params)
 Sets the options from text parameters. More...
 
virtual void solve (DVecPtr solution)
 Solve current linear system. Calls the solver's method. More...
 
void setLhsMatrix (DMatPtr lhs)
 Set the left-hand side matrix of the system. More...
 
void setPreconditioningMatrix (DMatPtr preconditioningMatrix)
 Sets the preconditioning matrix. If nullptr (default) LHS is used as preconditionner. More...
 
void setRhsVector (DVecPtr rhs)
 Set the right hand side. More...
 
void setType (const CepsString &type)
 Set solver type which can be CG, GMRES or LU. (LU for sequential runs only) More...
 
CepsSolver & getSolver ()
 Underlying solver. More...
 
DMatPtr getLhsMatrix ()
 Left hand side. More...
 
DVecPtr getRhsVector ()
 Right hand side. More...
 
void setTolerances (CepsReal rTol, CepsReal aTol, CepsReal dTol, CepsUInt iter)
 Sets all stopping criteria of iterative methods at once. More...
 
void setMaxNbIterations (CepsUInt nbIterations)
 Stopping criterion for iterative solvers. More...
 
void setRelativeTolerance (CepsReal rTol)
 Stopping criterion for iterative solvers: relative norm of residuals. More...
 
void setAbsoluteTolerance (CepsReal aTol)
 Stopping criterion for iterative solvers: absolute norm of residuals. More...
 
void setDivergenceTolerance (CepsReal dTol)
 Stopping criterion for iterative solvers: increase in norm of residuals. More...
 
CepsReal getRelativeTolerance () const
 Stopping criterion for iterative solvers: relative norm of residuals. More...
 
CepsReal getAbsoluteTolerance () const
 Stopping criterion for iterative solvers: absolute norm of residuals. More...
 
CepsReal getDivergenceTolerance () const
 Stopping criterion for iterative solvers: increase in norm of residuals. More...
 
CepsUInt getMaxNbIterations () const
 Stopping criterion for iterative solvers. More...
 
- Public Member Functions inherited from CepsObject
 CepsObject ()=default
 default constructor More...
 
 CepsObject (const CepsObject &)=default
 Copy constructor. More...
 
virtual ~CepsObject ()=default
 Destructor. More...
 
CepsObjectoperator= (const CepsObject &)=default
 Assignment operator. More...
 
CepsObjecttoBaseObject ()
 Returns a pointer to CepsObject class. More...
 
const CepsObjecttoBaseObject () const
 Returns a pointer to CepsObject class, const version. More...
 
ProfilergetProfiler () const
 Access to profiler. More...
 

Protected Attributes

CepsSolver m_solver
 Underlying solver. More...
 
DMatPtr m_lhsMatrix
 Left Hand Side (A) More...
 
DVecPtr m_rhsVector
 Right Hand Side (B) More...
 
DMatPtr m_precondMatrix
 Preconditioning matrix. More...
 
CepsReal m_absoluteTolerance
 Stopping criterion for iterative methods (abs diff between iterations) More...
 
CepsReal m_relativeTolerance
 Stopping criterion for iterative methods (rel diff between iterations) More...
 
CepsReal m_divergenceTolerance
 Stopping criterion for iterative methods (too large diff between iterations) More...
 
CepsUInt m_maxIterations
 Maximum of iterations for iterative methods. More...
 
CepsBool m_isSetUp
 Is the solver ready to solve ? More...
 
CepsUInt m_avIterNb
 average number of iterations More...
 
CepsUInt m_nSolv
 number of calls of the solvers More...
 

Private Member Functions

void initialize ()
 Sets the defaults values. More...
 
void setUp ()
 Calls methods of Linear Algebra library in order to prepare the solver. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from CepsObject
static Profiler m_profiler
 The same profiler for each big object. More...
 

Constructor & Destructor Documentation

◆ LinearSystem() [1/2]

LinearSystem::LinearSystem ( )

Default constructor.

Definition at line 32 of file PETScKSP.cpp.

◆ LinearSystem() [2/2]

LinearSystem::LinearSystem ( InputParameters params)
explicit

Constructor with inputs from strings (file)

Definition at line 37 of file PETScKSP.cpp.

◆ ~LinearSystem()

LinearSystem::~LinearSystem ( )
override

Destructor.

Definition at line 45 of file PETScKSP.cpp.

Member Function Documentation

◆ getAbsoluteTolerance()

CepsReal LinearSystem::getAbsoluteTolerance ( ) const

Stopping criterion for iterative solvers: absolute norm of residuals.

Definition at line 73 of file LinearSystem.cpp.

◆ getDivergenceTolerance()

CepsReal LinearSystem::getDivergenceTolerance ( ) const

Stopping criterion for iterative solvers: increase in norm of residuals.

Definition at line 79 of file LinearSystem.cpp.

◆ getLhsMatrix()

DMatPtr LinearSystem::getLhsMatrix ( )

Left hand side.

Definition at line 55 of file LinearSystem.cpp.

◆ getMaxNbIterations()

CepsUInt LinearSystem::getMaxNbIterations ( ) const

Stopping criterion for iterative solvers.

Definition at line 258 of file PETScKSP.cpp.

◆ getRelativeTolerance()

CepsReal LinearSystem::getRelativeTolerance ( ) const

Stopping criterion for iterative solvers: relative norm of residuals.

Definition at line 67 of file LinearSystem.cpp.

◆ getRhsVector()

DVecPtr LinearSystem::getRhsVector ( )

Right hand side.

Definition at line 61 of file LinearSystem.cpp.

◆ getSolver()

CepsSolver & LinearSystem::getSolver ( )

Underlying solver.

Definition at line 49 of file LinearSystem.cpp.

◆ initialize()

void LinearSystem::initialize ( )
private

Sets the defaults values.

Definition at line 264 of file PETScKSP.cpp.

◆ setAbsoluteTolerance()

void LinearSystem::setAbsoluteTolerance ( CepsReal  aTol)

Stopping criterion for iterative solvers: absolute norm of residuals.

Definition at line 238 of file PETScKSP.cpp.

◆ setDivergenceTolerance()

void LinearSystem::setDivergenceTolerance ( CepsReal  dTol)

Stopping criterion for iterative solvers: increase in norm of residuals.

Definition at line 248 of file PETScKSP.cpp.

◆ setLhsMatrix()

void LinearSystem::setLhsMatrix ( DMatPtr  lhs)

Set the left-hand side matrix of the system.

Definition at line 123 of file PETScKSP.cpp.

◆ setMaxNbIterations()

void LinearSystem::setMaxNbIterations ( CepsUInt  nbIterations)

Stopping criterion for iterative solvers.

Definition at line 216 of file PETScKSP.cpp.

◆ setPreconditioningMatrix()

void LinearSystem::setPreconditioningMatrix ( DMatPtr  preconditioningMatrix)

Sets the preconditioning matrix. If nullptr (default) LHS is used as preconditionner.

Definition at line 133 of file PETScKSP.cpp.

◆ setRelativeTolerance()

void LinearSystem::setRelativeTolerance ( CepsReal  rTol)

Stopping criterion for iterative solvers: relative norm of residuals.

Definition at line 228 of file PETScKSP.cpp.

◆ setRhsVector()

void LinearSystem::setRhsVector ( DVecPtr  rhs)

Set the right hand side.

Definition at line 141 of file PETScKSP.cpp.

◆ setTolerances()

void LinearSystem::setTolerances ( CepsReal  rTol,
CepsReal  aTol,
CepsReal  dTol,
CepsUInt  iter 
)

Sets all stopping criteria of iterative methods at once.

Parameters
[in]rTolrelative difference to reach between iterations
[in]aTolabsolute difference to reach between iterations
[in]dToldivergence between iterations
[in]itermaximum number of iterations

Definition at line 206 of file PETScKSP.cpp.

◆ setType()

void LinearSystem::setType ( const CepsString type)

Set solver type which can be CG, GMRES or LU. (LU for sequential runs only)

Definition at line 149 of file PETScKSP.cpp.

◆ setUp()

void LinearSystem::setUp ( )
private

Calls methods of Linear Algebra library in order to prepare the solver.

Definition at line 191 of file PETScKSP.cpp.

◆ setupWithParameters()

void LinearSystem::setupWithParameters ( InputParameters params)

Sets the options from text parameters.

Definition at line 38 of file LinearSystem.cpp.

◆ solve()

void LinearSystem::solve ( DVecPtr  solution)
virtual

Solve current linear system. Calls the solver's method.

PETSc implementation: This method is just a simple wrapper. Users familiar with PETSc should be able to do whatever they want by using the PETSc KSP object returned by LinearSystem::getSolver(...)

Parameters
[out]solutionpointer to the DistributedVector that will hold the solution

Definition at line 54 of file PETScKSP.cpp.

Field Documentation

◆ m_absoluteTolerance

CepsReal LinearSystem::m_absoluteTolerance
protected

Stopping criterion for iterative methods (abs diff between iterations)

Definition at line 168 of file LinearSystem.hpp.

◆ m_avIterNb

CepsUInt LinearSystem::m_avIterNb
protected

average number of iterations

Definition at line 175 of file LinearSystem.hpp.

◆ m_divergenceTolerance

CepsReal LinearSystem::m_divergenceTolerance
protected

Stopping criterion for iterative methods (too large diff between iterations)

Definition at line 170 of file LinearSystem.hpp.

◆ m_isSetUp

CepsBool LinearSystem::m_isSetUp
protected

Is the solver ready to solve ?

Definition at line 173 of file LinearSystem.hpp.

◆ m_lhsMatrix

DMatPtr LinearSystem::m_lhsMatrix
protected

Left Hand Side (A)

Definition at line 164 of file LinearSystem.hpp.

◆ m_maxIterations

CepsUInt LinearSystem::m_maxIterations
protected

Maximum of iterations for iterative methods.

Definition at line 171 of file LinearSystem.hpp.

◆ m_nSolv

CepsUInt LinearSystem::m_nSolv
protected

number of calls of the solvers

Definition at line 176 of file LinearSystem.hpp.

◆ m_precondMatrix

DMatPtr LinearSystem::m_precondMatrix
protected

Preconditioning matrix.

Definition at line 166 of file LinearSystem.hpp.

◆ m_relativeTolerance

CepsReal LinearSystem::m_relativeTolerance
protected

Stopping criterion for iterative methods (rel diff between iterations)

Definition at line 169 of file LinearSystem.hpp.

◆ m_rhsVector

DVecPtr LinearSystem::m_rhsVector
protected

Right Hand Side (B)

Definition at line 165 of file LinearSystem.hpp.

◆ m_solver

CepsSolver LinearSystem::m_solver
protected

Underlying solver.

Definition at line 163 of file LinearSystem.hpp.


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