CEPS  24.01
Cardiac ElectroPhysiology Simulator
LinearSystem.cpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
31 
32 #ifdef CEPS_USE_PETSC
33 // wrapper
35 #endif // CEPS_USE_PETSC
36 
37 void
39 {
40  // Setup the Linear Solver properties
41  setType(params->getString("linear solver type", "GMRES"));
42  setTolerances(params->getReal("linear solver relative tolerance" ,m_relativeTolerance),
43  params->getReal("linear solver absolute tolerance" ,m_absoluteTolerance),
44  params->getReal("linear solver divergence tolerance",m_divergenceTolerance),
45  params->getInt ("linear solver max iterations" ,m_maxIterations));
46 }
47 
48 CepsSolver&
50 {
51  return m_solver;
52 }
53 
54 DMatPtr
56 {
57  return m_lhsMatrix;
58 }
59 
60 DVecPtr
62 {
63  return m_rhsVector;
64 }
65 
68 {
69  return m_relativeTolerance;
70 }
71 
74 {
75  return m_absoluteTolerance;
76 }
77 
80 {
81  return m_divergenceTolerance;
82 }
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
std::shared_ptr< DistributedMatrix > DMatPtr
Short typedef for pointer on dist matrix.
std::shared_ptr< DistributedVector > DVecPtr
Short typedef for pointer on distributed vector.
Reads and stores simulation configuration.
CepsInt getInt(const keyType &key) const
Reads an integer value from configuration.
CepsString getString(const keyType &key) const
Reads a CepsString from configuration.
CepsReal getReal(const keyType &key) const
Reads a floating point value from configuration.
CepsReal m_relativeTolerance
Stopping criterion for iterative methods (rel diff between iterations)
void setTolerances(CepsReal rTol, CepsReal aTol, CepsReal dTol, CepsUInt iter)
Sets all stopping criteria of iterative methods at once.
Definition: PETScKSP.cpp:206
DVecPtr getRhsVector()
Right hand side.
void setupWithParameters(InputParameters *params)
Sets the options from text parameters.
CepsSolver & getSolver()
Underlying solver.
DVecPtr m_rhsVector
Right Hand Side (B)
DMatPtr m_lhsMatrix
Left Hand Side (A)
CepsReal getAbsoluteTolerance() const
Stopping criterion for iterative solvers: absolute norm of residuals.
CepsReal m_divergenceTolerance
Stopping criterion for iterative methods (too large diff between iterations)
CepsReal getRelativeTolerance() const
Stopping criterion for iterative solvers: relative norm of residuals.
CepsUInt m_maxIterations
Maximum of iterations for iterative methods.
CepsReal m_absoluteTolerance
Stopping criterion for iterative methods (abs diff between iterations)
CepsSolver m_solver
Underlying solver.
CepsReal getDivergenceTolerance() const
Stopping criterion for iterative solvers: increase in norm of residuals.
void setType(const CepsString &type)
Set solver type which can be CG, GMRES or LU. (LU for sequential runs only)
Definition: PETScKSP.cpp:149
DMatPtr getLhsMatrix()
Left hand side.