CEPS  24.01
Cardiac ElectroPhysiology Simulator
AbstractPdeSolver.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  CepsObject(),
36  m_problem (pb),
37  m_discretization(nullptr),
38  m_linearSystem (ceps::getNew<LinearSystem>()),
39  m_opAsb (nullptr),
40  m_bcAsb (nullptr),
41  m_lapSrcAsb (nullptr),
42  m_hasRegSrc (false),
43  m_hasLapSrc (false),
44  m_useMassLumping(false),
45  m_doOutput (true),
46  m_writer (nullptr),
47  m_timeWriter (nullptr),
48  m_doError (false),
49  m_errors (nullptr)
50 {
52  "Passed pointer on PDE problem is null"
53  );
54 
56 
57  if (pb->getParameters())
58  {
61  }
62 
67 
68  // Link matrix and vector to linear system
73 
74  // Matrix of the operator
76  // Vector of boundary conditions
79  // Matrix for laplace source terms
81 }
82 
84 {
92 }
93 
94 
95 // -----------------------------------------------------------------------------------------
96 
97 void
99 {
100  m_doOutput = false;
101 }
102 
103 void
105 {
106  m_doOutput = true;
107 }
108 
109 TimeWriter*
111 {
112  return m_timeWriter;
113 }
114 
115 // -----------------------------------------------------------------------------------------
116 
117 void
119 {
120  m_doError = false;
121 }
122 
123 
124 // -----------------------------------------------------------------------------------------
125 
126 void
128 {
129  m_useMassLumping = params->isActiveOption("use mass lumping");
130  m_doOutput = not params->isActiveOption("disable output");
131 }
132 
133 void
135 {
136  m_writer = ceps::getNew<VtkWriter>(
142  );
143 }
144 
@ Laplace
A source term that multiplies grad phi (for FE)
@ Default
Simply add the source term.
@ Stimulation
Apply cardiac specific treatment before adding.
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
DHVecPtr newDofHaloVector() const
Get a new vector from the factory, with halo data.
DVecPtr newDofVector() const
Get a new vector from the factory.
DMatPtr newDofMatrix() const
Get a new matrix from the factory.
Base class for creating PDEs to solve.
CepsOutputFormat getOutputFormat() const
Tells if output is binary or ascii.
CepsString getOutputFileBase() const
Output file name includes the directory.
SourceTermManager * getSourceTermManager() const
Get boundary condition manager.
AbstractDiscretization * getSpatialDiscretization() const
Link to the spatial discretization (FE, FV, etc)
InputParameters * getParameters() const
Text parameters.
CepsBool writesGlobalIndices() const
Tells if global indices are written on top of solution.
virtual void initializeWriter()
Creates the solution writer.
TimeWriter * getTimeWriter() const
Access to Time Writer to be able to add data.
VtkWriter * m_writer
Manages output.
DMatPtr m_lhs
Left hand side of the system.
AbstractAssembler * m_lapSrcAsb
Assembler for laplace source terms.
~AbstractPdeSolver() override
Destructor.
DVecPtr m_rhs
Right hand side of the system.
DMatPtr m_bcMat
Matrix of boundary conditions.
virtual void setupWithParameters(InputParameters *params)
Set attributes from input file. Parameters are passed as arguments in case one wants to use other par...
virtual CepsUInt getExpectedNumberOfOutputs() const =0
Gives the number of outputs.
CepsBool m_hasRegSrc
Flag telling if there are regular source terms.
AbstractDiscretization * m_discretization
Link to PDE discretization.
AbstractAssembler * m_bcAsb
Assembler for Robin and Neumann BCs.
void disableOutput()
Stops output.
void enableOutput()
Starts output.
PdeErrorCalculator * m_errors
Error computation.
LinearSystem * m_linearSystem
Linear system.
AbstractPdeSolver()=delete
Deleted default constructor.
CepsBool m_doOutput
Enables/disables outputs.
CepsBool m_useMassLumping
Put the mass on the diagonal of the matrix.
DMatPtr m_opMat
Matrix of operator.
TimeWriter * m_timeWriter
Writer for time dependant data (even for static problems...)
void disableErrorComputation()
Sets the comparison with analytic solution.
DVecPtr m_bcVec
Vector of boundary conditions.
AbstractAssembler * m_opAsb
Assembler for the operator matrix.
CepsBool m_hasLapSrc
Flag telling if there are Delta f source terms.
AbstractPdeProblem * m_problem
Link to PDE to solve.
CepsBool m_doError
Compute error wrt analytic solution or reference.
DMatPtr m_lapSrcMat
Matrix used for laplace source terms.
Base class for other (big) CEPS classes. All classes can get a pointer to this base class and also co...
Definition: CepsObject.hpp:40
Reads and stores simulation configuration.
CepsBool isActiveOption(const keyType &key) const
Tells if key exists in configuration and is of "1","YES","ON" or "TRUE".
Linear system Ax=b to be solved.
void setLhsMatrix(DMatPtr lhs)
Set the left-hand side matrix of the system.
Definition: PETScKSP.cpp:124
void setupWithParameters(InputParameters *params)
Sets the options from text parameters.
void setRhsVector(DVecPtr rhs)
Set the right hand side.
Definition: PETScKSP.cpp:141
CepsUInt getNbOfSourceTermsOf(CepsSourceTermFlag flag) const
Number of registered source terms of type flag.
A namespace for all utility methods.
_Type * getNew(_Args... args)
Allocates memory for one object. Be careful, the expansion of arguments may produce some weird result...
Definition: CepsMemory.hpp:170
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
Definition: CepsMemory.hpp:45
void destroyObject(_Type &)
Destroy[delete] any type.
Definition: CepsMemory.hpp:116