CEPS  24.01
Cardiac ElectroPhysiology Simulator
CardiacProblem.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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
30 #pragma once
31 
34 
37 {
38  public:
39 
41  struct UnknownsName
42  {
44  static constexpr const char* vm = "Transmembrane voltage (mV)";
46  static constexpr const char* ue = "Extracellular potential (mV)";
47  };
48 
49  public:
50 
52  explicit CardiacProblem(Geometry* g, InputParameters* params = nullptr);
53 
55  ~CardiacProblem() override;
56 
57  // ---------------------------------------------------------------------------
58  // Common problem definition: homogeneous neumann boundary conditions (ie, do nothing)
59  // Initial transmembrane voltage from ionic models
60 
62  virtual CepsVector<Unknown*>
63  getTMVUnknowns() const = 0;
64 
66  virtual CepsVector<Unknown*>
67  getCardiacUnknowns() const = 0;
68 
70  void
71  getInitialCondition(DHVecPtr v) const override;
72 
75  getIonicModels() const;
76 
79  getAm() const;
80 
83  getCm() const;
84 
87  getSigmaI() const;
88 
91  getSigmaE() const;
92 
95  getTissueAttributes() const;
96 
98  void
99  initializeEquation() override;
100 
102  void
103  initializeCm();
104 
106  void
107  initializeAm();
108 
110  void
112 
114  // This is an overload with no argument, in case there is only a single conductivity
115  // same mesh cells
116  virtual void
118 
120  // Suffix must be provided and non empty if different conducitivity fields must be defined on the
121  // same mesh cells
122  virtual void
124  CepsString sigmaIOpts,
125  CepsString sigmaEOpts,
126  TensorField<GeomCell>*& sigmaI,
127  TensorField<GeomCell>*& sigmaE,
128  CepsString fiberOptions,
129  CepsString suffix=""
130  );
131 
133  virtual void
135 
138  void
139  defineBoundaryConditions() override;
140 
142  void
143  defineSourceTerms() override;
144 
145  protected:
146 
148  void
149  setupWithParameters(InputParameters* params) override;
150 
154  void
156  CepsString fiberOptions,
157  TensorField<GeomCell>*& sigmaI,
158  TensorField<GeomCell>*& sigmaE,
159  CepsString suffix=""
160  );
161 
163  class FiberAligner : public TensorSAFunc
164  {
165 
166  public:
167 
170  FiberAligner(
171  VectorSAFunc* fL,
172  VectorSAFunc* fT,
173  VectorSAFunc* fN,
174  TensorSAFunc* sT = nullptr,
175  VectorSAFunc* sV = nullptr
176  );
177 
180  eval(CepsStandardArgs args) override;
181 
183  CepsEnum
184  getFlags() const override;
185 
186  private:
187 
193 
194  };
195 
196 
197  protected:
198 
199  // ------------------------
200  // Input parameters
201 
213 
214  // ------------------------
215  // Tissue properties
216 
218 
221 
223 
227 
228 };
229 
230 
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
int CepsEnum
Enum type.
Definition: CepsTypes.hpp:216
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
Definition: CepsTypes.hpp:209
Eigen::Matrix< CepsScalar, 3, 3 > CepsMathTensor
Tensor, eigen format.
Definition: CepsTypes.hpp:137
std::vector< _Type, _Alloc > CepsVector
C++ vector.
Definition: CepsTypes.hpp:155
std::shared_ptr< DistributedHaloVector > DHVecPtr
Typedef for pointer on Distributed Halo CepsVector.
A functor that aligns conductivities along the fibers directions.
CepsEnum getFlags() const override
Combination of flags of all 3 arrays.
VectorSAFunc * m_fT
Pointer on dico function for transverse component of fibers.
VectorSAFunc * m_fL
Pointer on dico function for longitudinal component of fibers.
FiberAligner(VectorSAFunc *fL, VectorSAFunc *fT, VectorSAFunc *fN, TensorSAFunc *sT=nullptr, VectorSAFunc *sV=nullptr)
Constructor with a functor for each direction. Input conductivity can be either vector (diagonal) or ...
VectorSAFunc * m_sV
Pointer on dico function for diagonal reference conductivity.
VectorSAFunc * m_fN
Pointer on dico function for "normal" component of fibers.
TensorSAFunc * m_sT
Pointer on dico function for tensorial reference conductivity.
CepsMathTensor eval(CepsStandardArgs args) override
Get the full tensor.
A abstract class that regroups common parameters of cardiac problems.
virtual CepsVector< Unknown * > getCardiacUnknowns() const =0
Returns a vector containing all unknowns that are cardiac unknowns (eg. vm, ui or ue)
void defineBoundaryConditions() override
For cardiac problems, use the "boundary stimulation" key to create boundary conditions using the same...
void getInitialCondition(DHVecPtr v) const override
Zero + asks each ionic model to fill the parts of the Vm vector with its initial value.
ScalarField< DegreeOfFreedom > * m_Cm
Membrane capacitance, may depend on x and t.
CepsString m_fibersOptions
Options for fiber orientation.
CepsString m_bcStimOptions
Options for stimulation, on boundary.
~CardiacProblem() override
Destructor.
CepsString m_CmOptions
Options for membrance capacitance.
void initializeCm()
Sets the membrane conductivity from the input parameters.
CepsString m_AmOptions
Options for membrane surface.
CepsString m_volFracOptions
Options for volume fraction.
void initializeIonicModels()
Creates and assign ionic models to tissue regions from input string.
void initializeAm()
Set the surface of membrane from input parameters.
CepsString m_ionOptions
Options for ionic models.
TensorField< GeomCell > * getSigmaE() const
Link to extracellular conductivity.
CardiacProblem(Geometry *g, InputParameters *params=nullptr)
Constructor with input file and geometry.
virtual void initializeConductivities()
Generates the functors that compute conductivity either from inputs or volume fraction.
void setupWithParameters(InputParameters *params) override
Sets options from the parameters.
virtual void initializeStimulations()
Generates stimulations and links them to ionic models. Called within define source terms.
CepsString m_sigmaIOptions
Options for intracellular conductivity.
TensorField< GeomCell > * m_sigmaI
Intracellular conductivity, defined on cells.
void createFibersAndConductivities(CepsString fiberOptions, TensorField< GeomCell > *&sigmaI, TensorField< GeomCell > *&sigmaE, CepsString suffix="")
Creates the entries in the dictionary for each direction of fibers from file This is splitted from in...
CepsVector< AbstractIonicModel * > getIonicModels() const
Vector of all initd ionic models.
virtual CepsVector< Unknown * > getTMVUnknowns() const =0
Returns a vector containing all unknowns that are a TMV (especially useful for bilayer)
CepsString m_sigmaEOptions
Options for extracellulat conductivity.
CepsVector< AbstractIonicModel * > m_ionicModels
All ionic models defined on the tissue.
CepsSet< CepsAttribute > m_tissueAttributes
Identifier for the tissue region, default {-1}.
ScalarField< DegreeOfFreedom > * m_Am
Surface (cm2) of cell membrane per cm3 of myocardium.
ScalarField< GeomCell > * m_volFrac
Fraction of tissue made of valid myocytes.
const CepsSet< CepsAttribute > & getTissueAttributes() const
All attributes that localize tissue.
TensorField< GeomCell > * m_sigmaE
Extracellulat conductivity, defined on cells.
ScalarField< DegreeOfFreedom > * getCm() const
Link to Cm coefficient.
CepsString m_stimOptions
Options for stimulation.
CepsString m_volFracItpFileI
Options for volume fraction.
CepsString m_volFracItpFileE
Options for volume fraction.
void initializeEquation() override
Initializes all the elements of the PDE from options.
ScalarField< DegreeOfFreedom > * getAm() const
Link to Am coefficient.
TensorField< GeomCell > * getSigmaI() const
Link to intracellular conductivity.
void defineSourceTerms() override
For cardiac problem, only calls initializeStimulation. Can be overriden.
A Field is an object wrapped around a SAFunc functor, defined on at least one domain.
Definition: Field.hpp:80
Encapsulates all the geometrical data.
Definition: Geometry.hpp:50
Heat PDE, single unknown, constant diffusion coeff 1, homogeneous Neumann (no BC defined)
Definition: HeatProblem.hpp:36
Reads and stores simulation configuration.
A SAFunc is a ceps::Function that uses CepsStandardArgs as argument of call operator (),...
Definition: SAFunc.hpp:100
name of unknowns in a struct
static constexpr const char * ue
Extracellular and extracardiac potential.
static constexpr const char * vm
Transmembrane voltage.
Structure used to pass arguments to SAFunc (see pde directory) The flags of the SAFunc allows extract...
Definition: CepsTypes.hpp:239