GCC Code Coverage Report


Directory: ./
File: Solver/ionicSolver.hpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 0 19 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // ______ ______ _ _ _____ ______
2 // | ____| ____| | (_)/ ____| | ____|
3 // | |__ | |__ | | _| (___ ___| |__
4 // | __| | __| | | | |\___ \ / __| __|
5 // | | | |____| |____| |____) | (__| |____
6 // |_| |______|______|_|_____/ \___|______|
7 // Finite Elements for Life Sciences and Engineering
8 //
9 // License: LGL2.1 License
10 // FELiScE default license: LICENSE in root folder
11 //
12 // Main authors: E.Schenone C.Corrado
13 //
14
15 #ifndef _IONICSOLVER_HPP
16 #define _IONICSOLVER_HPP
17
18 // System includes
19
20 // External includes
21 #include "Core/NoThirdPartyWarning/Petsc/vec.hpp"
22 #include "Core/NoThirdPartyWarning/Petsc/ao.hpp"
23
24 // Project includes
25 #include "Core/felisce.hpp"
26 #include "Solver/bdf.hpp"
27 #include "Core/felisceParam.hpp"
28 #include "Core/felisceTransient.hpp"
29 #include "Solver/cardiacFunction.hpp"
30
31 namespace felisce {
32 class IonicSolver {
33 public:
34 /// Constructor.
35 IonicSolver(FelisceTransient::Pointer fstransient);
36 /// Destructor.
37 virtual ~IonicSolver();
38 /// Define order of BDF.
39 void defineOrderBdf(int order, int nComp=1);
40 /// Define size of schaf equations.
41 void defineSizeAndMappingOfIonicProblem(felInt size, ISLocalToGlobalMapping& mapping, AO ao=FELISCE_PETSC_NULLPTR);
42 /// Initialization of the extrapolate.
43 void initializeExtrap(PetscVector& V_0);
44 /// Initialization BDF 1.
45 void initialize(PetscVector& sol_0);
46 /// Initialization BDF 2.
47 void initialize(PetscVector& sol_0,PetscVector& sol_1);
48 /// Initialization BDF 3.
49 void initialize(PetscVector& sol_0,PetscVector& sol_1,PetscVector& sol_2);
50
51 virtual void initialize(std::vector<PetscVector>& sol_0);
52 void initialize(std::vector<PetscVector>& sol_0,std::vector<PetscVector>& sol_1);
53 void initialize(std::vector<PetscVector>& sol_0,std::vector<PetscVector>& sol_1,std::vector<PetscVector>& sol_2);
54
55
56 /// Compute RHS in EDO.
57 virtual void computeRHS() {}
58 /// Solve the EDO.
59 virtual void solveEDO()=0;
60 /// Computation of ionic current from EDO solution.
61 virtual void computeIon()=0;
62
63 /// Update time scheme to next timestep.
64 void updateBdf();
65 /// Update extrapolate from result of EDP.
66 void update(PetscVector& V_1);
67
68 /// Access functions.
69 inline const PetscVector& sol() const {
70 return m_solEDO;
71 }
72 inline PetscVector& sol() {
73 return m_solEDO;
74 }
75
76 inline const PetscVector& sol_n_1() const {
77 return m_bdf.sol_n_1();
78 }
79 inline PetscVector& sol_n_1() {
80 return m_bdf.sol_n_1();
81 }
82
83 inline const PetscVector& sol_n_2() const {
84 return m_bdf.sol_n_2();
85 }
86 inline PetscVector& sol_n_2() {
87 return m_bdf.sol_n_2();
88 }
89
90 inline const PetscVector& ion() const {
91 return m_ion;
92 }
93 inline PetscVector& ion() {
94 return m_ion;
95 }
96
97 inline const Bdf & bdf() const {
98 return m_bdf;
99 }
100 inline Bdf & bdf() {
101 return m_bdf;
102 }
103
104 inline PetscVector& stabTerm() {
105 return m_stabTerm;
106 }
107 inline const PetscVector& stabTerm() const {
108 return m_stabTerm;
109 }
110
111 inline const std::vector<PetscVector> & vec_sol() const {
112 return m_vecSolEDO;
113 }
114 inline std::vector<PetscVector> & vec_sol() {
115 return m_vecSolEDO;
116 }
117
118 inline const PetscVector& vec_sol(const int i) const {
119 return m_vecSolEDO[i];
120 }
121
122 inline const std::vector<PetscVector> & vec_sol_n_1() const {
123 return m_bdf.vec_sol_n_1();
124 }
125 inline std::vector<PetscVector> & vec_sol_n_1() {
126 return m_bdf.vec_sol_n_1();
127 }
128
129 inline const std::vector<PetscVector> & vec_sol_n_2() const {
130 return m_bdf.vec_sol_n_2();
131 }
132 inline std::vector<PetscVector> & vec_sol_n_2() {
133 return m_bdf.vec_sol_n_2();
134 }
135
136 protected:
137 /// Number of Dof for the trans membrane potential.
138 felInt m_size;
139 /// User data file of Felisce.
140 /// User data file of Felisce (only transient parameters).
141 FelisceTransient::Pointer m_fstransient;
142 /// Number of currents
143 std::size_t m_nComp;
144 /// Cell types concerned by MV model
145 felInt m_cellTypeCut;
146 /// Extrapolate std::vector.
147 PetscVector m_uExtrap;
148
149 /// RHS std::vector.
150 PetscVector m_RHS;
151 /// EDO solution.
152 PetscVector m_solEDO;
153 /// Ionic current.
154 PetscVector m_ion;
155 ///
156 Bdf m_bdf;
157
158 std::vector<PetscVector> m_vecRHS;
159 std::vector<PetscVector> m_vecSolEDO;
160
161 /*! stabilization term, for Luenberger observer
162 \c the stabilization term has to be implemented in computeIon
163 */
164 PetscVector m_stabTerm;
165 /// tells if stabilization term is initialized
166 bool m_stabInit;
167
168 /// mapping between local petsc numbering and global petsc numbering
169 ISLocalToGlobalMapping m_localDofToGlobalDof;
170 /// mapping between global petsc numbering and global "mesh" numbering
171 AO m_ao;
172 };
173 }
174
175 #endif
176