Directory: | ./ |
---|---|
File: | Tools/test_utilities.cpp |
Date: | 2024-04-14 07:32:34 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 412 | 521 | 79.1% |
Branches: | 311 | 814 | 38.2% |
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 <cstdio> | ||
17 | #include <cstdlib> | ||
18 | |||
19 | // External includes | ||
20 | #include <tabulate/single_include/tabulate/tabulate.hpp> | ||
21 | |||
22 | // Project includes | ||
23 | #include "Model/model.hpp" | ||
24 | #include "Tools/test_utilities.hpp" | ||
25 | #include "Core/felisceTransient.hpp" | ||
26 | |||
27 | namespace felisce | ||
28 | { | ||
29 | |||
30 | namespace TestUtilities | ||
31 | { | ||
32 | |||
33 | 102 | std::string GetCurrentFolder( | |
34 | const std::string rFilename, | ||
35 | const std::string rFullFilename | ||
36 | ) | ||
37 | { | ||
38 | 102 | std::size_t pos = rFullFilename.find(rFilename); | |
39 | 102 | return rFullFilename.substr(0,pos); | |
40 | } | ||
41 | |||
42 | /***********************************************************************************/ | ||
43 | /***********************************************************************************/ | ||
44 | |||
45 | 64 | bool CompareTwoFiles( | |
46 | const std::string& rFile1, | ||
47 | const std::string& rFile2 | ||
48 | ) | ||
49 | { | ||
50 | // Opening both file in read only mode | ||
51 | 64 | FILE *fp1 = fopen(rFile1.c_str(), "r"); | |
52 | 64 | FILE *fp2 = fopen(rFile2.c_str(), "r"); | |
53 | |||
54 |
2/4✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
|
64 | if (fp1 == NULL || fp2 == NULL) { |
55 | ✗ | std::cout << "Error : Files not open" << std::endl; | |
56 | ✗ | return false; | |
57 | } | ||
58 | |||
59 | // Fetching character of two file | ||
60 | // in two variable ch1 and ch2 | ||
61 | 64 | char ch1 = getc(fp1); | |
62 | 64 | char ch2 = getc(fp2); | |
63 | |||
64 | // Error keeps track of number of errors pos keeps track of position of errors line keeps track of error line | ||
65 | 64 | int error = 0, pos = 0, line = 1; | |
66 | |||
67 | // iterate loop till end of file | ||
68 |
3/4✓ Branch 0 taken 107772 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 107772 times.
✗ Branch 3 not taken.
|
107836 | while (ch1 != EOF && ch2 != EOF) { |
69 | 107772 | ++pos; | |
70 | |||
71 | // If both variable encounters new line then line variable is incremented and pos variable is set to 0 | ||
72 |
4/4✓ Branch 0 taken 4812 times.
✓ Branch 1 taken 102960 times.
✓ Branch 2 taken 4810 times.
✓ Branch 3 taken 2 times.
|
107772 | if (ch1 == '\n' && ch2 == '\n') { |
73 | 4810 | ++line; | |
74 | 4810 | pos = 0; | |
75 | } | ||
76 | |||
77 | // If fetched data is not equal then | ||
78 | // error is incremented | ||
79 |
2/2✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 106108 times.
|
107772 | if (ch1 != ch2) { |
80 | 1664 | ++error; | |
81 | 1664 | std::cout << "Error: Line Number : " << line << "\t Position : " << pos << std::endl; | |
82 | } | ||
83 | |||
84 | // Fetching character until end of file | ||
85 | 107772 | ch1 = getc(fp1); | |
86 | 107772 | ch2 = getc(fp2); | |
87 | } | ||
88 | |||
89 | // Closing both files | ||
90 | 64 | fclose(fp1); | |
91 | 64 | fclose(fp2); | |
92 | |||
93 |
2/2✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
|
64 | if (error == 0) { |
94 | 62 | return true; | |
95 | } else { | ||
96 | 2 | return false; | |
97 | } | ||
98 | } | ||
99 | |||
100 | /***********************************************************************************/ | ||
101 | /***********************************************************************************/ | ||
102 | |||
103 | 13 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshLine(const std::array<double, 3> Delta) | |
104 | { | ||
105 | std::map<int,std::vector<felInt>> list_elements = | ||
106 | { | ||
107 |
2/4✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
|
26 | std::pair<int,std::vector<felInt>>(1, {0}) |
108 |
1/2✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
|
52 | }; |
109 | |||
110 |
1/2✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
|
13 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
111 | |||
112 | 13 | p_mesh_region->numCoor() = 3; | |
113 | 13 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh3D; | |
114 | 13 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
115 |
1/2✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
|
13 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Seg2) = list_elements[1].size(); |
116 | |||
117 | 13 | auto& r_points = p_mesh_region->listPoints(); | |
118 |
1/2✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
|
13 | r_points.emplace_back(0.0, 0.0, 0.0); |
119 |
1/2✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
|
13 | r_points.emplace_back(Delta[0], Delta[1], Delta[2]); |
120 | |||
121 |
1/2✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
|
13 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Seg2); |
122 |
1/2✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
|
13 | std::vector<felInt> elem0({1,2}); |
123 |
1/2✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
|
13 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Seg2, 0, elem0, true); |
124 | |||
125 |
1/2✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
|
13 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Seg2); |
126 |
1/2✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
|
13 | p_mesh_region->setBagElementTypeDomain(); |
127 |
1/2✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
|
13 | p_mesh_region->setBagElementTypeDomainBoundary(); |
128 | |||
129 | 26 | return p_mesh_region; | |
130 | 13 | } | |
131 | |||
132 | /***********************************************************************************/ | ||
133 | /***********************************************************************************/ | ||
134 | |||
135 | 34 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshTriangle() | |
136 | { | ||
137 | std::map<int,std::vector<felInt>> list_elements = | ||
138 | { | ||
139 |
2/4✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
|
68 | std::pair<int,std::vector<felInt>>(1, {0}) |
140 |
1/2✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
|
136 | }; |
141 | |||
142 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
143 | |||
144 | 34 | p_mesh_region->numCoor() = 2; | |
145 | 34 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh2D; | |
146 | 34 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
147 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Tria3) = list_elements[1].size(); |
148 | |||
149 | 34 | auto& r_points = p_mesh_region->listPoints(); | |
150 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | r_points.emplace_back(0.0, 0.0, 0.0); |
151 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | r_points.emplace_back(1.0, 0.0, 0.0); |
152 |
1/2✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
|
34 | r_points.emplace_back(1.0, 1.0, 0.0); |
153 | |||
154 |
1/2✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
|
34 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Tria3); |
155 |
1/2✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
|
34 | std::vector<felInt> elem0({1,2,3}); |
156 |
1/2✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
|
34 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tria3, 0, elem0, true); |
157 | |||
158 |
1/2✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
|
34 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Tria3); |
159 |
1/2✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
|
34 | p_mesh_region->setBagElementTypeDomain(); |
160 |
1/2✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
|
34 | p_mesh_region->setBagElementTypeDomainBoundary(); |
161 | |||
162 | // Set normals manually | ||
163 |
1/2✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
|
34 | p_mesh_region->allocateListNormalsAndTangents(); |
164 | 34 | Point aux_normal(0.0,0.0,1.0); | |
165 | 34 | p_mesh_region->listNormal(0) = aux_normal; | |
166 | 34 | p_mesh_region->listNormal(1) = aux_normal; | |
167 | 34 | p_mesh_region->listNormal(2) = aux_normal; | |
168 | |||
169 | 68 | return p_mesh_region; | |
170 | 34 | } | |
171 | |||
172 | /***********************************************************************************/ | ||
173 | /***********************************************************************************/ | ||
174 | |||
175 | 2 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshInvertedTriangle() | |
176 | { | ||
177 | std::map<int,std::vector<felInt>> list_elements = | ||
178 | { | ||
179 |
2/4✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
4 | std::pair<int,std::vector<felInt>>(1, {0}) |
180 |
1/2✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
8 | }; |
181 | |||
182 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
183 | |||
184 | 2 | p_mesh_region->numCoor() = 2; | |
185 | 2 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh2D; | |
186 | 2 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
187 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Tria3) = list_elements[1].size(); |
188 | |||
189 | 2 | auto& r_points = p_mesh_region->listPoints(); | |
190 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 0.0, 0.0); |
191 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(1.0, 0.0, 0.0); |
192 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(1.0, 1.0, 0.0); |
193 | |||
194 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Tria3); |
195 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | std::vector<felInt> elem0({3,2,1}); |
196 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tria3, 0, elem0, true); |
197 | |||
198 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Tria3); |
199 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setBagElementTypeDomain(); |
200 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setBagElementTypeDomainBoundary(); |
201 | |||
202 | // Set normals manually | ||
203 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->allocateListNormalsAndTangents(); |
204 | 2 | Point aux_normal(0.0,0.0,-1.0); | |
205 | 2 | p_mesh_region->listNormal(0) = aux_normal; | |
206 | 2 | p_mesh_region->listNormal(1) = aux_normal; | |
207 | 2 | p_mesh_region->listNormal(2) = aux_normal; | |
208 | |||
209 | 4 | return p_mesh_region; | |
210 | 2 | } | |
211 | |||
212 | /***********************************************************************************/ | ||
213 | /***********************************************************************************/ | ||
214 | |||
215 | 9 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshTriangles() | |
216 | { | ||
217 | std::map<int,std::vector<felInt>> list_elements = | ||
218 | { | ||
219 |
2/4✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 9 times.
✗ Branch 6 not taken.
|
18 | std::pair<int,std::vector<felInt>>(1, {0,1}) |
220 |
1/2✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
|
36 | }; |
221 | |||
222 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
223 | |||
224 | 9 | p_mesh_region->numCoor() = 2; | |
225 | 9 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh2D; | |
226 | 9 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
227 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Tria3) = list_elements[1].size(); |
228 | |||
229 | 9 | auto& r_points = p_mesh_region->listPoints(); | |
230 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | r_points.emplace_back(0.0, 0.0, 0.0); |
231 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | r_points.emplace_back(1.0, 0.0, 0.0); |
232 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | r_points.emplace_back(1.0, 1.0, 0.0); |
233 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | r_points.emplace_back(0.0, 1.0, 0.0); |
234 | |||
235 |
1/2✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Tria3); |
236 |
1/2✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | std::vector<felInt> elem0({1,2,4}); |
237 |
1/2✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tria3, 0, elem0, true); |
238 |
1/2✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | std::vector<felInt> elem1({2,3,4}); |
239 |
1/2✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tria3, 1, elem1, true); |
240 | |||
241 |
1/2✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Tria3); |
242 |
1/2✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | p_mesh_region->setBagElementTypeDomain(); |
243 |
1/2✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | p_mesh_region->setBagElementTypeDomainBoundary(); |
244 | |||
245 | 18 | return p_mesh_region; | |
246 | 9 | } | |
247 | |||
248 | /***********************************************************************************/ | ||
249 | /***********************************************************************************/ | ||
250 | |||
251 | 21 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshQuadrilaterals() | |
252 | { | ||
253 | std::map<int,std::vector<felInt>> list_elements = | ||
254 | { | ||
255 |
2/4✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
|
42 | std::pair<int,std::vector<felInt>>(1, {0}) |
256 |
1/2✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
84 | }; |
257 | |||
258 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
259 | |||
260 | 21 | p_mesh_region->numCoor() = 2; | |
261 | 21 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh2D; | |
262 | 21 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
263 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Quad4) = list_elements[1].size(); |
264 | |||
265 | 21 | auto& r_points = p_mesh_region->listPoints(); | |
266 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(0.0, 0.0, 0.0); |
267 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(1.0, 0.0, 0.0); |
268 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(1.0, 1.0, 0.0); |
269 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(0.0, 1.0, 0.0); |
270 | |||
271 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Quad4); |
272 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | std::vector<felInt> elem0({1,2,3,4}); |
273 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Quad4, 0, elem0, true); |
274 | |||
275 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Quad4); |
276 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->setBagElementTypeDomain(); |
277 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->setBagElementTypeDomainBoundary(); |
278 | |||
279 | 42 | return p_mesh_region; | |
280 | 21 | } | |
281 | |||
282 | /***********************************************************************************/ | ||
283 | /***********************************************************************************/ | ||
284 | |||
285 | 2 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshTetrahedron() | |
286 | { | ||
287 | std::map<int,std::vector<felInt>> list_elements = | ||
288 | { | ||
289 |
2/4✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
4 | std::pair<int,std::vector<felInt>>(1, {0}) |
290 |
1/2✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
8 | }; |
291 | |||
292 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
293 | |||
294 | 2 | p_mesh_region->numCoor() = 3; | |
295 | 2 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh3D; | |
296 | 2 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
297 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Tetra4) = list_elements[1].size(); |
298 | |||
299 | 2 | auto& r_points = p_mesh_region->listPoints(); | |
300 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 0.0, 0.0); |
301 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(1.0, 0.0, 0.0); |
302 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 1.0, 0.0); |
303 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 0.0, 1.0); |
304 | |||
305 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Tetra4); |
306 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | std::vector<felInt> elem0({1,2,3,4}); |
307 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tetra4, 0, elem0, true); |
308 | |||
309 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Tetra4); |
310 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setBagElementTypeDomain(); |
311 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setBagElementTypeDomainBoundary(); |
312 | |||
313 | 4 | return p_mesh_region; | |
314 | 2 | } | |
315 | |||
316 | /***********************************************************************************/ | ||
317 | /***********************************************************************************/ | ||
318 | |||
319 | 2 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshInvertedTetrahedron() | |
320 | { | ||
321 | std::map<int,std::vector<felInt>> list_elements = | ||
322 | { | ||
323 |
2/4✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
4 | std::pair<int,std::vector<felInt>>(1, {0}) |
324 |
1/2✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
8 | }; |
325 | |||
326 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
327 | |||
328 | 2 | p_mesh_region->numCoor() = 3; | |
329 | 2 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh3D; | |
330 | 2 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
331 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Tetra4) = list_elements[1].size(); |
332 | |||
333 | 2 | auto& r_points = p_mesh_region->listPoints(); | |
334 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 0.0, 0.0); |
335 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(1.0, 0.0, 0.0); |
336 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 1.0, 0.0); |
337 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 0.0, 1.0); |
338 | |||
339 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Tetra4); |
340 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | std::vector<felInt> elem0({4,1,2,3}); |
341 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tetra4, 0, elem0, true); |
342 | |||
343 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Tetra4); |
344 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setBagElementTypeDomain(); |
345 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setBagElementTypeDomainBoundary(); |
346 | |||
347 | 4 | return p_mesh_region; | |
348 | 2 | } | |
349 | |||
350 | /***********************************************************************************/ | ||
351 | /***********************************************************************************/ | ||
352 | |||
353 | 21 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshTetrahedra() | |
354 | { | ||
355 | std::map<int,std::vector<felInt>> list_elements = | ||
356 | { | ||
357 |
2/4✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
|
42 | std::pair<int,std::vector<felInt>>(1, {0,1,2,3,4}) |
358 |
1/2✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
|
84 | }; |
359 | |||
360 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
361 | |||
362 | 21 | p_mesh_region->numCoor() = 3; | |
363 | 21 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh3D; | |
364 | 21 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
365 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Tetra4) = list_elements[1].size(); |
366 | |||
367 | 21 | auto& r_points = p_mesh_region->listPoints(); | |
368 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(0.0, 0.0, 0.0); |
369 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(1.0, 0.0, 0.0); |
370 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(1.0, 1.0, 0.0); |
371 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(0.0, 1.0, 0.0); |
372 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(0.0, 0.0, 1.0); |
373 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(1.0, 0.0, 1.0); |
374 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(1.0, 1.0, 1.0); |
375 |
1/2✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
|
21 | r_points.emplace_back(0.0, 1.0, 1.0); |
376 | |||
377 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Tetra4); |
378 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | std::vector<felInt> elem0({1,2,4,5}); |
379 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tetra4, 0, elem0, true); |
380 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | std::vector<felInt> elem1({2,3,4,7}); |
381 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tetra4, 1, elem1, true); |
382 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | std::vector<felInt> elem2({2,7,4,5}); |
383 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tetra4, 2, elem2, true); |
384 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | std::vector<felInt> elem3({2,7,6,5}); |
385 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tetra4, 3, elem3, true); |
386 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | std::vector<felInt> elem4({4,7,8,5}); |
387 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Tetra4, 4, elem4, true); |
388 | |||
389 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Tetra4); |
390 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->setBagElementTypeDomain(); |
391 |
1/2✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
21 | p_mesh_region->setBagElementTypeDomainBoundary(); |
392 | |||
393 | 42 | return p_mesh_region; | |
394 | 21 | } | |
395 | |||
396 | /***********************************************************************************/ | ||
397 | /***********************************************************************************/ | ||
398 | |||
399 | 43 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshHexahedron() | |
400 | { | ||
401 | std::map<int,std::vector<felInt>> list_elements = | ||
402 | { | ||
403 |
2/4✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 43 times.
✗ Branch 6 not taken.
|
86 | std::pair<int,std::vector<felInt>>(1, {0}) |
404 |
1/2✓ Branch 3 taken 43 times.
✗ Branch 4 not taken.
|
172 | }; |
405 | |||
406 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
407 | |||
408 | 43 | p_mesh_region->numCoor() = 3; | |
409 | 43 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh3D; | |
410 | 43 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
411 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Hexa8) = list_elements[1].size(); |
412 | |||
413 | 43 | auto& r_points = p_mesh_region->listPoints(); | |
414 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | r_points.emplace_back(0.0, 0.0, 0.0); |
415 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | r_points.emplace_back(1.0, 0.0, 0.0); |
416 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | r_points.emplace_back(1.0, 1.0, 0.0); |
417 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | r_points.emplace_back(0.0, 1.0, 0.0); |
418 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | r_points.emplace_back(0.0, 0.0, 1.0); |
419 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | r_points.emplace_back(1.0, 0.0, 1.0); |
420 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | r_points.emplace_back(1.0, 1.0, 1.0); |
421 |
1/2✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
|
43 | r_points.emplace_back(0.0, 1.0, 1.0); |
422 | |||
423 |
1/2✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
|
43 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Hexa8); |
424 |
1/2✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
|
43 | std::vector<felInt> elem0({1,2,3,4,5,6,7,8}); |
425 |
1/2✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
|
43 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Hexa8, 0, elem0, true); |
426 | |||
427 |
1/2✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
|
43 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Hexa8); |
428 |
1/2✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
|
43 | p_mesh_region->setBagElementTypeDomain(); |
429 |
1/2✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
|
43 | p_mesh_region->setBagElementTypeDomainBoundary(); |
430 | |||
431 | 86 | return p_mesh_region; | |
432 | 43 | } | |
433 | |||
434 | /***********************************************************************************/ | ||
435 | /***********************************************************************************/ | ||
436 | |||
437 | 2 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshInvertedHexahedron() | |
438 | { | ||
439 | std::map<int,std::vector<felInt>> list_elements = | ||
440 | { | ||
441 |
2/4✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
|
4 | std::pair<int,std::vector<felInt>>(1, {0}) |
442 |
1/2✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
8 | }; |
443 | |||
444 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
445 | |||
446 | 2 | p_mesh_region->numCoor() = 3; | |
447 | 2 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh3D; | |
448 | 2 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
449 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Hexa8) = list_elements[1].size(); |
450 | |||
451 | 2 | auto& r_points = p_mesh_region->listPoints(); | |
452 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 0.0, 0.0); |
453 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(1.0, 0.0, 0.0); |
454 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(1.0, 1.0, 0.0); |
455 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 1.0, 0.0); |
456 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 0.0, 1.0); |
457 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(1.0, 0.0, 1.0); |
458 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(1.0, 1.0, 1.0); |
459 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | r_points.emplace_back(0.0, 1.0, 1.0); |
460 | |||
461 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Hexa8); |
462 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | std::vector<felInt> elem0({5,6,7,8,1,2,3,4}); |
463 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Hexa8, 0, elem0, true); |
464 | |||
465 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Hexa8); |
466 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setBagElementTypeDomain(); |
467 |
1/2✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | p_mesh_region->setBagElementTypeDomainBoundary(); |
468 | |||
469 | 4 | return p_mesh_region; | |
470 | 2 | } | |
471 | |||
472 | /***********************************************************************************/ | ||
473 | /***********************************************************************************/ | ||
474 | |||
475 | 39 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshPrism() | |
476 | { | ||
477 | std::map<int,std::vector<felInt>> list_elements = | ||
478 | { | ||
479 |
2/4✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 39 times.
✗ Branch 6 not taken.
|
78 | std::pair<int,std::vector<felInt>>(1, {0}) |
480 |
1/2✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
|
156 | }; |
481 | |||
482 |
1/2✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
|
39 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
483 | |||
484 | 39 | p_mesh_region->numCoor() = 3; | |
485 | 39 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh3D; | |
486 | 39 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
487 |
1/2✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
|
39 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Prism6) = list_elements[1].size(); |
488 | |||
489 | 39 | auto& r_points = p_mesh_region->listPoints(); | |
490 |
1/2✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
|
39 | r_points.emplace_back(0.0, 0.0, 0.0); |
491 |
1/2✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
|
39 | r_points.emplace_back(1.0, 0.0, 0.0); |
492 |
1/2✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
|
39 | r_points.emplace_back(1.0, 1.0, 0.0); |
493 |
1/2✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
|
39 | r_points.emplace_back(0.0, 0.0, 1.0); |
494 |
1/2✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
|
39 | r_points.emplace_back(1.0, 0.0, 1.0); |
495 |
1/2✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
|
39 | r_points.emplace_back(1.0, 1.0, 1.0); |
496 | |||
497 |
1/2✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
39 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Prism6); |
498 |
1/2✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
39 | std::vector<felInt> elem0({1,2,3,4,5,6}); |
499 |
1/2✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
39 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Prism6, 0, elem0, true); |
500 | |||
501 |
1/2✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
39 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Prism6); |
502 |
1/2✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
39 | p_mesh_region->setBagElementTypeDomain(); |
503 |
1/2✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
|
39 | p_mesh_region->setBagElementTypeDomainBoundary(); |
504 | |||
505 | 78 | return p_mesh_region; | |
506 | 39 | } | |
507 | |||
508 | /***********************************************************************************/ | ||
509 | /***********************************************************************************/ | ||
510 | |||
511 | 45 | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshPrism9() | |
512 | { | ||
513 | std::map<int,std::vector<felInt>> list_elements = | ||
514 | { | ||
515 |
2/4✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 45 times.
✗ Branch 6 not taken.
|
90 | std::pair<int,std::vector<felInt>>(1, {0}) |
516 |
1/2✓ Branch 3 taken 45 times.
✗ Branch 4 not taken.
|
180 | }; |
517 | |||
518 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); |
519 | |||
520 | 45 | p_mesh_region->numCoor() = 3; | |
521 | 45 | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh3D; | |
522 | 45 | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
523 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | p_mesh_region->numElements(felisce::GeometricMeshRegion::Prism9) = list_elements[1].size(); |
524 | |||
525 | 45 | auto& r_points = p_mesh_region->listPoints(); | |
526 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | r_points.emplace_back(0.0, 0.0, 0.0); |
527 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | r_points.emplace_back(1.0, 0.0, 0.0); |
528 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | r_points.emplace_back(1.0, 1.0, 0.0); |
529 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | r_points.emplace_back(0.0, 0.0, 1.0); |
530 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | r_points.emplace_back(1.0, 0.0, 1.0); |
531 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | r_points.emplace_back(1.0, 1.0, 1.0); |
532 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | r_points.emplace_back(0.0, 0.0, 0.5); |
533 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | r_points.emplace_back(1.0, 0.0, 0.5); |
534 |
1/2✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
|
45 | r_points.emplace_back(1.0, 1.0, 0.5); |
535 | |||
536 |
1/2✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
|
45 | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Prism9); |
537 |
1/2✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
|
45 | std::vector<felInt> elem0({1,2,3,4,5,6,7,8,9}); |
538 |
1/2✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
|
45 | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Prism9, 0, elem0, true); |
539 | |||
540 |
1/2✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
|
45 | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Prism9); |
541 |
1/2✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
|
45 | p_mesh_region->setBagElementTypeDomain(); |
542 |
1/2✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
|
45 | p_mesh_region->setBagElementTypeDomainBoundary(); |
543 | |||
544 | 90 | return p_mesh_region; | |
545 | 45 | } | |
546 | |||
547 | /***********************************************************************************/ | ||
548 | /***********************************************************************************/ | ||
549 | |||
550 | ✗ | felisce::GeometricMeshRegion::Pointer GenerateMinimalMeshPrism15() | |
551 | { | ||
552 | std::map<int,std::vector<felInt>> list_elements = | ||
553 | { | ||
554 | ✗ | std::pair<int,std::vector<felInt>>(1, {0}) | |
555 | ✗ | }; | |
556 | |||
557 | ✗ | auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>(); | |
558 | |||
559 | ✗ | p_mesh_region->numCoor() = 3; | |
560 | ✗ | p_mesh_region->domainDim() = felisce::GeometricMeshRegion::GeoMesh3D; | |
561 | ✗ | p_mesh_region->flagFormatMesh() = felisce::GeometricMeshRegion::FormatMedit; | |
562 | ✗ | p_mesh_region->numElements(felisce::GeometricMeshRegion::Prism15) = list_elements[1].size(); | |
563 | |||
564 | ✗ | auto& r_points = p_mesh_region->listPoints(); | |
565 | ✗ | r_points.emplace_back(0.0, 0.0, 0.0); | |
566 | ✗ | r_points.emplace_back(1.0, 0.0, 0.0); | |
567 | ✗ | r_points.emplace_back(1.0, 1.0, 0.0); | |
568 | ✗ | r_points.emplace_back(0.0, 0.0, 1.0); | |
569 | ✗ | r_points.emplace_back(1.0, 0.0, 1.0); | |
570 | ✗ | r_points.emplace_back(1.0, 1.0, 1.0); | |
571 | ✗ | r_points.emplace_back(0.5, 0.0, 0.0); | |
572 | ✗ | r_points.emplace_back(1.0, 0.5, 0.0); | |
573 | ✗ | r_points.emplace_back(0.5, 0.5, 0.0); | |
574 | ✗ | r_points.emplace_back(0.5, 0.0, 1.0); | |
575 | ✗ | r_points.emplace_back(1.0, 0.5, 1.0); | |
576 | ✗ | r_points.emplace_back(0.5, 0.5, 1.0); | |
577 | ✗ | r_points.emplace_back(0.0, 0.0, 0.5); | |
578 | ✗ | r_points.emplace_back(1.0, 0.0, 0.5); | |
579 | ✗ | r_points.emplace_back(1.0, 1.0, 0.5); | |
580 | |||
581 | ✗ | p_mesh_region->allocateElements(felisce::GeometricMeshRegion::Prism15); | |
582 | ✗ | std::vector<felInt> elem0({0,1,2,3,4,5,6,7,8,9,10,11,12,13,14}); | |
583 | ✗ | p_mesh_region->setOneElement(felisce::GeometricMeshRegion::Prism15, 0, elem0, true); | |
584 | |||
585 | ✗ | p_mesh_region->reorderListElePerRef(list_elements, felisce::GeometricMeshRegion::Prism15); | |
586 | ✗ | p_mesh_region->setBagElementTypeDomain(); | |
587 | ✗ | p_mesh_region->setBagElementTypeDomainBoundary(); | |
588 | |||
589 | ✗ | return p_mesh_region; | |
590 | } | ||
591 | |||
592 | /***********************************************************************************/ | ||
593 | /***********************************************************************************/ | ||
594 | |||
595 | template<class TFEType> | ||
596 | 370 | typename TFEType::Pointer GenerateFiniteElement( | |
597 | const felisce::GeometricMeshRegion::ElementType eltType, | ||
598 | const std::vector<felisce::DegreeOfExactness>& rDegreeOfExactnessVector, | ||
599 | const std::array<double, 3> Delta | ||
600 | ) | ||
601 | { | ||
602 | // Retrieve mesh | ||
603 | 370 | GeometricMeshRegion::Pointer p_mesh = nullptr; | |
604 | |||
605 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 174 times.
|
370 | if (eltType == felisce::GeometricMeshRegion::Seg2) { |
606 |
1/2✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
|
22 | p_mesh = GenerateMinimalMeshLine(Delta); |
607 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 144 times.
|
348 | } else if (eltType == felisce::GeometricMeshRegion::Tria3) { |
608 |
1/2✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
|
60 | p_mesh = GenerateMinimalMeshTriangle(); |
609 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 128 times.
|
288 | } else if (eltType == felisce::GeometricMeshRegion::Quad4) { |
610 |
1/2✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
|
32 | p_mesh = GenerateMinimalMeshQuadrilaterals(); |
611 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 114 times.
|
256 | } else if (eltType == felisce::GeometricMeshRegion::Tetra4) { |
612 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
28 | p_mesh = GenerateMinimalMeshTetrahedra(); |
613 |
2/2✓ Branch 0 taken 37 times.
✓ Branch 1 taken 77 times.
|
228 | } else if (eltType == felisce::GeometricMeshRegion::Hexa8) { |
614 |
1/2✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
|
74 | p_mesh = GenerateMinimalMeshHexahedron(); |
615 |
2/2✓ Branch 0 taken 37 times.
✓ Branch 1 taken 40 times.
|
154 | } else if (eltType == felisce::GeometricMeshRegion::Prism6) { |
616 |
1/2✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
|
74 | p_mesh = GenerateMinimalMeshPrism(); |
617 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
80 | } else if (eltType == felisce::GeometricMeshRegion::Prism9) { |
618 |
1/2✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
|
80 | p_mesh = GenerateMinimalMeshPrism9(); |
619 | ✗ | } else if (eltType == felisce::GeometricMeshRegion::Prism15) { | |
620 | ✗ | p_mesh = GenerateMinimalMeshPrism15(); | |
621 | } else { // Triangle | ||
622 | ✗ | p_mesh = GenerateMinimalMeshTriangle(); | |
623 | } | ||
624 | |||
625 | // Generate element from previous mesh | ||
626 | 370 | const GeoElement* geoEle = GeometricMeshRegion::eltEnumToFelNameGeoEle[eltType].second; | |
627 | 370 | const int typeOfFiniteElement = 0; | |
628 |
1/2✓ Branch 2 taken 185 times.
✗ Branch 3 not taken.
|
370 | const RefElement* refEle = geoEle->defineFiniteEle(eltType, typeOfFiniteElement, *p_mesh); |
629 |
1/2✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
|
370 | auto p_element = felisce::make_shared<TFEType>(*refEle,*geoEle, rDegreeOfExactnessVector); |
630 | |||
631 | /* Now, we generate the integration weights */ | ||
632 | |||
633 | //Points of the current element. | ||
634 | 370 | std::vector<felisce::Point*> elemPoint; | |
635 | |||
636 | //Id of points of the element. | ||
637 | 370 | std::vector<felisce::felInt> elemIdPoint; | |
638 | |||
639 | // Counter of elements | ||
640 | 370 | felInt numElement = 0; | |
641 | |||
642 | // Loop on element types | ||
643 | 370 | const auto numPointPerElt = GeometricMeshRegion::m_numPointsPerElt[eltType]; | |
644 |
1/2✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
|
370 | elemPoint.resize(numPointPerElt, nullptr); |
645 |
1/2✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
|
370 | elemIdPoint.resize(numPointPerElt,0); |
646 | |||
647 |
1/2✓ Branch 2 taken 185 times.
✗ Branch 3 not taken.
|
370 | p_mesh->getOneElement(eltType, numElement, elemIdPoint, elemPoint); |
648 | 370 | ++numElement; | |
649 | |||
650 | // Compute integration points | ||
651 |
1/2✓ Branch 2 taken 185 times.
✗ Branch 3 not taken.
|
370 | p_element->updateMeas(0, elemPoint); |
652 | |||
653 | 740 | return p_element; | |
654 | 370 | } | |
655 | |||
656 | // Explicit instantiation. | ||
657 | template felisce::CurBaseFiniteElement::Pointer GenerateFiniteElement<felisce::CurBaseFiniteElement>(const felisce::GeometricMeshRegion::ElementType eltType, const std::vector<felisce::DegreeOfExactness>& rDegreeOfExactnessVector, const std::array<double, 3> Delta); | ||
658 | template felisce::CurvilinearFiniteElement::Pointer GenerateFiniteElement<felisce::CurvilinearFiniteElement>(const felisce::GeometricMeshRegion::ElementType eltType, const std::vector<felisce::DegreeOfExactness>& rDegreeOfExactnessVector, const std::array<double, 3> Delta); | ||
659 | template felisce::CurrentFiniteElement::Pointer GenerateFiniteElement<felisce::CurrentFiniteElement>(const felisce::GeometricMeshRegion::ElementType eltType, const std::vector<felisce::DegreeOfExactness>& rDegreeOfExactnessVector, const std::array<double, 3> Delta); | ||
660 | |||
661 | /***********************************************************************************/ | ||
662 | /***********************************************************************************/ | ||
663 | |||
664 | template<class TFEType> | ||
665 | 220 | typename TFEType::Pointer GenerateFiniteElement( | |
666 | const felisce::GeometricMeshRegion::ElementType eltType, | ||
667 | const felisce::DegreeOfExactness DegreeOfExactnessVector, | ||
668 | const std::array<double, 3> Delta | ||
669 | ) | ||
670 | { | ||
671 |
2/4✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 110 times.
✗ Branch 6 not taken.
|
440 | return GenerateFiniteElement<TFEType>(eltType, std::vector<felisce::DegreeOfExactness>(1, DegreeOfExactnessVector), Delta); |
672 | } | ||
673 | |||
674 | // Explicit instantiation. | ||
675 | template felisce::CurBaseFiniteElement::Pointer GenerateFiniteElement<felisce::CurBaseFiniteElement>(const felisce::GeometricMeshRegion::ElementType eltType, const felisce::DegreeOfExactness DegreeOfExactnessVector, const std::array<double, 3> Delta); | ||
676 | template felisce::CurvilinearFiniteElement::Pointer GenerateFiniteElement<felisce::CurvilinearFiniteElement>(const felisce::GeometricMeshRegion::ElementType eltType, const felisce::DegreeOfExactness DegreeOfExactnessVector, const std::array<double, 3> Delta); | ||
677 | template felisce::CurrentFiniteElement::Pointer GenerateFiniteElement<felisce::CurrentFiniteElement>(const felisce::GeometricMeshRegion::ElementType eltType, const felisce::DegreeOfExactness DegreeOfExactnessVector, const std::array<double, 3> Delta); | ||
678 | |||
679 | /***********************************************************************************/ | ||
680 | /***********************************************************************************/ | ||
681 | |||
682 | 24 | felisce::ElementVector GenerateElementVector( | |
683 | const felisce::GeometricMeshRegion::ElementType eltType, | ||
684 | const std::size_t NumberOfComponents | ||
685 | ) | ||
686 | { | ||
687 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | auto p_elem = GenerateFiniteElement<felisce::CurBaseFiniteElement>(eltType); |
688 |
3/6✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 7 taken 24 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 24 times.
✗ Branch 11 not taken.
|
72 | return ElementVector(std::vector<const felisce::CurBaseFiniteElement*>{p_elem.get()}, std::vector<std::size_t>{NumberOfComponents}); |
689 | 24 | } | |
690 | |||
691 | /***********************************************************************************/ | ||
692 | /***********************************************************************************/ | ||
693 | |||
694 | 22 | felisce::ElementMatrix GenerateElementMatrix( | |
695 | const felisce::GeometricMeshRegion::ElementType eltType, | ||
696 | const std::size_t NumberOfComponents | ||
697 | ) | ||
698 | { | ||
699 |
1/2✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
|
22 | auto p_elem = GenerateFiniteElement<felisce::CurBaseFiniteElement>(eltType); |
700 |
4/8✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✓ Branch 11 taken 22 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 22 times.
✗ Branch 15 not taken.
|
66 | return ElementMatrix(std::vector<const felisce::CurBaseFiniteElement*>{p_elem.get()},std::vector<std::size_t>{NumberOfComponents},std::vector<std::size_t>{NumberOfComponents}); |
701 | 22 | } | |
702 | |||
703 | /***********************************************************************************/ | ||
704 | /***********************************************************************************/ | ||
705 | |||
706 | template<class TFEType> | ||
707 | 28 | felisce::ElementField GenerateElementField( | |
708 | const TFEType& rElement, | ||
709 | const std::size_t NumberOfComponents, | ||
710 | const ElementFieldType FieldType, | ||
711 | const double Value | ||
712 | ) | ||
713 | { | ||
714 | 28 | auto field = ElementField(); | |
715 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
28 | field.initialize(FieldType, rElement, NumberOfComponents); |
716 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
28 | if (FieldType == CONSTANT_FIELD) { |
717 |
1/2✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
|
28 | field.update(Value); |
718 | } | ||
719 | 28 | return field; | |
720 | } | ||
721 | |||
722 | // Explicit instantiation. | ||
723 | template felisce::ElementField GenerateElementField<felisce::CurvilinearFiniteElement>(const felisce::CurvilinearFiniteElement& rElement, const std::size_t NumberOfComponents, const ElementFieldType FieldType, const double Value); | ||
724 | template felisce::ElementField GenerateElementField<felisce::CurrentFiniteElement>(const felisce::CurrentFiniteElement& rElement, const std::size_t NumberOfComponents, const ElementFieldType FieldType, const double Value); | ||
725 | |||
726 | /***********************************************************************************/ | ||
727 | /***********************************************************************************/ | ||
728 | |||
729 | ✗ | void RetrieveSolutionTable( | |
730 | felisce::LinearProblem& rLinearProblem, | ||
731 | const std::string FileType | ||
732 | ) | ||
733 | { | ||
734 | ✗ | std::vector<double> valueVec(rLinearProblem.numDof()); | |
735 | ✗ | rLinearProblem.sequentialSolution().getAllValuesInAppOrdering(rLinearProblem.ao(), valueVec); | |
736 | |||
737 | ✗ | std::size_t dl_global = 0; | |
738 | ✗ | const std::size_t number_nodes = rLinearProblem.supportDofUnknown()[0].listNode().size(); | |
739 | |||
740 | ✗ | tabulate::Table solution; | |
741 | ✗ | solution.add_row({"NODE", "DL", "DL GLOBAL", "SOLUTION"}); | |
742 | ✗ | for (std::size_t i_node = 0; i_node < number_nodes; ++i_node) { | |
743 | ✗ | for (std::size_t i_dim = 0; i_dim < 3; ++i_dim) { | |
744 | ✗ | std::stringstream buffer; | |
745 | ✗ | buffer << std::setprecision(16) << std::scientific << valueVec[dl_global]; | |
746 | ✗ | if (i_dim == 0) { | |
747 | ✗ | solution.add_row({std::to_string(i_node + 1), std::to_string(i_dim + 1), std::to_string(dl_global + 1), buffer.str()}); | |
748 | } else { | ||
749 | ✗ | solution.add_row({"", std::to_string(i_dim + 1), std::to_string(dl_global + 1), buffer.str()}); | |
750 | } | ||
751 | ✗ | dl_global++; | |
752 | } | ||
753 | } | ||
754 | |||
755 | // Right align NODE, DL, DL GLOBAL column | ||
756 | ✗ | solution.column(0).format().font_align(tabulate::FontAlign::right); | |
757 | ✗ | solution.column(1).format().font_align(tabulate::FontAlign::right); | |
758 | ✗ | solution.column(2).format().font_align(tabulate::FontAlign::right); | |
759 | |||
760 | // Center align SOLUTION column | ||
761 | ✗ | solution.column(3).format().font_align(tabulate::FontAlign::center); | |
762 | |||
763 | // Center-align and color header cells | ||
764 | ✗ | for (std::size_t i = 0; i < 4; ++i) { | |
765 | ✗ | solution[0][i].format() | |
766 | ✗ | .font_color(tabulate::Color::yellow) | |
767 | ✗ | .font_align(tabulate::FontAlign::center) | |
768 | ✗ | .font_style({tabulate::FontStyle::bold}); | |
769 | } | ||
770 | |||
771 | // Exported TXT | ||
772 | ✗ | if (FileType == "TXT") { | |
773 | ✗ | std::ofstream txt_file; | |
774 | ✗ | txt_file.open("solution.txt"); | |
775 | ✗ | txt_file << solution.str() << std::endl; | |
776 | ✗ | txt_file.close(); | |
777 | ✗ | } else if (FileType == "MARKDOWN") { // Export to Markdown | |
778 | ✗ | tabulate::MarkdownExporter exporter_md; | |
779 | ✗ | auto markdown = exporter_md.dump(solution); | |
780 | |||
781 | // Exported Markdown | ||
782 | ✗ | std::ofstream markdown_file; | |
783 | ✗ | markdown_file.open("solution.md"); | |
784 | ✗ | markdown_file << markdown << std::endl; | |
785 | ✗ | markdown_file.close(); | |
786 | ✗ | } else if (FileType == "LATEX") { // Export to LaTeX | |
787 | ✗ | tabulate::LatexExporter exporter_latex; | |
788 | ✗ | auto latex = exporter_latex.dump(solution); | |
789 | |||
790 | // Exported LaTeX | ||
791 | ✗ | std::ofstream latex_file; | |
792 | ✗ | latex_file.open("solution.tex"); | |
793 | ✗ | latex_file << latex << std::endl; | |
794 | ✗ | latex_file.close(); | |
795 | } | ||
796 | } | ||
797 | |||
798 | /***********************************************************************************/ | ||
799 | /***********************************************************************************/ | ||
800 | |||
801 | ✗ | void FillTablesResults( | |
802 | felisce::LinearProblem& rLinearProblem, | ||
803 | std::unordered_map<int, felisce::TableInterpolation>& rTables | ||
804 | ) | ||
805 | { | ||
806 | // Retrieve the solution in the current time step | ||
807 | ✗ | std::vector<double> valueVec(rLinearProblem.numDof()); | |
808 | ✗ | rLinearProblem.sequentialSolution().getAllValuesInAppOrdering(rLinearProblem.ao(), valueVec); | |
809 | |||
810 | // Retrieve curremt time | ||
811 | ✗ | const double time = rLinearProblem.model()->fstransient()->time; | |
812 | |||
813 | // Fill the tables | ||
814 | ✗ | for (auto& r_table_pair : rTables) { | |
815 | ✗ | const auto idof = r_table_pair.first; | |
816 | ✗ | auto& r_table = r_table_pair.second; | |
817 | ✗ | r_table.PushBack(time, valueVec[idof]); | |
818 | } | ||
819 | } | ||
820 | |||
821 | /***********************************************************************************/ | ||
822 | /***********************************************************************************/ | ||
823 | |||
824 | 8 | void ImposeSolution( | |
825 | felisce::LinearProblem& rLinearProblem, | ||
826 | const std::vector<double>& rSolution | ||
827 | ) | ||
828 | { | ||
829 | // Set solution | ||
830 | 8 | auto& u = rLinearProblem.solution(); | |
831 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | const felInt numDof = u.getSize(); |
832 | 8 | felInt identityMap[numDof]; | |
833 |
2/2✓ Branch 0 taken 5832 times.
✓ Branch 1 taken 8 times.
|
5840 | for (felInt i=0; i<numDof; i++) { |
834 | 5832 | identityMap[i] = i; | |
835 | } | ||
836 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | AOApplicationToPetsc(rLinearProblem.ao(),numDof,identityMap); |
837 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | u.setValues(numDof,identityMap, rSolution.data(), INSERT_VALUES); |
838 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | u.assembly(); |
839 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | rLinearProblem.gatherSolution(); |
840 | 8 | auto& u_nl = rLinearProblem.evaluationState(); | |
841 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | u_nl.copyFrom(u); |
842 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | rLinearProblem.gatherEvaluationState(); |
843 | 16 | } | |
844 | |||
845 | /***********************************************************************************/ | ||
846 | /***********************************************************************************/ | ||
847 | |||
848 | 8 | void SaveSolutionToFile( | |
849 | felisce::LinearProblem& rLinearProblem, | ||
850 | const std::string& rAppendixName, | ||
851 | const std::size_t Precision, | ||
852 | const bool EvaluationState | ||
853 | ) | ||
854 | { | ||
855 | // Retrieve the solution in the current time step | ||
856 | 8 | const std::size_t number_of_points = rLinearProblem.mesh()->numPoints(); | |
857 | 8 | const std::size_t number_of_dofs = rLinearProblem.numDof(); | |
858 |
1/2✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | std::vector<double> valueVec(number_of_dofs); |
859 | 8 | const std::size_t number_dof_per_node = number_of_dofs / number_of_points; | |
860 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if (EvaluationState) { |
861 | ✗ | rLinearProblem.seqEvaluationState().getAllValuesInAppOrdering(rLinearProblem.ao(), valueVec); | |
862 | } else { | ||
863 |
1/2✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
|
8 | rLinearProblem.sequentialSolution().getAllValuesInAppOrdering(rLinearProblem.ao(), valueVec); |
864 | } | ||
865 | |||
866 | // Save solution to file | ||
867 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | std::ofstream out_file; |
868 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | const std::string file_name = "solution" + rAppendixName + ".out"; |
869 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | out_file.open(file_name); |
870 | 8 | out_file.precision(Precision); | |
871 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | out_file << std::scientific; |
872 |
2/2✓ Branch 0 taken 1944 times.
✓ Branch 1 taken 8 times.
|
1952 | for (std::size_t i_point = 0; i_point < number_of_points; ++i_point) { |
873 |
2/2✓ Branch 0 taken 5832 times.
✓ Branch 1 taken 1944 times.
|
7776 | for (std::size_t i_dof = 0; i_dof < number_dof_per_node; ++i_dof) { |
874 |
3/4✓ Branch 1 taken 2424 times.
✓ Branch 2 taken 3408 times.
✓ Branch 4 taken 2424 times.
✗ Branch 5 not taken.
|
5832 | if (valueVec[i_point * number_dof_per_node + i_dof] >= 0.0) out_file << " "; |
875 |
1/2✓ Branch 2 taken 5832 times.
✗ Branch 3 not taken.
|
5832 | out_file << valueVec[i_point * number_dof_per_node + i_dof]; |
876 |
1/2✓ Branch 1 taken 5832 times.
✗ Branch 2 not taken.
|
5832 | out_file << "\t"; |
877 | } | ||
878 |
1/2✓ Branch 1 taken 1944 times.
✗ Branch 2 not taken.
|
1944 | out_file << "\n"; |
879 | } | ||
880 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | out_file << std::endl; |
881 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | out_file.close(); |
882 | 8 | } | |
883 | |||
884 | /***********************************************************************************/ | ||
885 | /***********************************************************************************/ | ||
886 | |||
887 | ✗ | void SaveRHSToFile( | |
888 | felisce::LinearProblem& rLinearProblem, | ||
889 | const std::string& rAppendixName, | ||
890 | const std::size_t Precision | ||
891 | ) | ||
892 | { | ||
893 | // Retrieve the solution in the current time step | ||
894 | ✗ | const std::size_t number_of_points = rLinearProblem.mesh()->numPoints(); | |
895 | ✗ | const std::size_t number_of_dofs = rLinearProblem.numDof(); | |
896 | ✗ | std::vector<double> valueVec(number_of_dofs); | |
897 | ✗ | const std::size_t number_dof_per_node = number_of_dofs / number_of_points; | |
898 | ✗ | rLinearProblem.vector().getAllValuesInAppOrdering(rLinearProblem.ao(), valueVec); | |
899 | |||
900 | // Save RHS to file | ||
901 | ✗ | std::ofstream out_file; | |
902 | ✗ | const std::string file_name = "rhs" + rAppendixName + ".out"; | |
903 | ✗ | out_file.open(file_name); | |
904 | ✗ | out_file.precision(Precision); | |
905 | ✗ | out_file << std::scientific; | |
906 | ✗ | for (std::size_t i_point = 0; i_point < number_of_points; ++i_point) { | |
907 | ✗ | for (std::size_t i_dof = 0; i_dof < number_dof_per_node; ++i_dof) { | |
908 | ✗ | if (valueVec[i_point * number_dof_per_node + i_dof] >= 0.0) out_file << " "; | |
909 | ✗ | out_file << valueVec[i_point * number_dof_per_node + i_dof]; | |
910 | ✗ | out_file << "\t"; | |
911 | } | ||
912 | ✗ | out_file << "\n"; | |
913 | } | ||
914 | ✗ | out_file << std::endl; | |
915 | ✗ | out_file.close(); | |
916 | } | ||
917 | |||
918 | /***********************************************************************************/ | ||
919 | /***********************************************************************************/ | ||
920 | |||
921 | 9 | std::vector<double> GetSolutionFromFile(const std::string& rFileName) | |
922 | { | ||
923 | // Retrieve the solution in the current file | ||
924 | 9 | std::vector<double> solution; | |
925 | |||
926 | // Opening both file in read only mode | ||
927 |
1/2✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | FILE* fp = fopen(rFileName.c_str(), "r"); |
928 | |||
929 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (fp == NULL) { |
930 | ✗ | std::cout << "Error : Files not open" << std::endl; | |
931 | ✗ | return solution; | |
932 | } | ||
933 | |||
934 | // Fetching character | ||
935 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | char ch = getc(fp); |
936 | |||
937 | // iterate loop till end of file | ||
938 | 9 | std::string word; | |
939 |
2/2✓ Branch 0 taken 161862 times.
✓ Branch 1 taken 9 times.
|
161871 | while (ch != EOF) { |
940 | // If both variable encounters new line then line variable is incremented and pos variable is set to 0 | ||
941 |
9/12✓ Branch 0 taken 152580 times.
✓ Branch 1 taken 9282 times.
✓ Branch 2 taken 152580 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150393 times.
✓ Branch 5 taken 2187 times.
✓ Branch 6 taken 148206 times.
✓ Branch 7 taken 2187 times.
✓ Branch 8 taken 148206 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 148206 times.
|
161862 | if ((ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n') || (ch == ';') || (ch == ',')) { |
942 |
2/2✓ Branch 1 taken 6561 times.
✓ Branch 2 taken 7095 times.
|
13656 | if (word.size() > 0) { |
943 |
2/4✓ Branch 1 taken 6561 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6561 times.
✗ Branch 5 not taken.
|
6561 | solution.push_back(std::stod(word)); |
944 | } | ||
945 |
1/2✓ Branch 1 taken 13656 times.
✗ Branch 2 not taken.
|
13656 | ch = getc(fp); |
946 | 13656 | word.clear(); | |
947 | 13656 | continue; | |
948 | } else { | ||
949 | // If ch is not a space then it is a number | ||
950 |
1/2✓ Branch 1 taken 148206 times.
✗ Branch 2 not taken.
|
148206 | word += ch; |
951 | } | ||
952 | |||
953 | // Fetching character until end of file | ||
954 |
1/2✓ Branch 1 taken 148206 times.
✗ Branch 2 not taken.
|
148206 | ch = getc(fp); |
955 | } | ||
956 | |||
957 | // Closing both files | ||
958 |
1/2✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
|
9 | fclose(fp); |
959 | |||
960 | 9 | return solution; | |
961 | 9 | } | |
962 | |||
963 | } // namespace TestUtilities | ||
964 | |||
965 | } // namespace felisce | ||
966 |