Directory: | ./ |
---|---|
File: | Solver/linearProblemPerfectFluid.cpp |
Date: | 2024-04-14 07:32:34 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 56 | 56 | 100.0% |
Branches: | 68 | 124 | 54.8% |
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 | // System includes | ||
16 | |||
17 | // External includes | ||
18 | |||
19 | // Project includes | ||
20 | #include "Solver/linearProblemPerfectFluid.hpp" | ||
21 | #include "FiniteElement/elementMatrix.hpp" | ||
22 | #include "Core/felisceTransient.hpp" | ||
23 | #include "Geometry/curvatures.hpp" | ||
24 | |||
25 | namespace felisce { | ||
26 | |||
27 | |||
28 | // ====================================================================== | ||
29 | // the public methods | ||
30 | // ====================================================================== | ||
31 | 4 | LinearProblemPerfectFluid::LinearProblemPerfectFluid():LinearProblem("Perfect fluid equation"), | |
32 |
2/4✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
4 | m_relaxParam(0) |
33 | 4 | {} | |
34 | /** \brief Initializer of the class. | ||
35 | * | ||
36 | * This function overrides LinearProblem::initialize | ||
37 | * we define variable/unknowns and ids and we std::set the | ||
38 | * relaxation parameter from the data file. | ||
39 | * | ||
40 | * \param[in] mesh a pointer to the GeometricMeshRegion mesh, to be passed to the LinearProblem::initialize() | ||
41 | * \param[in] comm mpi communicator also to be passed to the mother class | ||
42 | * \param[in] doUseSNES also to be passed to the mother class | ||
43 | */ | ||
44 | void | ||
45 | 4 | LinearProblemPerfectFluid::initialize(std::vector<GeometricMeshRegion::Pointer>& mesh, FelisceTransient::Pointer fstransient, MPI_Comm& comm, bool doUseSNES) { | |
46 | IGNORE_UNUSED_ARGUMENT(fstransient); | ||
47 | /// First: mother class function is called. | ||
48 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | LinearProblem::initialize(mesh,comm,doUseSNES); |
49 | /// Then iop is added as an unknown and as a variable with one component (scalar) | ||
50 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | m_listUnknown.push_back(iop); |
51 | 4 | std::vector<PhysicalVariable> listVariable; | |
52 | 4 | std::vector<std::size_t> listNumComp; | |
53 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | listVariable.push_back(iop); |
54 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | listNumComp.push_back(/*numOfComponents*/1); |
55 | /// Then the other variables possibly coming from the model are added | ||
56 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | this->userAddOtherVariables(listVariable,listNumComp); |
57 | |||
58 | // we finalize the variable declaration calling this function | ||
59 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | this->definePhysicalVariable(listVariable,listNumComp); |
60 | |||
61 | // we save the id variable and id unknown for the iop | ||
62 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | m_idVarIop = m_listVariable.getVariableIdList(iop); |
63 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | m_iUnknownIop = m_listUnknown.getUnknownIdList(iop); |
64 | |||
65 | // we store the relaxation parameter for the interface boundary condition | ||
66 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | m_relaxParam = FelisceParam::instance().relaxationParam; |
67 | 4 | } | |
68 | // This function initialize the petscVectors and take their structure | ||
69 | // from the solution and from the sequential solution | ||
70 | void | ||
71 | 4 | LinearProblemPerfectFluid::initializePetscVectors() { | |
72 | |||
73 | // we call the default constructor of the petscVector | ||
74 |
2/4✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
4 | m_vecs.Init("velocityInterface"); |
75 |
2/4✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
4 | m_vecs.Init("velocityInterfaceOld"); |
76 |
2/4✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
4 | m_vecs.Init("currentIop"); |
77 |
2/4✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
4 | m_seqVecs.Init("velocityInterface"); |
78 |
2/4✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
4 | m_seqVecs.Init("velocityInterfaceOld"); |
79 |
2/4✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
|
4 | m_seqVecs.Init("currentIop"); |
80 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 4 times.
|
12 | for ( felInt iComp(0); iComp < this->dimension(); ++iComp ) { |
81 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | std::stringstream namevector; |
82 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | namevector << "normalVector" << iComp; |
83 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | m_vecs.Init( namevector.str() ); |
84 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | m_seqVecs.Init( namevector.str() ); |
85 | 8 | } | |
86 | |||
87 | //we take the structure from solution and std::set the value to zero | ||
88 |
2/2✓ Branch 3 taken 20 times.
✓ Branch 4 taken 4 times.
|
24 | for ( auto vecPtr = m_vecs.begin(); vecPtr != m_vecs.end(); vecPtr++) { |
89 |
1/2✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
|
20 | vecPtr->second.duplicateFrom(this->solution()); |
90 |
1/2✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
|
20 | vecPtr->second.set(0.0); |
91 | } | ||
92 | |||
93 | //we take the structure from sequential solution and std::set the value to zero | ||
94 |
2/2✓ Branch 3 taken 20 times.
✓ Branch 4 taken 4 times.
|
24 | for ( auto vecPtr = m_seqVecs.begin(); vecPtr != m_seqVecs.end(); vecPtr++) { |
95 |
1/2✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
|
20 | vecPtr->second.duplicateFrom(this->sequentialSolution()); |
96 |
1/2✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
|
20 | vecPtr->second.set(0.0); |
97 | } | ||
98 | // Why the normalVectors are std::set to -1 ? | ||
99 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 4 times.
|
12 | for ( felInt iComp(0); iComp < this->dimension(); ++iComp ) { |
100 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | std::stringstream namevector; |
101 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | namevector << "normalVector" << iComp; |
102 |
3/6✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
|
8 | m_seqVecs.Get( namevector.str() ).set(-1); |
103 | 8 | } | |
104 | 4 | } | |
105 | /// Some of the vectors containings quantities at the interface are reset to | ||
106 | // zero | ||
107 | // TODO change the name | ||
108 | void | ||
109 | 12 | LinearProblemPerfectFluid::resetInterfaceQuantities() { | |
110 | /// We are advancing in time and therfore we update the old values | ||
111 |
5/10✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 12 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 12 times.
✗ Branch 16 not taken.
|
12 | m_vecs.Get("velocityInterfaceOld").copyFrom(m_vecs.Get("velocityInterface")); |
112 |
5/10✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 12 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 12 times.
✗ Branch 16 not taken.
|
12 | m_seqVecs.Get("velocityInterfaceOld").copyFrom(m_seqVecs.Get("velocityInterface")); |
113 | /// At the same time we std::set the old ones to zero. | ||
114 |
3/6✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
|
12 | m_vecs.Get("velocityInterface").set(0.0); |
115 |
3/6✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
|
12 | m_seqVecs.Get("velocityInterface").set(0.0); |
116 | 12 | } | |
117 | // ====================================================================== | ||
118 | // now the privates methods | ||
119 | // ====================================================================== | ||
120 | |||
121 | // Function the initialize the feiop, it is called in | ||
122 | // the assembly loop of the matrix in linearProblem | ||
123 | void | ||
124 | 332 | LinearProblemPerfectFluid::initPerElementType(ElementType /*eltType*/, FlagMatrixRHS /*flagMatrixRHS*/) { | |
125 | 332 | felInt iIop = m_listVariable.getVariableIdList(iop); | |
126 | 332 | m_feIop=m_listCurrentFiniteElement[iIop]; | |
127 | 332 | } | |
128 | // Function the compute the elementary matrix for the laplacian | ||
129 | // called in the assembly loop of the matrix in linearProblem | ||
130 | void | ||
131 | 598928 | LinearProblemPerfectFluid::computeElementArray(const std::vector<Point*>& elemPoint, const std::vector<felInt>& /*elemIdPoint*/, felInt& /*iel*/, FlagMatrixRHS flagMatrixRHS) { | |
132 | 598928 | m_feIop->updateFirstDeriv(0, elemPoint); | |
133 |
4/4✓ Branch 0 taken 591712 times.
✓ Branch 1 taken 7216 times.
✓ Branch 2 taken 7216 times.
✓ Branch 3 taken 584496 times.
|
598928 | if ( ( flagMatrixRHS == FlagMatrixRHS::matrix_and_rhs ) || ( flagMatrixRHS == FlagMatrixRHS::only_matrix ) ) { |
134 | 14432 | m_elementMat[0]->grad_phi_i_grad_phi_j( /*coeff*/1.,*m_feIop,/*iblock*/0,/*jblock*/0,/*numOfComponents*/1); | |
135 | } | ||
136 | 598928 | } | |
137 | } | ||
138 |