GCC Code Coverage Report


Directory: ./
File: Solver/linearProblemElasticString.cpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 41 43 95.3%
Branches: 12 24 50.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:
13 //
14
15 // System includes
16
17 // External includes
18
19 // Project includes
20 #include "Solver/linearProblemElasticString.hpp"
21 #include "FiniteElement/elementMatrix.hpp"
22 #include "FiniteElement/elementVector.hpp"
23
24 namespace felisce
25 {
26
27 9 LinearProblemElasticString::LinearProblemElasticString():
28
5/10
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 9 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 9 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 9 times.
✗ Branch 17 not taken.
9 LinearProblem("ElasticString solver")
29 9 {}
30
31 18 LinearProblemElasticString::~LinearProblemElasticString() = default;
32
33
34 9 void LinearProblemElasticString::initialize(std::vector<GeometricMeshRegion::Pointer>& mesh, FelisceTransient::Pointer fstransient, MPI_Comm& comm, bool doUseSNES) {
35
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 LinearProblem::initialize(mesh, comm, doUseSNES);
36 9 m_fstransient = fstransient;
37
38 // only one variable: displacement
39
1/2
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 std::vector<PhysicalVariable> listVariable(1);
40 9 listVariable[0] = displacement;
41
42 // number of components of each variable. The displacement is scalar here but the final solution
43 // is a std::vector (scalar displacement * normal).
44
1/2
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 std::vector<std::size_t> listNumComp(1);
45 9 listNumComp[0] = 1;
46
47 // define unknown of the linear system.
48
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 m_listUnknown.push_back(displacement);
49
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 definePhysicalVariable(listVariable, listNumComp);
50
51 // define parameters of the model
52
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 const auto& r_instance = FelisceParam::instance();
53 9 const double rho = r_instance.densitySolid;
54 9 const double young = r_instance.young;
55 9 const double nu = r_instance.poisson;
56 9 const double epsilon = r_instance.thickness;
57 9 const double radius = r_instance.solidRadius;
58 9 const double tau = m_fstransient->timeStep;
59
60 9 m_mass = rho * epsilon / (tau * tau);
61 9 m_massVel = rho * epsilon / tau;
62 9 m_lap = young * epsilon / (2 * (1 + nu));
63
64
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 if(Tools::equal(radius, 0.))
65 9 m_0 = 0.;
66 else
67 m_0 = young * epsilon / (radius * radius * (1 - nu * nu));
68 9 }
69
70
71 280 void LinearProblemElasticString::initPerElementTypeBD(ElementType eltType, FlagMatrixRHS flagMatrixRHS) {
72 (void) eltType;
73 (void) flagMatrixRHS;
74
75 280 m_iDisplacement = m_listVariable.getVariableIdList(displacement);
76 280 m_feDisp = m_listCurvilinearFiniteElement[m_iDisplacement];
77
78 // define elemField to put term u_n_1.phi_j in RHS.
79 // m_dispLastSol contains the previous time step solution
80 280 m_elemDispVel.initialize(DOF_FIELD, *m_feDisp);
81 280 m_elemDisp.initialize(DOF_FIELD, *m_feDisp);
82
83 // source term (the solution is scalar)
84 280 m_elemRHS.initialize(QUAD_POINT_FIELD, *m_feDisp, 1);
85 280 }
86
87
88 2760 void LinearProblemElasticString::computeElementArrayBD(const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, felInt& iel, FlagMatrixRHS flagMatrixRHS) {
89 (void) elemIdPoint;
90 (void) flagMatrixRHS;
91
92 // update finite element shape functions and its first derivatives at quadrature points
93 2760 m_feDisp->updateMeasNormalContra(0, elemPoint);
94
95 // MATRIX //
96 // time scheme
97 2760 m_elementMatBD[0]->phi_i_phi_j(m_mass, *m_feDisp, 0, 0, 1);
98
99 // 0-th order terms
100 2760 m_elementMatBD[0]->phi_i_phi_j(m_0, *m_feDisp, 0, 0, 1);
101
102 // laplacian
103 2760 m_elementMatBD[0]->grad_phi_i_grad_phi_j(m_lap, *m_feDisp, 0, 0, 1);
104
105 // RHS //
106 // time scheme
107 // rho * epsilon / tau^2 * (2*d^{n-1} - d^{n-2})
108 2760 m_elemDisp.setValue(externalVec(0), *m_feDisp, iel, m_iDisplacement, m_ao, dof());
109 2760 m_elementVectorBD[0]->source(m_mass, *m_feDisp, m_elemDisp, 0, 1);
110 2760 }
111
112
113 void LinearProblemElasticString::computeElementArrayBD(const std::vector<Point*>& elemPoint, const std::vector<felInt>& elemIdPoint, const std::vector<Point*>& elemNormal, const std::vector< std::vector<Point*> >& elemTangent, felInt& iel, FlagMatrixRHS flagMatrixRHS) {
114 (void) elemIdPoint;
115 (void) elemPoint;
116 (void) elemNormal;
117 (void) elemTangent;
118 (void) iel;
119 (void) flagMatrixRHS;
120 }
121 }
122