GCC Code Coverage Report


Directory: ./
File: HyperelasticityLaws/Ogden.cpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 47 47 100.0%
Branches: 2 4 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: Vicente Mataix Ferrandiz
13 //
14
15 // System includes
16 #include <string>
17 #include <cmath>
18 #include <limits>
19
20 // External includes
21
22 // Project includes
23 #include "Core/felisceTools.hpp"
24 #include "Core/felisceParam.hpp"
25 #include "HyperelasticityLaws/Ogden.hpp"
26
27 namespace felisce
28 {
29
30 574 Ogden::Ogden()
31 : BaseClassType(),
32 574 m_C1(1.e20), // silly value on purpose
33 574 m_C2(1.e20),
34 574 m_a(1.e20)
35 {
36 574 }
37
38 /***********************************************************************************/
39 /***********************************************************************************/
40
41 10 void Ogden::InitParameters()
42 {
43 // Call base class
44 10 BaseClassType::InitParameters();
45
46 10 const auto& r_ogden = FelisceParam::instance().Ogden;
47 10 m_C1 = r_ogden.C1;
48 10 m_C2 = r_ogden.C2;
49 10 m_a = r_ogden.a;
50 10 }
51
52 /***********************************************************************************/
53 /***********************************************************************************/
54
55 3 double Ogden::W() const
56 {
57 3 BaseClassType::W();
58
59 3 const double I1 = HyperElasticLaw::m_invariants[0];
60 3 const double I2 = HyperElasticLaw::m_invariants[1];
61 3 const double I3 = HyperElasticLaw::m_invariants[2];
62
63 // Law:
64 // W = C1*(I1-3)+C2*(I2-3)+a*(I3-1)-(C1+2*C2+a)*Log[I3]
65
66 3 return m_C1 * (I1 - 3.0) + m_C2 * (I2 - 3.0) + m_a * (I3 - 1.0) - (m_C1 + 2.0 * m_C2 + m_a) * std::log(I3);
67 }
68
69 /***********************************************************************************/
70 /***********************************************************************************/
71
72 2 double Ogden::FirstDerivativeWFirstInvariant() const
73 {
74 2 BaseClassType::FirstDerivativeWFirstInvariant();
75 2 return m_C1;
76 }
77
78 /***********************************************************************************/
79 /***********************************************************************************/
80
81 2 double Ogden::FirstDerivativeWSecondInvariant() const
82 {
83 2 BaseClassType::FirstDerivativeWSecondInvariant();
84 2 return m_C2;
85 }
86
87 /***********************************************************************************/
88 /***********************************************************************************/
89
90 2 double Ogden::FirstDerivativeWThirdInvariant() const
91 {
92 2 BaseClassType::FirstDerivativeWThirdInvariant();
93
94 2 const double I3 = HyperElasticLaw::m_invariants[2];
95
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 FEL_ASSERT("I3 should be strictly positive! (and more precisely somewhere in the vicinity of 1.)" && std::abs(I3) > std::numeric_limits<double>::epsilon());
96
97 2 return m_a - (m_C1 + 2.0 * m_C2 + m_a)/I3;
98 }
99
100 /***********************************************************************************/
101 /***********************************************************************************/
102
103 2 double Ogden::SecondDerivativeWFirstInvariant() const
104 {
105 2 return 0.0;
106 }
107
108 /***********************************************************************************/
109 /***********************************************************************************/
110
111 2 double Ogden::SecondDerivativeWSecondInvariant() const
112 {
113 2 return 0.0;
114 }
115
116 /***********************************************************************************/
117 /***********************************************************************************/
118
119 2 double Ogden::SecondDerivativeWThirdInvariant() const
120 {
121 2 BaseClassType::SecondDerivativeWThirdInvariant();
122
123 2 const double I3 = HyperElasticLaw::m_invariants[2];
124
125
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 FEL_ASSERT("I3 should be strictly positive!" && std::abs(I3) > std::numeric_limits<double>::epsilon());
126
127 2 return (m_C1 + 2.0 * m_C2 + m_a)/std::pow(I3, 2);
128 }
129
130 /***********************************************************************************/
131 /***********************************************************************************/
132
133 2 double Ogden::SecondDerivativeWFirstAndSecondInvariant() const
134 {
135 2 BaseClassType::SecondDerivativeWFirstAndSecondInvariant();
136
137 2 return 0.0;
138 }
139
140 /***********************************************************************************/
141 /***********************************************************************************/
142
143 2 double Ogden::SecondDerivativeWFirstAndThirdInvariant() const
144 {
145 2 BaseClassType::SecondDerivativeWFirstAndThirdInvariant();
146
147 2 return 0.0;
148 }
149
150 /***********************************************************************************/
151 /***********************************************************************************/
152
153 2 double Ogden::SecondDerivativeWSecondAndThirdInvariant() const
154 {
155 2 BaseClassType::SecondDerivativeWSecondAndThirdInvariant();
156
157 2 return 0.0;
158 }
159
160 } // namespace felisce
161