CEPS  24.01
Cardiac ElectroPhysiology Simulator
AbstractPdeProblem.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 
33 #include "common/CepsCommon.hpp"
34 #include "geometry/Geometry.hpp"
35 #include "pde/common/Unknown.hpp"
40 
43 {
44 
45  public :
46 
49 
50 
51  public :
52 
56  explicit AbstractPdeProblem(
57  Geometry* geom,
58  InputParameters* params = nullptr
59  );
60 
62  virtual ~AbstractPdeProblem();
63 
65  AbstractPdeProblem(const AbstractPdeProblem& that) = delete;
66 
69  operator=(const AbstractPdeProblem& that) = delete;
70 
73  getParameters() const;
74 
77  virtual void
79 
81  virtual void
82  run();
83 
85  void
86  setProblemName(const CepsString& name);
87 
89  CepsString
90  getProblemName() const;
91 
92  // ---------------------------------------------------------------------------------------
93  // LINKS
94 
96  Geometry*
97  getGeometry() const;
98 
101  getSpatialDiscretization() const;
102 
104  void
106 
108  void
110 
111  // ---------------------------------------------------------------------------------------
112  // UNKNOWNS
113 
116  virtual void
118 
120  const CepsVector<Unknown*>&
121  getUnknowns() const;
122 
124  Unknown*
125  getUnknown(const CepsString& label) const;
126 
128  Unknown*
129  getUnknown(CepsUnknownIndex uid) const;
130 
133  getSpatialUnknowns() const;
134 
137  getZeroDUnknowns() const;
138 
141  getUnknownsInteractions() const;
142 
144  CepsBool
146  Unknown* u1,
147  Unknown* u2,
148  const CepsSet<CepsAttribute>& attrs = {CepsUniversal}
149  ) const;
150 
152  CepsBool
154 
155  // ---------------------------------------------------------------------------------------
156  // Functions, source terms, bcs
157 
159  CepsBool
160  hasAnalyticSolution() const;
161 
164  getAnalyticSolution() const;
165 
168  virtual void
170 
172  void
173  setReferenceSolution(const CepsString& baseFiles, CepsReal snapDt);
174 
176  CepsBool
177  usesReferenceSolution() const;
178 
180  CepsReal
182 
185  getFunctionDictionary() const;
186 
188  void
190 
192  virtual void
194 
198 
200  void
202 
204  virtual void
206 
209  getSourceTermManager() const;
210 
212  void
214 
217  virtual void
219 
220  // ---------------------------------------------------------------------------------------
221  // outputs
222 
224  CepsString
225  getOutputFileBase() const;
226 
228  void
229  setOutputFileBase(CepsString fileName);
230 
233  getOutputFormat() const;
234 
236  void
238 
240  CepsBool
241  writesGlobalIndices() const;
242 
244  void
246 
249  getProbePoints() const;
250 
252  CepsReal
253  virtual getStartTime() const;
254 
256  CepsReal
257  virtual getEndTime() const;
258 
260  CepsReal
261  virtual getSnapshotTime() const;
262 
263 
264  protected :
265 
271  void
272  addUnknown(const CepsString& label, CepsSet<CepsAttribute> attrs = {},
273  CepsLocationFlag flag = CepsLocationFlag::Point, const CepsString& unit = "");
274 
278  void
279  addZeroDUnknown(CepsString label, const CepsString& unit = "");
280 
285  void
287 
288 
289  protected:
290 
292 
297 
300 
308 
312 
318 
319 };
CepsLocationFlag
DataLocation: an enum that will be used by various elements of the code (pde, readers,...
Definition: CepsEnums.hpp:108
@ Point
Data is defined on each point.
CepsOutputFormat
Style of output files.
Definition: CepsEnums.hpp:179
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
CepsIndex CepsUnknownIndex
For unknowns.
Definition: CepsTypes.hpp:217
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
Definition: CepsTypes.hpp:209
std::vector< _Type, _Alloc > CepsVector
C++ vector.
Definition: CepsTypes.hpp:155
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
constexpr CepsAttribute CepsUniversal
This attribute means "everywhere".
Definition: CepsTypes.hpp:232
Abstract Class for all numerical method (FE, FD, FV etc)
Base class for creating PDEs to solve.
CepsString m_name
Name of the problem.
CepsOutputFormat getOutputFormat() const
Tells if output is binary or ascii.
CepsVector< Unknown * > getSpatialUnknowns() const
A vector of all unknowns of pb defined on cells or points.
ScalarFunction * getAnalyticSolution() const
Pointer on analytic or refScalarFunction solution.
virtual void defineUnknowns()=0
Define all the unknowns of the problem here. Must be overriden, and call all necessary addUnknown,...
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 defineBoundaryConditions()
Define the boundary conditions. Should be defined in derived classes. Default is no BC.
CepsString getOutputFileBase() const
Output file name includes the directory.
virtual CepsReal getSnapshotTime() const
Returns 0. Here for compatibility.
CepsBool m_ownedDiscr
True if instance used new to create discretization.
virtual void setupWithParameters(InputParameters *params)
Set attributes from input file. Parameters are passed as arguments in case one wants to use other par...
const CepsVector< UnknownInteraction * > & getUnknownsInteractions() const
All the interactions between unknowns.
FunctionDictionary * getFunctionDictionary() const
Get functions manager.
SourceTermManager * getSourceTermManager() const
Get boundary condition manager.
virtual void defineAnalyticSolution()
Set directly the analytic function, default sets no solution, unless there is a collection of referen...
CepsString m_outputFileBase
File names prefix.
CepsVector< CepsReal3D > getProbePoints() const
Returns points where single data output should be written.
CepsString m_refSolFiles
base name of reference solution file, if any
AbstractDiscretization * m_discr
Discretization method (eg FE for now)
AbstractPdeProblem(Geometry *geom, InputParameters *params=nullptr)
Constructor with geometry and optional parameters.
void setFunctionDictionary(FunctionDictionary *)
Set functions manager.
SourceTermManager * m_sourceTerms
All source terms.
virtual ~AbstractPdeProblem()
destructor
CepsReal m_refSolSnapDt
reference solution output period
void addUnknown(const CepsString &label, CepsSet< CepsAttribute > attrs={}, CepsLocationFlag flag=CepsLocationFlag::Point, const CepsString &unit="")
Register a new unknown.
CepsBool ignoreZeroDUnknownsForError() const
Tells if 0D must not be taken into account in error computation.
ceps::Function< CepsReal(CepsStandardArgs)> ScalarFunction
Typedef for analytic solution.
CepsString getProblemName() const
Get the name of the problem.
void setOutputFormat(CepsOutputFormat opt)
Enable/disable binary output.
void addZeroDUnknown(CepsString label, const CepsString &unit="")
Register a new unknown, defined outside of geometry.
CepsVector< UnknownInteraction * > m_unknownsInteractions
Describes how unknowns interact.
AbstractPdeProblem & operator=(const AbstractPdeProblem &that)=delete
No assignment operator.
CepsBool m_ignoreZeroDError
Ignore 0D unknowns when computing errors.
void addUnknownInteraction(CepsString label1, CepsString label2, CepsSet< CepsAttribute > attrs={})
Register interaction between unknowns. Also sets the interaction within Unknown instances label1 and ...
CepsBool unknownsInteract(Unknown *u1, Unknown *u2, const CepsSet< CepsAttribute > &attrs={CepsUniversal}) const
Tells if unknowns interact on an entity with attributes.
AbstractDiscretization * getSpatialDiscretization() const
Link to the spatial discretization (FE, FV, etc)
InputParameters * getParameters() const
Text parameters.
CepsOutputFormat m_outputFormat
Output format selector.
CepsVector< Unknown * > m_unknowns
All maths unknowns of the problem.
CepsBool usesReferenceSolution() const
Tells if analytic solution and if it is loaded from files.
Unknown * getUnknown(const CepsString &label) const
Get an unknown by its name.
CepsVector< CepsReal3D > m_probePoints
Single point data outputs.
CepsBool writesGlobalIndices() const
Tells if global indices are written on top of solution.
virtual void run()
Computes the solution to the problem. Default does nothing, override it !
InputParameters * m_parameters
Input file data.
CepsBool m_ownedSrcs
True if instance used new to create src term manager.
void setOutputFileBase(CepsString fileName)
Output file name includes the directory.
virtual void initializeEquation()
Initializes equations (unknowns, bc, source term) and creates the spatial discretization This method ...
CepsReal getReferenceSolutionOutputPeriod() const
Output dt of reference.
CepsBool m_ownedRefSol
Flag for reference ownership.
Geometry * m_geom
Link to geometry on which the pb is defined.
void setSpatialDiscretization(AbstractDiscretization *discr)
Link to the spatial discretization (FE, FV, etc)
void writeGlobalIndices(CepsBool opt)
Activate/deactivate global indices writing.
AbstractPdeProblem(const AbstractPdeProblem &that)=delete
No copy constructor.
BoundaryConditionManager * getBoundaryConditionManager() const
Get boundary condition manager.
virtual void defineSourceTerms()
Define the source terms. Should be defined in derived classes. Default is no src term.
void setSourceTermManager(SourceTermManager *stm)
Set boundary condition manager.
virtual CepsReal getStartTime() const
Returns 0. Here for compatibility.
void createSpatialDiscretization()
Compute the discretization structure.
Geometry * getGeometry() const
Link to geometry on which the pb is defined.
virtual CepsReal getEndTime() const
Returns 0. Here for compatibility.
ScalarFunction * m_analyticSolution
analytic or reference solution
CepsBool m_ownedBCs
True if instance used new to create BC manager.
BoundaryConditionManager * m_boundaryConditions
All BCs should be there.
CepsBool m_ownedFunctions
True if instance used new to create dictionary.
FunctionDictionary * m_functions
Collection of custom functions.
CepsVector< Unknown * > getZeroDUnknowns() const
A vector of all zeroD unknowns of the pb.
void setBoundaryConditionManager(BoundaryConditionManager *bcm)
Set boundary condition manager.
void setReferenceSolution(const CepsString &baseFiles, CepsReal snapDt)
Externally define the referece solution from files. Can be used for convergence tests.
CepsBool m_writeGlobalIDs
Writes CEPS indices as well.
const CepsVector< Unknown * > & getUnknowns() const
List of unknowns of the pb.
Boundary condition to manage Dirichlet, Neumann and Robin conditions.
Base class for other (big) CEPS classes. All classes can get a pointer to this base class and also co...
Definition: CepsObject.hpp:40
FunctionDictionary that holds functions which can be used to define source terms, boundary conditions...
Encapsulates all the geometrical data.
Definition: Geometry.hpp:50
Reads and stores simulation configuration.
Source term manager to create and manage SourceTerm objects.
A class used to defined an unknown of a PDE problem The unknown can be defined on a specific region,...
Definition: Unknown.hpp:45
Structure used to pass arguments to SAFunc (see pde directory) The flags of the SAFunc allows extract...
Definition: CepsTypes.hpp:239
function caller : abstract base, only contains an variadic operator()