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: |
13 |
|
|
// |
14 |
|
|
|
15 |
|
|
#ifndef _LINEARPROBLEMLUNG_HPP |
16 |
|
|
#define _LINEARPROBLEMLUNG_HPP |
17 |
|
|
|
18 |
|
|
// System includes |
19 |
|
|
|
20 |
|
|
// External includes |
21 |
|
|
|
22 |
|
|
// Project includes |
23 |
|
|
#include "Core/felisceParam.hpp" |
24 |
|
|
// #include "FiniteElement/elementField.hpp" |
25 |
|
|
#include "Solver/linearProblem.hpp" |
26 |
|
|
|
27 |
|
|
namespace felisce { |
28 |
|
|
|
29 |
|
|
class LinearProblemLung: |
30 |
|
|
public LinearProblem { |
31 |
|
|
|
32 |
|
|
public: |
33 |
|
|
LinearProblemLung(); |
34 |
|
|
|
35 |
|
|
~LinearProblemLung() override = default;; |
36 |
|
|
|
37 |
|
|
protected: |
38 |
|
|
|
39 |
|
|
///lung case (TODO: much code duplicated, is this really necessary ?) |
40 |
|
|
/** |
41 |
|
|
* @brief elementary loop to build matrix. lung case : enables access to previous iteration states for element field actualization |
42 |
|
|
* This function uses specific functions which are defined in derived problem classes. |
43 |
|
|
*/ |
44 |
|
|
void assembleMatrixRHSlung(Vec & divVel,Mat & divBasis,PetscVector& rhsMinus,PetscVector& prevVel, PetscVector& prevDis, double currPre, int rank, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs); |
45 |
|
|
|
46 |
|
|
void assembleMatrixRHSlungDisplacement(PetscVector& emphysemaCoeff, PetscVector& volReg,PetscVector& volEvol,PetscVector& divVel,PetscMatrix& divBasis,PetscVector& rhsMinus,PetscVector& localExpansion,PetscVector& pCouplingB,PetscVector& volumeB,PetscVector& prevVel, PetscVector& prevDis, PetscVector& displReal, double currPre, int rank, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs); |
47 |
|
|
|
48 |
|
|
void assembleMatrixRHSlungPressure(PetscVector& emphysemaCoeff,PetscVector& volReg,PetscVector& volEvol,PetscVector& divVel,PetscMatrix& divBasis,PetscVector& rhsMinus,PetscVector& localExpansion,PetscVector& pCouplingB,PetscVector& volumeB,PetscVector& prevVel, PetscVector& prevDis, double currPre, int rank, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs); |
49 |
|
|
|
50 |
|
|
void computeVolumeLungRegions(PetscVector& volReg, PetscVector& displ, int rank, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::only_rhs); |
51 |
|
|
|
52 |
|
|
void computeVolumeLungRegions2(PetscVector& volReg, PetscVector& displ, int rank, FlagMatrixRHS flagMatrixRH = FlagMatrixRHS::only_rhs); |
53 |
|
|
|
54 |
|
|
void normalLungMesh(PetscVector& modelVec, std::string modeLung, PetscVector& normalVec, felInt idVecVariable); |
55 |
|
|
|
56 |
|
|
virtual void computeElementArrayLung(Vec & divVel,Mat & divBasis,PetscVector& rhsMinus,int currentLabel,PetscVector& prevVel, PetscVector& prevDis, double currPre,const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, |
57 |
|
|
felInt& iel, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs ); |
58 |
|
|
|
59 |
|
|
virtual void computeElementArrayLungDisplacement(PetscVector& emphysemaCoeff,PetscVector& volReg,PetscVector& volEvol,PetscVector& divVel,PetscMatrix& divBasis,PetscVector& rhsMinus,PetscVector& localExpansion,PetscVector& pCouplingB,PetscVector& volumeB,int currentLabel,PetscVector& prevVel, PetscVector& prevDis, PetscVector& displReal, double currPre,const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, |
60 |
|
|
felInt& iel, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs ); |
61 |
|
|
|
62 |
|
|
virtual void computeElementArrayLungPressure(PetscVector& emphysemaCoeff,PetscVector& volReg,PetscVector& volEvol,PetscVector& divVel,PetscMatrix& divBasis,PetscVector& rhsMinus,PetscVector& localExpansion,PetscVector& pCouplingB,PetscVector& volumeB,int currentLabel,PetscVector& prevVel, PetscVector& prevDis, double currPre,const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, |
63 |
|
|
felInt& iel, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs ); |
64 |
|
|
|
65 |
|
|
virtual void computeElementLungVolume(int currentLabel, PetscVector& volReg,PetscVector& displ,const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, |
66 |
|
|
felInt& iel, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs ); |
67 |
|
|
|
68 |
|
|
///apply boundary condition for the mechanically induce lung ventilation (lung model) |
69 |
|
|
void applyBoundaryConditionMecha(double ratioM, PetscVector& volCurr,PetscVector& volFRC,PetscVector& volTLC, double dt, double coeffReaction, const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, felInt& iel, FlagMatrixRHS=FlagMatrixRHS::only_rhs); |
70 |
|
|
|
71 |
|
|
///Assembly loop on boundary element with curvilinear finite element. This is used in the lung model for mechanically induced ventilation |
72 |
|
|
void assembleMatrixRHSBoundaryConditionMecha(double ratioM, PetscVector& volCurr,PetscVector& volFRC,PetscVector& volTLC , double dt, double coeffReaction, int rank, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs, const int idBCforLinCombMethod=0); |
73 |
|
|
|
74 |
|
|
void applyBCMecha(double ratioM, PetscVector& volCurr,PetscVector& volFRC,PetscVector& volTLC, double dt, double coeffReaction, const int & applicationOption, int rank, FlagMatrixRHS flagMatrixRHSEss = FlagMatrixRHS::matrix_and_rhs, FlagMatrixRHS flagMatrixRHSNat = FlagMatrixRHS::matrix_and_rhs, const int idBCforLinCombMethod=0, |
75 |
|
|
bool doPrintBC = true, ApplyNaturalBoundaryConditionsType do_apply_natural = ApplyNaturalBoundaryConditions::yes); |
76 |
|
|
|
77 |
|
|
|
78 |
|
|
/** |
79 |
|
|
* @brief it computes the P1 normal field on the lateral surface |
80 |
|
|
* This function compute the P1 outward normal starting from the discontinuos normal. |
81 |
|
|
* It also computes, for each boundary dof, the measure of the all the boundary elements that share the dof it has to be called when you init the structure |
82 |
|
|
*/ |
83 |
|
|
void computeNormalField(const std::vector<int> & labels, felInt idVecVariable); |
84 |
|
|
|
85 |
|
|
|
86 |
|
|
/** |
87 |
|
|
* @brief Used to compute the P1 outward normal |
88 |
|
|
*/ |
89 |
|
|
void normalFieldComputer(felInt ielSupportDof); |
90 |
|
|
|
91 |
|
|
/** |
92 |
|
|
* @brief Used to update fe used for the computation of the P1 outward normal |
93 |
|
|
*/ |
94 |
|
|
void updateFeNormVel(const std::vector<Point*>& elemPoint, const std::vector<int>& elemIdPoint); |
95 |
|
|
|
96 |
|
|
/** |
97 |
|
|
* @brief Used to normalized the P1 outward normal right after its computation |
98 |
|
|
* It does a getValues from the sequential normalField and a setValue on the parallel normalField. |
99 |
|
|
* It is then necessary to call an assembly on the parallel normalField after finished using it. |
100 |
|
|
*/ |
101 |
|
|
void normalizeComputer(felInt ielSupportDof); |
102 |
|
|
|
103 |
|
|
/** |
104 |
|
|
* @brief Virtual function to initialize element fields for the computation of the P1 outward normal |
105 |
|
|
*/ |
106 |
|
✗ |
void initPerETNormVel() {}; |
107 |
|
|
|
108 |
|
|
|
109 |
|
|
std::vector<int> m_auxiliaryInts; |
110 |
|
|
}; |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
#endif |
114 |
|
|
|