CEPS  24.01
Cardiac ElectroPhysiology Simulator
IonicSolver.hpp
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 #pragma once
32 
37 
44 {
45 
46 
47  public:
48 
51 
52  public:
53 
62  CepsString opts,
65  );
66 
68  ~IonicSolver ();
69 
70  // Interface with pde ==========================================================================
71 
74  void
76 
78  void
80 
82  void
84 
90  void
91  addDtv(DHVecPtr dtv, CepsReal t=0) const;
92 
95  void
96  fillPdeVm(DHVecPtr vPde) const;
97 
99  CepsReal
100  getVm(CepsBool convert) const;
101 
103  CepsReal*
104  getStates() const;
105 
107  CepsReal*
108  getDtv() const;
109 
111  CepsUInt
112  getNbMultiSteps() const;
113 
114  protected:
115 
118  void
120 
122  void
124 
126  void
128 
130  void
132 
134  void
136 
138  void
140 
141 
142  protected :
143 
147 
148  // Spatial discretization is needed to determine on which rows the ionic current will be added
150 
152 
153  // Data
159 
161 
162  // Ptr on ptr because we perform rotations between several arrays in multistep methods
164 
166 
168 
169 };
170 
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
std::vector< _Type, _Alloc > CepsVector
C++ vector.
Definition: CepsTypes.hpp:155
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
std::shared_ptr< DistributedHaloVector > DHVecPtr
Typedef for pointer on Distributed Halo CepsVector.
Abstract Class for all numerical method (FE, FD, FV etc)
Represents a ionic model for a group of cells, i.e. multiple systems of ODEs.
Solves ODE systems .
Groups two ODE solvers for ionic variables and interacts with cardiac problem.
Definition: IonicSolver.hpp:44
CepsUInt m_size
Number of dofs for this solver.
CepsReal * m_y
Values of state variables.
CepsVector< CepsIndex > m_localToGlobal
Mapping between local index of dof and index in PDE.
void computeModelRates(CepsReal t, CepsReal *y)
Computes the evolution function and ionic current on all dofs, calls the model.
CepsBool m_tauOk
Flag to avoid to compute tau and winf twice per iteration.
CepsReal * m_dtv
Total ionic current.
void fillPdeVm(DHVecPtr vPde) const
Fills the linked PDE vector for vm with current values of m_v. Can be used to get initial condition.
CepsUInt getNbMultiSteps() const
Number of multi steps of the inner solver.
AbstractIonicModel * m_model
Link to ionic model equations.
void computeRatesLin(CepsReal t, CepsReal *w, CepsReal *dtw, CepsUInt n)
Call the linear part of evolution function of the model.
void createSolvers(CepsString opts)
Instantiates ODE solvers from options.
~IonicSolver()
Destructor.
Definition: IonicSolver.cpp:71
CepsReal * m_v
Transmembrane voltage.
void addDtv(DHVecPtr dtv, CepsReal t=0) const
Fills the given distributed vector with values of ionic current from ODE system. Does the unit conver...
void takeOneSubStep(CepsReal t, CepsReal dt, DHVecPtr vPde)
Advance the ODE system by one sub step (for RK solvers)
CepsReal * m_dtyLin
Linear part of rates.
CepsReal * getStates() const
Get pointer on state vars for testing purposes.
DHVecPtr * m_vPde
Pointer on pointer with v data from the PDE.
CepsReal * getDtv() const
Get pointer on ionic current for testing purposes.
AbstractOdeSolver * m_solver
internal ODE solver
CepsReal * m_dtyNLin
Non-linear part of rates.
void takeOneStep(CepsReal t, CepsReal dt, DHVecPtr vPde)
Advance the ODE system by one full step each (not substep)
Definition: IonicSolver.cpp:96
void computeIndexMapping()
Sets the map from instance-local indices of points to global indices, then allocates arrays and sets ...
IonicSolver(CepsString opts, AbstractIonicModel *m, AbstractDiscretization *discr)
Constructor with parameters from input file and ionic model to be linked with The constructor also se...
Definition: IonicSolver.cpp:34
CepsReal getVm(CepsBool convert) const
Get TMV for testing purposes.
void setActionPotential(DHVecPtr vPde)
Copies values of TMV from PDE vector to local array. Call this method prior to takeOneStep or takeOne...
Definition: IonicSolver.cpp:86
EvolFunction * m_fNLin
Evolution function (non linear part winf/tau + others)
void initializeSolver()
Set the initial conditions and required intermediate arrays of the ODE solvers.
void computeRatesNonLin(CepsReal t, CepsReal *w, CepsReal *dtw, CepsUInt n)
Get the non linear part of evolution function of the model.
AbstractDiscretization * m_sDiscr
Link to spatial discretization.
EvolFunction * m_fLin
Evolution function (linear part -1/tau)
function caller : abstract base, only contains an variadic operator()