CEPS  24.01
Cardiac ElectroPhysiology Simulator
DirichletAnodeCathodeProblem.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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
33 
35  LaplacianProblem (g,p),
37  m_sigmaOpts ("CONSTANT 1. 0. 0. 0. 1. 0. 0. 0. 1.")
38 {
39  setProblemName("Basic Anode Cathode");
40 
42 
43  // Set conductivity
44  m_functions->add("physCoeffSigma",m_sigmaOpts,m_geom);
45 
46 }
47 
49 {
50 }
51 
52 void
54 {
55  m_sigmaOpts = m_parameters->getString("conductivity",m_sigmaOpts);
56  return;
57 }
58 
59 void
61 {
62  // A single spatial unknown defined everywhere
63  addUnknown("u");
64 }
65 
66 void
68 {
69 }
70 
71 void
73 {
74  m_functions->addConstant("zerofunc",0.);
75  m_functions->addConstant("onefunc",1.);
76 
77  std::stringstream ssa,ssc;
79  ssa << a << " ";
81  ssc << a << " ";
82 
83  m_boundaryConditions->add(CepsString("dirichletAnode DIRICHLET onefunc ")
84  + "UNKNOWN 0 ATTRIBUTES " + ssa.str());
85  m_boundaryConditions->add(CepsString("dirichletCathode DIRICHLET zerofunc ")
86  + "UNKNOWN 0 ATTRIBUTES " + ssc.str());
87 }
88 
91 {
92  return m_functions->getTensor("physCoeffSigma");
93 }
94 
95 void
97 {
99 }
100 
101 void
103 {
104 
105  if (ceps::isProfiling())
106  getProfiler()->start("whole","solving the whole PDE");
107 
109 
110  DirichletAnodeCathodeSolver solver(this);
111 
112  solver.solve();
113 
114  if (hasAnalyticSolution())
115  m_errors = solver.getErrors();
116 
117  if (ceps::isProfiling())
118  getProfiler()->stop("whole");
119 
120 }
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
CepsInt CepsAttribute
Used to define regions.
Definition: CepsTypes.hpp:215
CepsBool hasAnalyticSolution() const
Tells if there is an analytic or reference solution.
void setProblemName(const CepsString &name)
Set the name of the problem.
virtual void defineAnalyticSolution()
Set directly the analytic function, default sets no solution, unless there is a collection of referen...
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.
Geometry * m_geom
Link to geometry on which the pb is defined.
BoundaryConditionManager * m_boundaryConditions
All BCs should be there.
FunctionDictionary * m_functions
Collection of custom functions.
void initializeEquation() override
Initializes equations (unknowns, bc, source term) and creates the spatial discretization This method ...
CepsArray2< CepsArray3< CepsReal > > m_errors
Will store Linf, L1 and L2 relative errors.
void solve() override
Solves the whole PDE in time.
CepsArray2< CepsArray3< CepsReal > > getErrors() const
Gets the currently computed errors. First index selects absolute(0) orrelative(1) second index is L-i...
void add(const CepsString &params)
Add a boundary condition term from parameters.
Profiler * getProfiler() const
Access to profiler.
Definition: CepsObject.cpp:46
DirichletAnodeCathodeProblem(Geometry *g, InputParameters *p=nullptr)
Constructor from geometry and optional input file.
void run() override
Run does nothing. The tests call directly a LaplacianSolver solve method.
TensorSAFunc * getDiffusionTensor() const
Diffusion tensor.
~DirichletAnodeCathodeProblem() override
Destructor.
void defineAnalyticSolution() override
No analytic solution.
void setupWithParameters(InputParameters *p) override
Sets the diffusion tensor.
CepsString m_sigmaOpts
Text input for conductivity.
void defineSourceTerms() override
No source term.
void defineUnknowns() override
Lists the unknowns of the problem (one here)
void defineBoundaryConditions() override
Dirichlet 1/0 on electrodes, neumann 0 elsewhere.
DirichletAnodeCathode solver with custom stiffness tensor.
Base class for electrode objects. This one just holds attributes and size, and has very few options.
void addConstant(const CepsString &label, const CepsString &params)
Add a constant function through parameter string.
const TensorEntry getTensor(const CepsString &label) const
Get a single tensor entry, const version.
void add(const CepsString &label, const CepsString &params, Geometry *geom=nullptr)
Add an object from parameters.
Encapsulates all the geometrical data.
Definition: Geometry.hpp:50
An abstract class for objects (problems) that have an anode and a cathode The template argument must ...
ElectrodeBase * m_anode
Electrode object.
ElectrodeBase * m_cathode
Electrode object.
Reads and stores simulation configuration.
CepsString getString(const keyType &key) const
Reads a CepsString from configuration.
Laplacian PDE, single unknown, constant stiffness coefficient.
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 is a ceps::Function that uses CepsStandardArgs as argument of call operator (),...
Definition: SAFunc.hpp:100
CepsSet< CepsAttribute > & getAttributes()
Returns the attributes of the entity.
CepsBool isProfiling()
Check if we are currently profiling on the master proc (always false on slave procs).
Definition: CepsFlags.cpp:257