Directory: | ./ |
---|---|
File: | FiniteElement/quadratureRule.cpp |
Date: | 2024-04-14 07:32:34 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 91 | 116 | 78.4% |
Branches: | 65 | 134 | 48.5% |
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: J-F. Gerbeau | ||
13 | // | ||
14 | |||
15 | // System includes | ||
16 | |||
17 | // External includes | ||
18 | |||
19 | // Project includes | ||
20 | #include "quadratureRule.hpp" | ||
21 | |||
22 | namespace felisce | ||
23 | { | ||
24 | 15792 | QuadratureRule::QuadratureRule( | |
25 | const QuadraturePoint* point, | ||
26 | const std::string name, | ||
27 | const RefShape& shape, | ||
28 | const int numQuadraturePoint, | ||
29 | const int degreeOfExactness | ||
30 | 15792 | ) : m_point( point ), | |
31 | 15792 | m_shape( &shape ), | |
32 |
2/4✓ Branch 2 taken 15792 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 15792 times.
✗ Branch 6 not taken.
|
15792 | m_name( name ) |
33 | { | ||
34 | 15792 | m_numQuadraturePoint[0] = numQuadraturePoint; | |
35 | 15792 | m_degreeOfExactness[0] = degreeOfExactness; | |
36 | 15792 | } | |
37 | |||
38 | /***********************************************************************************/ | ||
39 | /***********************************************************************************/ | ||
40 | |||
41 | 15228 | QuadratureRule::QuadratureRule( | |
42 | const QuadratureRule& rQuadratureRule1, | ||
43 | const QuadratureRule& rQuadratureRule2, | ||
44 | const std::string name, | ||
45 | const RefShape& shape, | ||
46 | const double Coefficient | ||
47 | 15228 | ) : m_shape( &shape ), | |
48 |
2/4✓ Branch 2 taken 15228 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 15228 times.
✗ Branch 6 not taken.
|
15228 | m_name( name ) |
49 | { | ||
50 | // Assign values | ||
51 |
1/2✓ Branch 1 taken 15228 times.
✗ Branch 2 not taken.
|
15228 | m_numQuadraturePoint = new int[3]; |
52 | 15228 | m_numQuadraturePoint[0] = rQuadratureRule1.numQuadraturePoint() * rQuadratureRule2.numQuadraturePoint(); | |
53 | 15228 | m_numQuadraturePoint[1] = rQuadratureRule1.numQuadraturePoint(); | |
54 | 15228 | m_numQuadraturePoint[2] = rQuadratureRule2.numQuadraturePoint(); | |
55 |
1/2✓ Branch 1 taken 15228 times.
✗ Branch 2 not taken.
|
15228 | m_degreeOfExactness = new int[3]; |
56 |
2/2✓ Branch 2 taken 6768 times.
✓ Branch 3 taken 8460 times.
|
15228 | m_degreeOfExactness[0] = rQuadratureRule1.degreeOfExactness() > rQuadratureRule2.degreeOfExactness() ? rQuadratureRule1.degreeOfExactness() : rQuadratureRule2.degreeOfExactness(); |
57 | 15228 | m_degreeOfExactness[1] = rQuadratureRule1.degreeOfExactness(); | |
58 | 15228 | m_degreeOfExactness[2] = rQuadratureRule2.degreeOfExactness(); | |
59 | |||
60 | // Getting the points | ||
61 | 15228 | const QuadraturePoint* point1 = rQuadratureRule1.quadraturePoints(); | |
62 | 15228 | const QuadraturePoint* point2 = rQuadratureRule2.quadraturePoints(); | |
63 | |||
64 | // Fill QuadraturePoint | ||
65 |
4/6✓ Branch 0 taken 15228 times.
✗ Branch 1 not taken.
✓ Branch 4 taken 15228 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 128592 times.
✓ Branch 8 taken 15228 times.
|
143820 | QuadraturePoint* points = new QuadraturePoint[m_numQuadraturePoint[0]]; |
66 |
2/2✓ Branch 0 taken 64296 times.
✓ Branch 1 taken 15228 times.
|
79524 | for (int i = 0; i < m_numQuadraturePoint[1]; ++i) { |
67 |
2/2✓ Branch 0 taken 128592 times.
✓ Branch 1 taken 64296 times.
|
192888 | for (int j = 0; j < m_numQuadraturePoint[2]; ++j) { |
68 | 128592 | points[i * m_numQuadraturePoint[2] + j] = QuadraturePoint(point1[i].x(), point1[i].y(), point2[j].x(), Coefficient * point1[i].weight() * point2[j].weight()); | |
69 | } | ||
70 | } | ||
71 | 15228 | m_point = points; | |
72 | 15228 | } | |
73 | |||
74 | /***********************************************************************************/ | ||
75 | /***********************************************************************************/ | ||
76 | |||
77 | 15228 | QuadratureRule& QuadratureRule::operator=(const QuadratureRule& QR) | |
78 | { | ||
79 | 15228 | m_point = QR.m_point; | |
80 | 15228 | m_shape = QR.m_shape; | |
81 | 15228 | m_name = QR.m_name; | |
82 | 15228 | m_numQuadraturePoint = QR.m_numQuadraturePoint; | |
83 | 15228 | m_degreeOfExactness = QR.m_degreeOfExactness; | |
84 | |||
85 | 15228 | return *this; | |
86 | } | ||
87 | |||
88 | /***********************************************************************************/ | ||
89 | /***********************************************************************************/ | ||
90 | |||
91 | 170305 | void QuadratureRule::print(int verbose,std::ostream& c) const | |
92 | { | ||
93 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 170305 times.
|
170305 | if(verbose) { |
94 | ✗ | c << "Quadrature Rule:" << std::endl; | |
95 | ✗ | c << " name: " << m_name << std::endl; | |
96 | ✗ | c << " shape:" << m_shape->name() << std::endl; | |
97 | ✗ | c << " degree of exactness: " << m_degreeOfExactness[0] << std::endl; | |
98 | ✗ | c << " numQuadraturePoint: " << m_numQuadraturePoint[0] << std::endl; | |
99 | ✗ | c << " Points: \n"; | |
100 | ✗ | for ( int i = 0; i < m_numQuadraturePoint[0]; i++ ) { | |
101 | ✗ | std::cout << " "; | |
102 | ✗ | m_point[ i ].print(verbose,c); | |
103 | ✗ | std::cout << std::endl; | |
104 | } | ||
105 | } | ||
106 | 170305 | } | |
107 | |||
108 | /***********************************************************************************/ | ||
109 | /***********************************************************************************/ | ||
110 | |||
111 | 5640 | ListOfQuadratureRule::ListOfQuadratureRule( | |
112 | const std::string name, | ||
113 | const int numQuadratureRule, | ||
114 | const QuadratureRule* quadratureRule | ||
115 | 5640 | ): m_name(name), | |
116 |
2/4✓ Branch 1 taken 5640 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5640 times.
✗ Branch 5 not taken.
|
5640 | m_quadratureRule(quadratureRule) |
117 | { | ||
118 | 5640 | m_numQuadratureRule[0] = numQuadratureRule; | |
119 | 5640 | m_maxDegreeOfExactness[0] = 0; | |
120 |
2/2✓ Branch 0 taken 20304 times.
✓ Branch 1 taken 5640 times.
|
25944 | for(int i=0; i<m_numQuadratureRule[0]; i++) { |
121 |
1/2✓ Branch 1 taken 20304 times.
✗ Branch 2 not taken.
|
20304 | if(m_quadratureRule[i].degreeOfExactness()>m_maxDegreeOfExactness[0]) m_maxDegreeOfExactness[0] = m_quadratureRule[i].degreeOfExactness(); |
122 | } | ||
123 |
2/4✓ Branch 0 taken 5640 times.
✗ Branch 1 not taken.
✓ Branch 4 taken 5640 times.
✗ Branch 5 not taken.
|
5640 | m_quadratureByDegreeOfExactness = new int[m_maxDegreeOfExactness[0]+1]; |
124 | 5640 | int iquad=0; | |
125 |
2/2✓ Branch 0 taken 32712 times.
✓ Branch 1 taken 5640 times.
|
38352 | for(int i=0; i<m_maxDegreeOfExactness[0] + 1; i++) { |
126 |
2/2✓ Branch 1 taken 16920 times.
✓ Branch 2 taken 15792 times.
|
32712 | if(m_quadratureRule[iquad].degreeOfExactness()>=i) { |
127 | 16920 | m_quadratureByDegreeOfExactness[i] = iquad; | |
128 | } else { | ||
129 | 15792 | iquad++; | |
130 | 15792 | m_quadratureByDegreeOfExactness[i] = iquad; | |
131 | } | ||
132 | } | ||
133 | 5640 | } | |
134 | |||
135 | /***********************************************************************************/ | ||
136 | /***********************************************************************************/ | ||
137 | |||
138 | 1128 | ListOfQuadratureRule::ListOfQuadratureRule( | |
139 | const std::string name, | ||
140 | const ListOfQuadratureRule& listQuadratureRule1, | ||
141 | const ListOfQuadratureRule& listQuadratureRule2, | ||
142 | const double Coefficient | ||
143 |
1/2✓ Branch 4 taken 1128 times.
✗ Branch 5 not taken.
|
1128 | ) : ListOfQuadratureRule(name, listQuadratureRule1.getNumQuadratureRule(), listQuadratureRule1.getQuadratureRule()) |
144 | { | ||
145 | // Reassign value | ||
146 |
1/2✓ Branch 1 taken 1128 times.
✗ Branch 2 not taken.
|
1128 | m_numQuadratureRule = new int[3]; |
147 | 1128 | m_numQuadratureRule[1] = listQuadratureRule1.getNumQuadratureRule(); | |
148 | 1128 | m_numQuadratureRule[2] = listQuadratureRule2.getNumQuadratureRule(); | |
149 | 1128 | m_numQuadratureRule[0] = m_numQuadratureRule[1] * m_numQuadratureRule[2] ; | |
150 | |||
151 | 1128 | const QuadratureRule* quadratureRule1 = listQuadratureRule1.getQuadratureRule(); | |
152 | 1128 | const QuadratureRule* quadratureRule2 = listQuadratureRule2.getQuadratureRule(); | |
153 | |||
154 | // Update m_quadratureRule with const_cast | ||
155 |
5/10✓ Branch 0 taken 1128 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 1128 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 15228 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15228 times.
✓ Branch 9 taken 1128 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
16356 | QuadratureRule* quad_rule = new QuadratureRule[m_numQuadratureRule[0]]; |
156 |
2/2✓ Branch 0 taken 5076 times.
✓ Branch 1 taken 1128 times.
|
6204 | for (int i = 0; i < m_numQuadratureRule[1]; ++i) { |
157 |
1/2✓ Branch 2 taken 5076 times.
✗ Branch 3 not taken.
|
5076 | const auto& r_name_1 = quadratureRule1[i].refShape().name(); |
158 |
2/2✓ Branch 0 taken 15228 times.
✓ Branch 1 taken 5076 times.
|
20304 | for (int j = 0; j < m_numQuadratureRule[2] ; ++j) { |
159 |
1/2✓ Branch 2 taken 15228 times.
✗ Branch 3 not taken.
|
15228 | const auto& r_name_2 = quadratureRule2[j].refShape().name(); |
160 |
5/6✓ Branch 1 taken 5076 times.
✓ Branch 2 taken 10152 times.
✓ Branch 4 taken 5076 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5076 times.
✓ Branch 7 taken 10152 times.
|
15228 | if (r_name_1 == "QUADRILATERAL" && r_name_2== "SEGMENT") { |
161 |
3/6✓ Branch 1 taken 5076 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 5076 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 5076 times.
✗ Branch 8 not taken.
|
5076 | quad_rule[i * m_numQuadratureRule[2] + j] = QuadratureRule(quadratureRule1[i], quadratureRule2[j], name, HEXAHEDRON, Coefficient); |
162 |
3/6✓ Branch 1 taken 10152 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10152 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10152 times.
✗ Branch 7 not taken.
|
10152 | } else if (r_name_1 == "TRIANGLE" && r_name_2 == "SEGMENT") { |
163 |
3/6✓ Branch 1 taken 10152 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10152 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10152 times.
✗ Branch 8 not taken.
|
10152 | quad_rule[i * m_numQuadratureRule[2] + j] = QuadratureRule(quadratureRule1[i], quadratureRule2[j], name, PRISM, Coefficient); |
164 | } else { | ||
165 | ✗ | FEL_ERROR("Combination not defined: " + r_name_1 + " " + r_name_2); | |
166 | } | ||
167 | 15228 | } | |
168 | 5076 | } | |
169 | 1128 | m_quadratureRule = quad_rule; | |
170 | |||
171 | // Degree of exactness of each value | ||
172 |
1/2✓ Branch 1 taken 1128 times.
✗ Branch 2 not taken.
|
1128 | m_maxDegreeOfExactness = new int[2]; |
173 | 1128 | m_maxDegreeOfExactness[0] = listQuadratureRule1.getMaxDegreeOfExactness(); | |
174 | 1128 | m_maxDegreeOfExactness[1] = listQuadratureRule2.getMaxDegreeOfExactness(); | |
175 | |||
176 | // Append values | ||
177 |
2/4✓ Branch 0 taken 1128 times.
✗ Branch 1 not taken.
✓ Branch 4 taken 1128 times.
✗ Branch 5 not taken.
|
1128 | m_quadratureByDegreeOfExactness = new int[m_maxDegreeOfExactness[0]+m_maxDegreeOfExactness[1]+2]; |
178 | 1128 | const int* quad_exact_1 = listQuadratureRule1.getquadratureByDegreeOfExactness(); | |
179 | 1128 | const int* quad_exact_2 = listQuadratureRule2.getquadratureByDegreeOfExactness(); | |
180 |
2/2✓ Branch 0 taken 7332 times.
✓ Branch 1 taken 1128 times.
|
8460 | for(int i=0; i<m_maxDegreeOfExactness[0] + 1; i++) { |
181 | 7332 | m_quadratureByDegreeOfExactness[i] = quad_exact_1[i]; | |
182 | } | ||
183 |
2/2✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 1128 times.
|
7896 | for(int i=0; i<m_maxDegreeOfExactness[1] + 1; i++) { |
184 | 6768 | m_quadratureByDegreeOfExactness[i + m_maxDegreeOfExactness[0] + 1] = quad_exact_2[i]; | |
185 | } | ||
186 | 1128 | } | |
187 | |||
188 | /***********************************************************************************/ | ||
189 | /***********************************************************************************/ | ||
190 | |||
191 | 503278 | const QuadratureRule& ListOfQuadratureRule::quadratureRuleByExactness(const DegreeOfExactness deg) const | |
192 | { | ||
193 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 503278 times.
|
503278 | FEL_CHECK(deg<=m_maxDegreeOfExactness[0],"Maximum degree of exactness is " << m_maxDegreeOfExactness[0] ); |
194 | 503278 | return m_quadratureRule[m_quadratureByDegreeOfExactness[deg]]; | |
195 | } | ||
196 | |||
197 | /***********************************************************************************/ | ||
198 | /***********************************************************************************/ | ||
199 | |||
200 | 5070 | const QuadratureRule& ListOfQuadratureRule::quadratureRuleByExactness(const DegreeOfExactness degi, const DegreeOfExactness degj) const | |
201 | { | ||
202 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5070 times.
|
5070 | FEL_CHECK(degi<=m_maxDegreeOfExactness[0],"Maximum degree of exactness 0 is " << m_maxDegreeOfExactness[0] ); |
203 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5070 times.
|
5070 | FEL_CHECK(degj<=m_maxDegreeOfExactness[1],"Maximum degree of exactness 1 is " << m_maxDegreeOfExactness[1] ); |
204 | 5070 | const int index_i = m_quadratureByDegreeOfExactness[degi]; | |
205 | 5070 | const int index_j = m_quadratureByDegreeOfExactness[degj + m_maxDegreeOfExactness[0] + 1]; | |
206 | 5070 | return m_quadratureRule[index_i * m_numQuadratureRule[2] + index_j]; | |
207 | } | ||
208 | |||
209 | /***********************************************************************************/ | ||
210 | /***********************************************************************************/ | ||
211 | |||
212 | ✗ | void ListOfQuadratureRule::print(int verbose,std::ostream& c) const | |
213 | { | ||
214 | ✗ | if(verbose) { | |
215 | ✗ | c << "List of Quadrature Rules:" << std::endl; | |
216 | ✗ | c << " name: " << m_name << std::endl; | |
217 | ✗ | c << " maximum degree of exactness: " << m_maxDegreeOfExactness << std::endl; | |
218 | ✗ | c << " Quadrature rules of the list by degree of exactness:" << std::endl; | |
219 | ✗ | for(int i=0; i<=m_maxDegreeOfExactness[0]; i++) { | |
220 | ✗ | int iquad = m_quadratureByDegreeOfExactness[i]; | |
221 | ✗ | std::cout << " Degree " << i << ": " << m_quadratureRule[iquad].name() | |
222 | ✗ | << "(degree of exactness: " << m_quadratureRule[iquad].degreeOfExactness() << ")" << std::endl; | |
223 | } | ||
224 | ✗ | c << " Details of the Quadrature rules of the list:" << std::endl; | |
225 | ✗ | for(int i=0; i<m_numQuadratureRule[0]; i++) { | |
226 | ✗ | std::cout << " "; | |
227 | ✗ | m_quadratureRule[i].print(verbose,c); | |
228 | } | ||
229 | } | ||
230 | } | ||
231 | |||
232 | } | ||
233 |