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: A. Collin |
13 |
|
|
// |
14 |
|
|
|
15 |
|
|
#ifndef _LinearProblemBidomain_HPP |
16 |
|
|
#define _LinearProblemBidomain_HPP |
17 |
|
|
|
18 |
|
|
// System includes |
19 |
|
|
#include <vector> |
20 |
|
|
|
21 |
|
|
// External includes |
22 |
|
|
|
23 |
|
|
// Project includes |
24 |
|
|
#include "Solver/linearProblem.hpp" |
25 |
|
|
#include "Core/felisceParam.hpp" |
26 |
|
|
#include "Solver/bdf.hpp" |
27 |
|
|
#include "Solver/cardiacFunction.hpp" |
28 |
|
|
#include "PETScInterface/romPETSC.hpp" |
29 |
|
|
#include "DegreeOfFreedom/boundaryCondition.hpp" |
30 |
|
|
#include "FiniteElement/elementMatrix.hpp" |
31 |
|
|
|
32 |
|
|
#ifdef FELISCE_WITH_CVGRAPH |
33 |
|
|
#include "Model/cvgMainSlave.hpp" |
34 |
|
|
#endif |
35 |
|
|
|
36 |
|
|
namespace felisce |
37 |
|
|
{ |
38 |
|
|
/*! |
39 |
|
|
\class LinearProblemBidomain |
40 |
|
|
\authors A. Collin |
41 |
|
|
*/ |
42 |
|
|
class LinearProblemBidomain: |
43 |
|
|
public LinearProblem { |
44 |
|
|
public: |
45 |
|
|
LinearProblemBidomain(); |
46 |
|
|
~LinearProblemBidomain() override; |
47 |
|
|
void initialize(std::vector<GeometricMeshRegion::Pointer>& mesh, FelisceTransient::Pointer fstransient, MPI_Comm& comm, bool doUseSNES) override; |
48 |
|
|
void getFiberDirection(felInt iel, int iUnknown, std::vector<double>& elemFiber); |
49 |
|
|
void getAngle(felInt iel, int iUnknown, std::vector<double>& elemAngle); |
50 |
|
|
void initPerElementType(ElementType eltType, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs) override; |
51 |
|
✗ |
void initPerDomain(int label, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs) override { |
52 |
|
✗ |
m_currentLabel=label; |
53 |
|
|
IGNORE_UNUSED_FLAG_MATRIX_RHS; |
54 |
|
|
} |
55 |
|
|
void computeElementArray(const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, felInt& iel, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs) override; |
56 |
|
|
void computeElementArrayBoundaryCondition(const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, felInt& iel, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs) override; |
57 |
|
|
void computeElementArraySurfaceModel(const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, felInt& iel, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs) override; |
58 |
|
|
|
59 |
|
|
double conductivityHet(int currentLabel); |
60 |
|
|
double conductivityHom(int currentLabel); |
61 |
|
|
|
62 |
|
✗ |
void initializeTimeScheme(Bdf* bdf) override { |
63 |
|
✗ |
m_bdf = bdf; |
64 |
|
|
} |
65 |
|
|
void readData(IO& io) override; |
66 |
|
|
void readDataDisplacement(std::vector<IO::Pointer>& io, double iteration); |
67 |
|
|
void updateFibers(IO& io,double iteration); |
68 |
|
|
void writeEnsightScalar(double* solValue, int idIter, std::string varName); |
69 |
|
|
void writeEnsightCase(int numIt, std::string varName); |
70 |
|
|
void writeEnsightCaseCurrents(int numIt, std::vector<std::string> varName); |
71 |
|
|
|
72 |
|
|
|
73 |
|
|
void writeSolution(int rank, std::vector<IO::Pointer>& io, double& time, int iteration) override; |
74 |
|
|
|
75 |
|
|
void addMatrixRHS() override; |
76 |
|
|
|
77 |
|
✗ |
std::vector<double> & EndocardiumDistance() { |
78 |
|
✗ |
return m_vectorDistance; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
✗ |
void initializeROM(RomPETSC* rom) { |
82 |
|
✗ |
m_rom = rom; |
83 |
|
|
} |
84 |
|
|
|
85 |
|
✗ |
virtual void sortSolution() {} |
86 |
|
|
|
87 |
|
|
double* sortedSolution() { |
88 |
|
|
return m_sortedSol; |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
template <class Templ_functor> void evalFunctionOnElem(const Templ_functor& func, double& value, int& label); |
92 |
|
|
|
93 |
|
✗ |
std::vector<double> & Reference() { |
94 |
|
✗ |
return m_vectorRef; |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
void readMatch(); |
98 |
|
|
void readElectrodeMeasure(); |
99 |
|
|
void addElectrodeCondtrol(); |
100 |
|
|
|
101 |
|
✗ |
virtual void fillValueToImpose(double* /*valueToImpose*/) {} |
102 |
|
|
|
103 |
|
✗ |
virtual void userComputeMass(const std::vector<Point*>& /*elemPoint*/, const std::vector<felInt>& /*elemIdPoint*/, felInt& /*iel*/){}; |
104 |
|
|
|
105 |
|
|
void assembleOnlyMassMatrix(PetscMatrix& mass); |
106 |
|
|
void initAndStoreMassMatrix(); |
107 |
|
|
PetscMatrix massMatrix(){ return m_massMatrix;} |
108 |
|
✗ |
virtual void removeAverageForPotExtraCell(){}; |
109 |
|
✗ |
virtual void applyUserDefinedStimulation(double /*time*/){}; |
110 |
|
✗ |
virtual void initMassBoundaryForStimulation(){}; |
111 |
|
|
void initMassBoundaryForCVG(); |
112 |
|
|
|
113 |
|
✗ |
inline std::vector<double> & Displacement() { return m_vectorDisp; } |
114 |
|
|
|
115 |
|
|
#ifdef FELISCE_WITH_CVGRAPH |
116 |
|
|
void massMatrixComputer(felInt ielSupportDof); |
117 |
|
|
void initPerETMass(); |
118 |
|
|
void updateFE(const std::vector<Point*>& elemPoint, const std::vector<int>&); |
119 |
|
|
#endif |
120 |
|
|
|
121 |
|
|
protected: |
122 |
|
|
RomPETSC* m_rom; |
123 |
|
|
CurrentFiniteElement* m_fePotTransMemb; |
124 |
|
|
CurrentFiniteElement* m_fePotExtraCell; |
125 |
|
|
CurvilinearFiniteElement* m_fePotTransMembCurv; |
126 |
|
|
CurvilinearFiniteElement* m_fePotExtraCellCurv; |
127 |
|
|
felInt m_ipotTransMemb; |
128 |
|
|
felInt m_ipotExtraCell; |
129 |
|
|
double* m_sortedSol; |
130 |
|
|
CurvilinearFiniteElement* m_curvFe; |
131 |
|
|
private: |
132 |
|
|
Bdf* m_bdf; |
133 |
|
|
std::vector<double> m_vectorFiber; |
134 |
|
|
std::vector<double> m_vectorAngle; |
135 |
|
|
std::vector<double> m_vectorDistance; |
136 |
|
|
std::vector<double> m_vectorRef; |
137 |
|
|
std::vector<double> m_vectorDisp; |
138 |
|
|
bool m_initializeCVGraphInterface; |
139 |
|
|
felInt* m_electrodeNode; |
140 |
|
|
felInt m_numElectrodeNode; |
141 |
|
|
double** m_electrodeMeasure; |
142 |
|
|
PetscVector m_electrodeControl; |
143 |
|
|
PetscMatrix m_massMatrix; |
144 |
|
|
|
145 |
|
|
|
146 |
|
|
#ifdef FELISCE_WITH_CVGRAPH |
147 |
|
|
public: |
148 |
|
|
void readData() override; |
149 |
|
|
void sendData(); |
150 |
|
|
void addCurrentToRHS(); |
151 |
|
|
virtual void cvgAddRobinToRHS(); |
152 |
|
|
#endif |
153 |
|
|
|
154 |
|
|
}; |
155 |
|
|
|
156 |
|
|
template <class Templ_functor> void LinearProblemBidomain::evalFunctionOnElem(const Templ_functor& func, double& value, int& label) { |
157 |
|
|
value = func(label); |
158 |
|
|
} |
159 |
|
|
|
160 |
|
|
} |
161 |
|
|
|
162 |
|
|
#endif |
163 |
|
|
|