GCC Code Coverage Report


Directory: ./
File: Solver/linearProblemFSINitscheXFEMFluid.hpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 9 9 100.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: B. Fabreges and M. Fernandez
13 //
14
15 #ifndef _LinearProblemFSINitscheXFEMFluid_HPP
16 #define _LinearProblemFSINitscheXFEMFluid_HPP
17
18 // System includes
19
20 // External includes
21
22 // Project includes
23 #include "Solver/linearProblem.hpp"
24 #include "Core/felisceParam.hpp"
25 #include "Solver/bdf.hpp"
26 #include "FiniteElement/elementField.hpp"
27 #include "DegreeOfFreedom/duplicateSupportDof.hpp"
28 #include "Core/felisceTransient.hpp"
29
30 namespace felisce
31 {
32 /*!
33 \brief Monolithic algorithm for fsi with fictitious domain and Nitsche's formulation
34 */
35 class LinearProblemFSINitscheXFEMFluid:
36 public LinearProblem {
37 public:
38
39 // Constructor
40 LinearProblemFSINitscheXFEMFluid();
41
42 // Destructor
43 ~LinearProblemFSINitscheXFEMFluid() override;
44
45 // Initialize the linar problem (parameters, unknowns, ...)
46 void initialize(std::vector<GeometricMeshRegion::Pointer>& mesh, FelisceTransient::Pointer fstransient, MPI_Comm& comm, bool doUseSNES) override;
47
48 // add solid variable
49 void addSolidVariable();
50
51 // Duplicate and initialize the support dof
52 void initSupportDofDerivedProblem() override;
53
54 // Initialize the bdf scheme (pointer to the one in the model)
55 2 void initializeTimeScheme(Bdf* bdf) override {
56 2 m_bdf = bdf;
57 2 }
58
59 // For Dirichlet BC changing at each time step
60 void finalizeEssBCTransientDerivedProblem() override;
61
62 // Get the current finite elements and initialize elemFields for the problem
63 void initPerElementType(ElementType eltType, FlagMatrixRHS flagMatrixRHS = FlagMatrixRHS::matrix_and_rhs) override;
64
65
66 void computeElementArray(const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, felInt& iel1, felInt& iel2, ElementType& eltType, felInt& ielGeo, FlagMatrixRHS = FlagMatrixRHS::matrix_and_rhs) override;
67
68 void assembleMatrixFrontPoints();
69 void assembleMatrixGhostPenalty();
70 void assembleMatrixFaceOriented();
71
72
73 // LumpedModelBC: NS model with implicit implementation
74 void userChangePattern(int numProc, int rankProc) override;
75
76 // gather bdf->vector() to m_seqBdfRHS
77 void gatherSeqBdfRHS(std::vector<PetscVector>& parallelVec);
78
79 // gather a std::vector to m_seqVelExtrapol
80 void gatherSeqVelExtrapol(std::vector<PetscVector>& parallelVec);
81
82 // get the sequential std::vector of the extrapolation of the velocity (used in the structure problem with
83 // stabilized explicit methods)
84 PetscVector& getVelExtrapol(felInt n);
85
86 // add m_Matrix[1] to the current matrix (m_Matrix[0])
87 void addMatrixRHS() override;
88
89 // get the reference to the object in the model duplicating the support dofs
90 void setDuplicateSupportObject(DuplicateSupportDof* object);
91
92 // get the pointer to the curvilinear finite element of the structure
93 void setStrucFiniteElement(CurvilinearFiniteElement* strucFE);
94
95 // get a pointer to the structure linear problem
96 void setStrucLinPrb(LinearProblem* pLinPrb);
97
98
99 // Dynamics, copy original <-> current
100 void initOriginalBdf(felInt timeScheme, felInt extrapolOrder);
101 void copyOriginalBdfToCurrentBdf(felInt timeScheme, felInt extrapolOrder);
102 void copyOriginalSolToCurrentSol();
103 void copyCurrentSolToOriginalSol();
104 void deleteDynamicData();
105 void copyOriginalToCurrent(PetscVector& vecSeqOriginal, PetscVector& vecSeqCurrent, PetscVector& vecParCurrent);
106
107 void initOldObjects(felInt stabExplicitExtrapolOrder);
108 void updateOldSolution(felInt countInitOld);
109
110 84 const PetscVector& solutionOld(felInt n) const { return m_solutionOld[n]; }
111 2034 const PetscVector& sequentialSolutionOld(felInt n) const { return m_sequentialSolutionOld[n]; }
112 54756 AO const & aoOld(felInt n) const { return m_aoOld[n]; }
113 54756 Dof const & dofOld(felInt n) const { return m_dofOld[n]; }
114 50728 SupportDofMesh const & supportDofUnknownOld(felInt n, felInt i) const { return m_supportDofUnknownOld[n][i]; }
115
116 // virtual function of LinearProblem
117 void initPerElementTypeBoundaryCondition(ElementType& eltType, FlagMatrixRHS flagMatrixRHS) override;
118 void computeElementArrayBoundaryCondition(const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, felInt& ielSupportDof, FlagMatrixRHS flagMatrixRHS) override;
119
120
121 40 void setUseCurrentFluidSolution(bool useCurFluidSol) { m_useCurrentFluidSolution = useCurFluidSol;}
122
123 // Manage the extrapolations in the Robin - Neumann schemes
124 void gatherRNFluidExtrapol(std::vector<PetscVector>& parFluidExtrapol);
125 void gatherRNFluidExtrapol(PetscVector& parFluidExtrapol);
126 void setRNFluidExtrapol(PetscVector& seqFluidExtrapol);
127 void initRNFluidExtrapol(felInt order);
128
129 protected:
130 CurrentFiniteElement* m_feVel; // volume velocity finite element
131 CurrentFiniteElement* m_fePres; // volume pressure finite element
132 CurrentFiniteElementWithBd* m_feVelWithBd; // volume finite element with edges
133 CurrentFiniteElementWithBd* m_fePreWithBd; // volume finite element with edges
134 CurvilinearFiniteElement *m_curvFeVel; // boundary velocity finite element
135 CurvilinearFiniteElement *m_curvFePress; // boundary pressure finite element
136 CurvilinearFiniteElement *m_feStruc; // finite element for the structure
137 Variable* m_velocity; // velocity
138 Variable* m_pressure; // pressure
139 felInt m_iVelocity; // id of the velocity
140 felInt m_iPressure; // id of the pressure
141 double m_viscosity; // dynamic viscosity of the fluid
142 double m_density; // density of the fluid
143 bool m_useSymmetricStress; // expression of the Laplacian (epsilon(u) or grad(u))
144 std::vector<PetscVector> m_seqBdfRHS; // bdf part going to the rhs
145 std::vector<PetscVector> m_seqVelExtrapol; // extrapolation of the velocity
146 ElementField m_sourceTerm;
147
148 private:
149 void computeElementMatrixRHS();
150 void computeElementMatrixRHSPartDependingOnOldTimeStep(felInt iel, felInt ielOld, felInt idTimeStep);
151 void computeNitscheSigma_u_v(double velCoeff, double preCoeff);
152 void computeNitscheSigma_v_u(double velCoeff, double preCoeff);
153 void computeNitscheSigma_u_Sigma_v(double coeff);
154 void computeNitscheSigma_uold_Sigma_v(double coeff);
155 void computeNitscheDpoint_Sigma_v(double velCoeff, double preCoeff);
156 void computeStenbergSigma_u_Sigma_v(double velCoeff, double preCoeff);
157 void updateStructureVel(felInt strucId, PetscVector& strucVel);
158 void updateSubStructureVel(const std::vector<Point*>& ptElem, const std::vector<Point*>& ptSubElem);
159
160
161 ElementField m_elemFieldAdv; // the extrapolated velocity
162 ElementField m_elemFieldAdvDup; // the extrapolated velocity on the duplicate elt
163 ElementField m_elemFieldAdvTmp;
164 ElementField m_elemFieldRHS; // rhs use for supg stabilization (not use at the moment)
165 ElementField m_elemFieldRHSbdf; // the bdf part that goes in the rhs
166 ElementField m_elemFieldTotalPressureFormulation; // old velocity for total pressure formulation
167
168 Bdf* m_bdf; // Bdf scheme, initialized in initializedTimeScheme
169 std::vector<ElementField> m_seqVelDofPts;
170 std::vector<ElementField> m_seqPreDofPts;
171 ElementField m_elemFieldNormal;
172 ElementField m_elemFieldNormalInit;
173 ElementField m_tmpSourceTerm;
174 ElementField m_strucVelDofPts;
175 ElementField m_strucVelQuadPts;
176 ElementField m_ddotComp;
177 ElementField m_elemFieldAux;
178
179 bool m_isSeqBdfRHSAllocated; // to know if m_seqBdfRHS has been allocated
180 bool m_isSeqVelExtrapolAllocated; // to know if m_solExtrapol has been allocated
181
182 DuplicateSupportDof *m_duplicateSupportElements; // manage the duplication of the support dofs
183
184 LinearProblem* m_pLinStruc; // structure linear problem
185
186 ElementFieldDynamicValue *m_elemFieldTimeSchemeType;
187 felInt m_timeSchemeType;
188
189 std::vector<Point*> m_mshPts;
190 std::vector<Point*> m_itfPts;
191 std::vector<Point*> m_subItfPts;
192
193 std::size_t m_numVerPerFluidElt;
194 std::size_t m_numVerPerSolidElt;
195
196 felInt m_useCurrentFluidSolution;
197
198 bool m_isSeqRNFluidExtrapolAllocated;
199 std::vector<PetscVector> m_seqRNFluidExtrapol;
200
201 // if one choose to do a projection when the intersection is changing
202 felInt m_numOriginalDof;
203 Bdf m_seqOriginalSolutions;
204 PetscVector m_tmpSeqOriginalSol;
205 bool m_isSeqOriginalSolAllocated;
206
207 // if one choose to NOT do a projection when the intersection is changing
208 std::vector<Dof> m_dofOld;
209 std::vector<AO> m_aoOld;
210 std::vector<PetscVector> m_solutionOld;
211 std::vector<PetscVector> m_sequentialSolutionOld;
212 std::vector< std::vector<SupportDofMesh> > m_supportDofUnknownOld;
213
214 //Robin - Neumann extrapolation coefficients
215 std::vector<double> m_betaRN;
216 };
217 }
218
219 #endif
220