CEPS  24.01
Cardiac ElectroPhysiology Simulator
ExtendedBidomainSolver.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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
32 
38 
40  BidomainSolver(problem)
41 {
42  if (ceps::isValidPtr(problem->getParameters()))
44 }
45 
46 void
48 {
49  // Scale current boundary condition
50 
51  auto pb = getExtendedBidomainProblem();
52 
53  if (pb->hasAnodalCathodalStimulation())
54  {
55  CEPS_SAYS("Anodal cathodal stimulation enabled");
56 
57  auto bcFE = m_fe->getBoundaryFiniteElements();
58  CepsReal anodeMeas = getDomainMeasure(bcFE, pb->getAnodeAttributes());
59  CepsReal cathodeMeas = getDomainMeasure(bcFE, pb->getCathodeAttributes());
60 
61  BoundaryConditionManager* bcManager = pb->getBoundaryConditionManager();
62 
63  bcManager->getNeumannBCs()->at("ANODE")->setScaleFactor(1. / anodeMeas);
64  CEPS_SAYS("Anode intensity divided by the electrode measure: " << anodeMeas);
65 
66  bcManager->getNeumannBCs()->at("CATHODE")->setScaleFactor(1. / cathodeMeas);
67  CEPS_SAYS("Cathode intensity divided by the electrode measure: " << cathodeMeas);
68  }
69 
70 }
71 
72 void
74 {
75  auto bepb = getExtendedBidomainProblem();
76 
77  if (bepb->requireNullMean())
78  {
79  // Lhs assembler cannot be a simple FEExtendedBidomainAssembler
80  // because the ue field is defined up to a constant. Here we use the
81  // actual lagragian unknown to enforce a null mean on ue
83 
84  LhsAssembler* opAsb = ceps::getNew<LhsAssembler>(bepb, m_fe);
85  opAsb->addLagrangian(m_problem->getUnknown("Lagrangian for extracellular potential"));
86 
87  m_opAsb = opAsb;
88  }
89  else
90  {
91  FEExtendedBidomainAssembler* opAsb = ceps::getNew<FEExtendedBidomainAssembler>(bepb,m_fe);
92 
93  m_opAsb = opAsb;
94  }
95  m_bcAsb = ceps::getNew<FECardiacBCAssembler>(bepb,CepsSet<CepsAttribute>({CepsUniversal}),m_fe);
96 }
97 
100 {
101  return ceps::runtimeCast<ExtendedBidomainProblem*>(m_problem);
102 }
#define CEPS_SAYS(message)
Writes a message in the debug log and in the terminal (stdio).
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
Definition: CepsTypes.hpp:209
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
constexpr CepsAttribute CepsUniversal
This attribute means "everywhere".
Definition: CepsTypes.hpp:232
CepsReal getDomainMeasure(const CepsVector< FEBase * > &cells, const CepsSet< CepsAttribute > &attributes, CepsBool onlyOfThisProc)
Compute the measure of a set of a cells.
InputParameters * getParameters() const
Text parameters.
Unknown * getUnknown(const CepsString &label) const
Get an unknown by its name.
AbstractAssembler * m_bcAsb
Assembler for Robin and Neumann BCs.
AbstractAssembler * m_opAsb
Assembler for the operator matrix.
AbstractPdeProblem * m_problem
Link to PDE to solve.
Solves bidomain problem with FBE, SBDF RK or CN schemes.
Boundary condition to manage Dirichlet, Neumann and Robin conditions.
Manager * getNeumannBCs() const
Get the manager for Neumann conditions of dim.
Bidomain equation with extracardiac medium main class.
ExtendedBidomainSolver(ExtendedBidomainProblem *problem)
Constructor from problem.
void initializeAssemblers() override
Sets the assemblers.
ExtendedBidomainProblem * getExtendedBidomainProblem() const
Converts own pointer to abstract pde problem to cardiac problem.
void setupWithParameters(InputParameters *params) override
Set attributes from input file. Parameters are passed as arguments in case one wants to use other par...
Linear system builder for the bidomain extended equation.
A class that adds a 0 mean constraint to an already existing assembler.
FiniteElements * m_fe
Geometry and reference FE.
CepsVector< FEBase * > & getBoundaryFiniteElements()
Get vector containing all finite elements of the maximum valid dim.
Reads and stores simulation configuration.
CepsBool isValidPtr(_Type *ptr)
Tells if pointer is not null.
Definition: CepsMemory.hpp:61