CEPS  24.01
Cardiac ElectroPhysiology Simulator
CLMonodomainProblem.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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
35 
36 
38  SolVecSAFunc(sol,loc)
39 {
40 }
41 
44 {
45  setArgsFromLocation(args);
46  return args.u;
47 }
48 
50  : MonodomainProblem(g,params)
51 {
52  setProblemName("Current Lifted Monodomain");
53 }
54 
55 void
57 {
58  if (ceps::isProfiling())
59  getProfiler()->start("whole","solving the whole PDE (FluxAnodeCathodeProblem + CLMonodomainProblem)");
60 
62 
63  // Solve the static problem
64 
66  // if (spb.getFunctionDictionary()->hasTensor("physCoeffSigma"))
67  // spb.getFunctionDictionary()->deleteTensor("physCoeffSigma");
68  spb.getFunctionDictionary()->add("sigma_i", m_sigmaIOptions);
69  spb.getFunctionDictionary()->add("sigma_e", m_sigmaEOptions);
70  spb.getFunctionDictionary()->add("physCoeffSigma", "OPERATOR sigma_i + sigma_e");
71  spb.setOutputFileBase(spb.getOutputFileBase() + "_static");
72  spb.initializeEquation();
73 
74  FluxAnodeCathodeSolver ssolver(&spb);
75  ssolver.solve();
76 
77  // not realy clean, but it's working
78  auto solCL = ssolver.getSolution();
79  getFunctionDictionary()->addEntry("ubar", ceps::getNew<Ufunc>(&solCL, CepsFunctionFlag::DofIndex));
80  getFunctionDictionary()->add("cl", "OPERATOR cl_stimulation * ubar");
81  CepsString sourceOptions = "cl cl UNKNOWN 0 TYPE KTERM ATTRIBUTES";
82  for (CepsAttribute attr: this->getTissueAttributes())
83  sourceOptions += " " + ceps::toString(attr);
84  getSourceTermManager()->add(sourceOptions,false);
85 
86  MonodomainSolver solver(this);
87  solver.solve();
88 
89  if (ceps::isProfiling())
90  getProfiler()->stop("whole");
91 }
92 
93 void
95 {
97 }
98 
99 
100 void
102 {
104 
105  CepsString stimOptions = m_parameters->getString("electrodes stimulation");
106  m_functions->addFunction("cl_stimulation", stimOptions);
107 }
CepsFunctionFlag
Enum for CepsStandardArgs functions.
Definition: CepsEnums.hpp:137
@ DofIndex
Use dof index to determine position.
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
CepsInt CepsAttribute
Used to define regions.
Definition: CepsTypes.hpp:215
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
std::shared_ptr< DistributedHaloVector > DHVecPtr
Typedef for pointer on Distributed Halo CepsVector.
void setProblemName(const CepsString &name)
Set the name of the problem.
CepsString getOutputFileBase() const
Output file name includes the directory.
FunctionDictionary * getFunctionDictionary() const
Get functions manager.
SourceTermManager * getSourceTermManager() const
Get boundary condition manager.
void addUnknown(const CepsString &label, CepsSet< CepsAttribute > attrs={}, CepsLocationFlag flag=CepsLocationFlag::Point, const CepsString &unit="")
Register a new unknown.
InputParameters * m_parameters
Input file data.
void setOutputFileBase(CepsString fileName)
Output file name includes the directory.
Geometry * m_geom
Link to geometry on which the pb is defined.
FunctionDictionary * m_functions
Collection of custom functions.
void initializeEquation() override
Initializes equations (unknowns, bc, source term) and creates the spatial discretization This method ...
DHVecPtr getSolution() const
Returns a copy of the distributed vector containing the current solution.
Ufunc(DHVecPtr *sol, CepsFunctionFlag loc)
Constructor.
CepsReal eval(CepsStandardArgs args) final
Returs f(u)=u.
void defineUnknowns() override
A single unknown for transmembrane voltage.
void run() override
Run the simulation.
void defineBoundaryConditions() override
For cardiac problems, use the "boundary stimulation" key to create boundary conditions using the same...
CLMonodomainProblem(Geometry *g, InputParameters *=nullptr)
Constructor with input strings and geometry.
void defineBoundaryConditions() override
For cardiac problems, use the "boundary stimulation" key to create boundary conditions using the same...
CepsString m_sigmaIOptions
Options for intracellular conductivity.
CepsString m_sigmaEOptions
Options for extracellulat conductivity.
CepsSet< CepsAttribute > m_tissueAttributes
Identifier for the tissue region, default {-1}.
const CepsSet< CepsAttribute > & getTissueAttributes() const
All attributes that localize tissue.
void initializeEquation() override
Initializes all the elements of the PDE from options.
void solve() override
Performs all iterations of the PDE solver.
Profiler * getProfiler() const
Access to profiler.
Definition: CepsObject.cpp:46
Poisson equation with Neumann 1 on anode, -1 on cathode. Neumann 0 elsewhere. Functional tensorial co...
Solver for a Poisson equation with Neumann BC (using 0 mean constraint)
void solve() override
Solve and postprocess.
void add(const CepsString &label, const CepsString &params, Geometry *geom=nullptr)
Add an object from parameters.
void addFunction(const CepsString &label, const CepsString &params)
Add a function deduced from tags only, works only with scalar return type.
void addEntry(const CepsString &label, ScalarEntry func)
Ads an entry to the map of scalar functions.
Encapsulates all the geometrical data.
Definition: Geometry.hpp:50
Reads and stores simulation configuration.
CepsString getString(const keyType &key) const
Reads a CepsString from configuration.
Defines and solve the monodomain problem, see models page of user doc.
Solves the monodomain problem with FBE, SBDF RK or CN schemes.
void stop(CepsString lbl)
Stops the measure of a labeled chronometer.
void start(CepsString lbl, CepsString dspl="")
Creates or continue a labeled chronometer.
A SAFunc which gets its values from a distributed vector of values on degrees of freedom.
void add(const CepsString &params, CepsBool computeSupport=false)
Add a source term from parameters.
CepsString toString(_Tp value)
Convert a given value to a string (input has to be compatible with std::to_string)
Definition: CepsString.hpp:409
CepsBool isProfiling()
Check if we are currently profiling on the master proc (always false on slave procs).
Definition: CepsFlags.cpp:257
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
CepsReal u
solution u
Definition: CepsTypes.hpp:242