Directory: | ./ |
---|---|
File: | Tools/contour_utilities.cpp |
Date: | 2024-04-14 07:32:34 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 161 | 179 | 89.9% |
Branches: | 176 | 298 | 59.1% |
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 <vector> | ||
17 | #include <set> | ||
18 | #include <unordered_set> | ||
19 | |||
20 | // External includes | ||
21 | |||
22 | // Project includes | ||
23 | #include "Core/key_hash.hpp" | ||
24 | #include "Core/felisceParam.hpp" | ||
25 | #include "Tools/fe_utilities.hpp" | ||
26 | #include "Tools/contour_utilities.hpp" | ||
27 | |||
28 | namespace felisce | ||
29 | { | ||
30 | |||
31 | namespace ContourUtilities | ||
32 | { | ||
33 | |||
34 | 20 | void GenerateContourMesh( | |
35 | GeometricMeshRegion& rMesh, | ||
36 | const bool ImposeParentReferences | ||
37 | ) | ||
38 | { | ||
39 | 20 | std::unordered_map<felInt,felInt> auxiliar_list; | |
40 | |||
41 | // Filling with the parent references | ||
42 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
|
20 | if (ImposeParentReferences) { |
43 | ✗ | felInt startindex = 0, numElemsPerRef = 0; | |
44 | ✗ | int the_ref = 0; | |
45 | ✗ | bool incr_vert_id = false; | |
46 | ✗ | std::vector<felInt> elem; | |
47 | ✗ | std::vector<GeometricMeshRegion::ElementType> eltType_list({GeometricMeshRegion::Tria3, GeometricMeshRegion::Quad4, GeometricMeshRegion::Tetra4, GeometricMeshRegion::Hexa8, GeometricMeshRegion::Prism6, GeometricMeshRegion::Prism9}); | |
48 | ✗ | for (auto& eltType : eltType_list) { | |
49 | ✗ | elem.resize(GeometricMeshRegion::m_numPointsPerElt[eltType], 0); | |
50 | ✗ | for ( auto it_ref = rMesh.intRefToBegEndMaps[eltType].begin();it_ref != rMesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) { | |
51 | ✗ | the_ref = it_ref->first; | |
52 | ✗ | startindex = it_ref->second.first; | |
53 | ✗ | numElemsPerRef = it_ref->second.second; | |
54 | ✗ | for(felInt iel = 0; iel < numElemsPerRef; iel++) { | |
55 | ✗ | rMesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id); | |
56 | ✗ | for (auto r_id : elem) { | |
57 | ✗ | auxiliar_list[r_id] = the_ref; | |
58 | } | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 |
1/2✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
|
20 | GenerateContourMesh(rMesh, auxiliar_list, ImposeParentReferences); |
64 | 20 | } | |
65 | |||
66 | /***********************************************************************************/ | ||
67 | /***********************************************************************************/ | ||
68 | |||
69 | 72 | void GenerateContourMesh( | |
70 | GeometricMeshRegion& rMesh, | ||
71 | const std::unordered_map<felInt,felInt>& rManualRefListNodes, | ||
72 | const bool ImposeManualReferences | ||
73 | ) | ||
74 | { | ||
75 | // The initial reference | ||
76 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
|
72 | int ref = ImposeManualReferences ? 0 : 100; |
77 | |||
78 | /** | ||
79 | * The following geometries are supported to generate a skin. Extend then to support new geometries: | ||
80 | * - Triangle (P1) | ||
81 | * - Quadrilateral (P1) | ||
82 | * - Tetrahedra (P1) | ||
83 | * - Hexahedra (P1) | ||
84 | * - Prism (P1 and P1-P2, 9 nodes) | ||
85 | */ | ||
86 | // P1 triangle | ||
87 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 2 taken 66 times.
|
72 | if (rMesh.numElements(GeometricMeshRegion::Tria3) > 0) { |
88 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | GenerateContourMeshGivenGeometry(rMesh, GeometricMeshRegion::Tria3, ref, rManualRefListNodes); |
89 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if(!ImposeManualReferences) ++ref; |
90 | } | ||
91 | |||
92 | // P1 quadrilateral | ||
93 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 67 times.
|
72 | if (rMesh.numElements(GeometricMeshRegion::Quad4) > 0) { |
94 |
1/2✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
5 | GenerateContourMeshGivenGeometry(rMesh, GeometricMeshRegion::Quad4, ref, rManualRefListNodes); |
95 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if(!ImposeManualReferences) ++ref; |
96 | } | ||
97 | |||
98 | // P1 tetrahedra | ||
99 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 2 taken 66 times.
|
72 | if (rMesh.numElements(GeometricMeshRegion::Tetra4) > 0) { |
100 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | GenerateContourMeshGivenGeometry(rMesh, GeometricMeshRegion::Tetra4, ref, rManualRefListNodes); |
101 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | if(!ImposeManualReferences) ++ref; |
102 | } | ||
103 | |||
104 | // P1 hexahedra | ||
105 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 69 times.
|
72 | if (rMesh.numElements(GeometricMeshRegion::Hexa8) > 0) { |
106 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | GenerateContourMeshGivenGeometry(rMesh, GeometricMeshRegion::Hexa8, ref, rManualRefListNodes); |
107 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if(!ImposeManualReferences) ++ref; |
108 | } | ||
109 | |||
110 | // P1 prisms | ||
111 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 70 times.
|
72 | if (rMesh.numElements(GeometricMeshRegion::Prism6) > 0) { |
112 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | GenerateContourMeshGivenGeometry(rMesh, GeometricMeshRegion::Prism6, ref, rManualRefListNodes); |
113 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(!ImposeManualReferences) ++ref; |
114 | } | ||
115 | |||
116 | // P1-P2 prisms | ||
117 |
2/2✓ Branch 1 taken 53 times.
✓ Branch 2 taken 19 times.
|
72 | if (rMesh.numElements(GeometricMeshRegion::Prism9) > 0) { |
118 |
1/2✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
|
53 | GenerateContourMeshGivenGeometry(rMesh, GeometricMeshRegion::Prism9, ref, rManualRefListNodes); |
119 |
1/2✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
|
53 | if(!ImposeManualReferences) ++ref; |
120 | } | ||
121 | |||
122 | // Check if the mesh is inverted | ||
123 |
2/4✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 72 times.
|
72 | if (FelisceParam::instance().checkVolumeOrientation) { |
124 | ✗ | if (FEUtilities::CheckVolumeIsInverted(rMesh)) { | |
125 | ✗ | FEL_ERROR("Mesh is inverted. Check connectivity"); | |
126 | } | ||
127 | } | ||
128 | 72 | } | |
129 | |||
130 | /***********************************************************************************/ | ||
131 | /***********************************************************************************/ | ||
132 | |||
133 | 75 | void GenerateContourMeshGivenGeometry( | |
134 | GeometricMeshRegion& rMesh, | ||
135 | const GeometricMeshRegion::ElementType& rElementType, | ||
136 | int& rRef, | ||
137 | const std::unordered_map<felInt,felInt>& rManualRefListNodes | ||
138 | ) | ||
139 | { | ||
140 | /// Definition of the vector indexes considered | ||
141 | typedef std::vector<felInt> VectorIndexType; | ||
142 | |||
143 | /// Definition of the hasher considered | ||
144 | typedef VectorIndexHasher<VectorIndexType> VectorIndexHasherType; | ||
145 | |||
146 | /// Definition of the key comparor considered | ||
147 | typedef VectorIndexComparor<VectorIndexType> VectorIndexComparorType; | ||
148 | |||
149 | /// Definition of the ordered key comparor considered | ||
150 | typedef VectorIndexComparorLess<VectorIndexType> VectorIndexComparorLessType; | ||
151 | |||
152 | /// Define the set considered for element pointers | ||
153 | typedef std::unordered_set<VectorIndexType, VectorIndexHasherType, VectorIndexComparorType > HashSetVectorIntType; | ||
154 | |||
155 | /// Define the map considered for face ids | ||
156 | typedef std::map<VectorIndexType, VectorIndexType, VectorIndexComparorLessType > HashMapVectorIntType; | ||
157 | |||
158 | /// Define the map considered to create contour | ||
159 | typedef std::unordered_map<VectorIndexType, GeometricMeshRegion::ElementType, VectorIndexHasherType, VectorIndexComparorType > ContourMapType; | ||
160 | |||
161 | /// Define the map considered for face types counter | ||
162 | std::unordered_map<GeometricMeshRegion::ElementType, std::size_t> geometry_counter = { | ||
163 | std::pair<GeometricMeshRegion::ElementType, std::size_t>(GeometricMeshRegion::Seg2, 0), | ||
164 | std::pair<GeometricMeshRegion::ElementType, std::size_t>(GeometricMeshRegion::Tria3, 0), | ||
165 | std::pair<GeometricMeshRegion::ElementType, std::size_t>(GeometricMeshRegion::Quad4, 0), | ||
166 | std::pair<GeometricMeshRegion::ElementType, std::size_t>(GeometricMeshRegion::Quad6, 0) | ||
167 |
1/2✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
|
75 | }; |
168 | |||
169 | // Defining references | ||
170 | 75 | auto& r_int_ref_to_enum = rMesh.intRefToEnum(); | |
171 | |||
172 | // Definition of the inverse map | ||
173 | 75 | HashMapVectorIntType inverse_face_map; | |
174 | 75 | ContourMapType contour_map; | |
175 | |||
176 |
1/2✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
|
75 | const std::size_t number_of_nodes_element = NumberOfNodesGeometries[rElementType]; |
177 |
1/2✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
|
75 | const std::size_t potential_number_neighbours = NumberOfContours[rElementType]; |
178 |
1/2✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
|
75 | const auto& r_boundary_geometries = ContourConnectivities[rElementType]; |
179 |
1/2✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
|
75 | const auto& r_boundary_types = ContourTypes[rElementType]; |
180 | 75 | const auto number_of_elements = rMesh.numElements(rElementType); | |
181 |
1/2✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
|
75 | std::vector<felInt> origin_elem(number_of_nodes_element, 0); |
182 |
2/2✓ Branch 0 taken 33831 times.
✓ Branch 1 taken 75 times.
|
33906 | for (int i_elem = 0; i_elem < number_of_elements; ++i_elem) { |
183 |
1/2✓ Branch 1 taken 33831 times.
✗ Branch 2 not taken.
|
33831 | rMesh.getOneElement(rElementType, i_elem, origin_elem, false); |
184 | |||
185 |
2/2✓ Branch 0 taken 161994 times.
✓ Branch 1 taken 33831 times.
|
195825 | for (std::size_t i_face = 0; i_face < potential_number_neighbours; ++i_face) { |
186 | /* FACES/EDGES */ | ||
187 | 161994 | const std::size_t number_nodes = r_boundary_geometries[i_face].size(); | |
188 |
1/2✓ Branch 2 taken 161994 times.
✗ Branch 3 not taken.
|
161994 | VectorIndexType vector_ids(number_nodes); |
189 |
1/2✓ Branch 2 taken 161994 times.
✗ Branch 3 not taken.
|
161994 | VectorIndexType ordered_vector_ids(number_nodes); |
190 | |||
191 | /* FACE/EDGE */ | ||
192 |
2/2✓ Branch 0 taken 730484 times.
✓ Branch 1 taken 161994 times.
|
892478 | for (std::size_t i_node = 0; i_node < number_nodes; ++i_node) { |
193 | 730484 | vector_ids[i_node] = origin_elem[r_boundary_geometries[i_face][i_node]]; | |
194 | 730484 | ordered_vector_ids[i_node] = vector_ids[i_node]; | |
195 | } | ||
196 | |||
197 | /*** THE ARRAY OF IDS MUST BE ORDERED!!! ***/ | ||
198 |
1/2✓ Branch 3 taken 161994 times.
✗ Branch 4 not taken.
|
161994 | std::sort(vector_ids.begin(), vector_ids.end()); |
199 | // Check if the elements already exist in the HashMapVectorIntType | ||
200 |
1/2✓ Branch 1 taken 161994 times.
✗ Branch 2 not taken.
|
161994 | auto it_check = inverse_face_map.find(vector_ids); |
201 | |||
202 |
2/2✓ Branch 2 taken 109745 times.
✓ Branch 3 taken 52249 times.
|
161994 | if(it_check == inverse_face_map.end() ) { |
203 | // If it doesn't exist it is added to the database | ||
204 |
2/4✓ Branch 1 taken 109745 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 109745 times.
✗ Branch 5 not taken.
|
109745 | inverse_face_map.insert(std::pair<VectorIndexType, VectorIndexType>(vector_ids, ordered_vector_ids)); |
205 |
2/4✓ Branch 2 taken 109745 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 109745 times.
✗ Branch 6 not taken.
|
109745 | contour_map.insert(std::pair<VectorIndexType, GeometricMeshRegion::ElementType>(vector_ids, r_boundary_types[i_face])); |
206 |
1/2✓ Branch 2 taken 109745 times.
✗ Branch 3 not taken.
|
109745 | geometry_counter[r_boundary_types[i_face]] += 1; |
207 | } | ||
208 | 161994 | } | |
209 | } | ||
210 | |||
211 | // Create the face_set | ||
212 | 75 | HashSetVectorIntType face_set; | |
213 | |||
214 |
2/2✓ Branch 0 taken 33831 times.
✓ Branch 1 taken 75 times.
|
33906 | for (int i_elem = 0; i_elem < number_of_elements; ++i_elem) { |
215 |
1/2✓ Branch 1 taken 33831 times.
✗ Branch 2 not taken.
|
33831 | rMesh.getOneElement(rElementType, i_elem, origin_elem, false); |
216 |
2/2✓ Branch 0 taken 161994 times.
✓ Branch 1 taken 33831 times.
|
195825 | for (std::size_t i_face = 0; i_face < potential_number_neighbours; ++i_face) { |
217 | |||
218 | /* FACES/EDGES */ | ||
219 | 161994 | const std::size_t number_nodes = r_boundary_geometries[i_face].size(); | |
220 |
1/2✓ Branch 2 taken 161994 times.
✗ Branch 3 not taken.
|
161994 | VectorIndexType vector_ids(number_nodes); |
221 | |||
222 | /* FACE/EDGE */ | ||
223 |
2/2✓ Branch 0 taken 730484 times.
✓ Branch 1 taken 161994 times.
|
892478 | for (std::size_t i_node = 0; i_node < number_nodes; ++i_node) { |
224 | 730484 | vector_ids[i_node] = origin_elem[r_boundary_geometries[i_face][i_node]]; | |
225 | } | ||
226 | |||
227 | /*** THE ARRAY OF IDS MUST BE ORDERED!!! ***/ | ||
228 |
1/2✓ Branch 3 taken 161994 times.
✗ Branch 4 not taken.
|
161994 | std::sort(vector_ids.begin(), vector_ids.end()); |
229 | // Check if the elements already exist in the HashSetVectorIntType | ||
230 |
1/2✓ Branch 1 taken 161994 times.
✗ Branch 2 not taken.
|
161994 | auto it_check = face_set.find(vector_ids); |
231 | |||
232 |
2/2✓ Branch 2 taken 52249 times.
✓ Branch 3 taken 109745 times.
|
161994 | if(it_check != face_set.end() ) { |
233 | // If it exists we remove from the inverse map | ||
234 |
1/2✓ Branch 1 taken 52249 times.
✗ Branch 2 not taken.
|
52249 | inverse_face_map.erase(vector_ids); |
235 |
1/2✓ Branch 1 taken 52249 times.
✗ Branch 2 not taken.
|
52249 | contour_map.erase(vector_ids); |
236 |
1/2✓ Branch 2 taken 52249 times.
✗ Branch 3 not taken.
|
52249 | geometry_counter[r_boundary_types[i_face]] -= 1; |
237 | } else { | ||
238 | // If it doesn't exist it is added to the database | ||
239 |
1/2✓ Branch 1 taken 109745 times.
✗ Branch 2 not taken.
|
109745 | face_set.insert(vector_ids); |
240 | } | ||
241 | 161994 | } | |
242 | } | ||
243 | |||
244 | // Allocate contour | ||
245 | 75 | std::size_t counter_check = 0; | |
246 |
2/2✓ Branch 5 taken 300 times.
✓ Branch 6 taken 75 times.
|
375 | for (auto& r_counter : geometry_counter) { |
247 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 172 times.
|
300 | if (r_counter.second > 0) { |
248 | 128 | counter_check += r_counter.second; | |
249 | 128 | rMesh.numElements(r_counter.first) = r_counter.second; | |
250 |
1/2✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
|
128 | rMesh.allocateElements(r_counter.first); |
251 | } | ||
252 | } | ||
253 | |||
254 | // Check | ||
255 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
|
75 | if (counter_check != inverse_face_map.size()) { |
256 | ✗ | std::cout << "WARNING: Inconsistent clean up of unused BC" << std::endl; | |
257 | } | ||
258 | |||
259 | // Generate contour | ||
260 | std::unordered_map<GeometricMeshRegion::ElementType, felInt> contour_counter = { | ||
261 | std::pair<GeometricMeshRegion::ElementType, felInt>(GeometricMeshRegion::Seg2, 0), | ||
262 | std::pair<GeometricMeshRegion::ElementType, felInt>(GeometricMeshRegion::Tria3, 0), | ||
263 | std::pair<GeometricMeshRegion::ElementType, felInt>(GeometricMeshRegion::Quad4, 0), | ||
264 | std::pair<GeometricMeshRegion::ElementType, felInt>(GeometricMeshRegion::Quad6, 0) | ||
265 |
1/2✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
|
75 | }; |
266 | std::unordered_map<GeometricMeshRegion::ElementType, std::map<int,std::vector<felInt>>> list_elements = { | ||
267 |
1/2✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
|
150 | std::pair<GeometricMeshRegion::ElementType, std::map<int,std::vector<felInt>>>(GeometricMeshRegion::Seg2, {}), |
268 |
1/2✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
|
150 | std::pair<GeometricMeshRegion::ElementType, std::map<int,std::vector<felInt>>>(GeometricMeshRegion::Tria3, {}), |
269 |
1/2✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
|
150 | std::pair<GeometricMeshRegion::ElementType, std::map<int,std::vector<felInt>>>(GeometricMeshRegion::Quad4, {}), |
270 |
1/2✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
|
150 | std::pair<GeometricMeshRegion::ElementType, std::map<int,std::vector<felInt>>>(GeometricMeshRegion::Quad6, {}) |
271 |
1/2✓ Branch 6 taken 75 times.
✗ Branch 7 not taken.
|
750 | }; |
272 | // Default reference | ||
273 |
2/2✓ Branch 1 taken 23 times.
✓ Branch 2 taken 52 times.
|
75 | if (rManualRefListNodes.size() == 0) { |
274 |
2/2✓ Branch 4 taken 1001 times.
✓ Branch 5 taken 23 times.
|
1024 | for (auto& r_countour_index : inverse_face_map) { |
275 | 1001 | const auto& r_connectivity = r_countour_index.second; | |
276 |
1/2✓ Branch 1 taken 1001 times.
✗ Branch 2 not taken.
|
1001 | const auto type_contour = contour_map[r_countour_index.first]; |
277 |
1/2✓ Branch 1 taken 1001 times.
✗ Branch 2 not taken.
|
1001 | auto& r_counter = contour_counter[type_contour]; |
278 |
1/2✓ Branch 1 taken 1001 times.
✗ Branch 2 not taken.
|
1001 | rMesh.setOneElement(type_contour, r_counter, r_connectivity, false); |
279 | 1001 | ++r_counter; | |
280 | } | ||
281 | } else { // Manual references | ||
282 |
2/2✓ Branch 5 taken 208 times.
✓ Branch 6 taken 52 times.
|
260 | for (auto& r_component : list_elements) { |
283 | 208 | auto& r_map = r_component.second; | |
284 |
2/4✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 208 times.
✗ Branch 6 not taken.
|
208 | r_map.insert(std::pair<int, std::vector<felInt>>(rRef, {})); |
285 |
2/2✓ Branch 5 taken 116712 times.
✓ Branch 6 taken 208 times.
|
116920 | for (auto& r_manual : rManualRefListNodes) { |
286 |
3/4✓ Branch 2 taken 116712 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 416 times.
✓ Branch 6 taken 116296 times.
|
116712 | if (r_map.find(rRef + r_manual.second) == r_map.end()) { |
287 |
2/4✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 416 times.
✗ Branch 6 not taken.
|
416 | r_map.insert(std::pair<int, std::vector<felInt>>(rRef + r_manual.second, {})); |
288 | } | ||
289 | } | ||
290 | } | ||
291 | std::unordered_map<GeometricMeshRegion::ElementType, std::unordered_map<int,std::set<felInt>>> auxiliar_list_elements = { | ||
292 |
1/2✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
|
104 | std::pair<GeometricMeshRegion::ElementType, std::unordered_map<int,std::set<felInt>>>(GeometricMeshRegion::Seg2, {}), |
293 |
1/2✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
|
104 | std::pair<GeometricMeshRegion::ElementType, std::unordered_map<int,std::set<felInt>>>(GeometricMeshRegion::Tria3, {}), |
294 |
1/2✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
|
104 | std::pair<GeometricMeshRegion::ElementType, std::unordered_map<int,std::set<felInt>>>(GeometricMeshRegion::Quad4, {}), |
295 |
1/2✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
|
104 | std::pair<GeometricMeshRegion::ElementType, std::unordered_map<int,std::set<felInt>>>(GeometricMeshRegion::Quad6, {}) |
296 |
1/2✓ Branch 6 taken 52 times.
✗ Branch 7 not taken.
|
520 | }; |
297 |
2/2✓ Branch 5 taken 208 times.
✓ Branch 6 taken 52 times.
|
260 | for (auto& r_component : auxiliar_list_elements) { |
298 | 208 | auto& r_map = r_component.second; | |
299 |
2/4✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 208 times.
✗ Branch 6 not taken.
|
208 | r_map.insert(std::pair<int, std::set<felInt>>(rRef, {})); |
300 |
2/2✓ Branch 5 taken 116712 times.
✓ Branch 6 taken 208 times.
|
116920 | for (auto& r_manual : rManualRefListNodes) { |
301 |
3/4✓ Branch 2 taken 116712 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 416 times.
✓ Branch 6 taken 116296 times.
|
116712 | if (r_map.find(rRef + r_manual.second) == r_map.end()) { |
302 |
2/4✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 416 times.
✗ Branch 6 not taken.
|
416 | r_map.insert(std::pair<int, std::set<felInt>>(rRef + r_manual.second, {})); |
303 | } | ||
304 | } | ||
305 | } | ||
306 |
2/2✓ Branch 5 taken 56495 times.
✓ Branch 6 taken 52 times.
|
56547 | for (auto& r_countour_index : inverse_face_map) { |
307 | 56495 | const auto& r_connectivity = r_countour_index.second; | |
308 |
1/2✓ Branch 1 taken 56495 times.
✗ Branch 2 not taken.
|
56495 | const auto type_contour = contour_map[r_countour_index.first]; |
309 |
1/2✓ Branch 1 taken 56495 times.
✗ Branch 2 not taken.
|
56495 | auto& r_counter = contour_counter[type_contour]; |
310 |
1/2✓ Branch 1 taken 56495 times.
✗ Branch 2 not taken.
|
56495 | rMesh.setOneElement(type_contour, r_counter, r_connectivity, false); |
311 |
1/2✓ Branch 1 taken 56495 times.
✗ Branch 2 not taken.
|
56495 | auto& r_list_elements = auxiliar_list_elements[type_contour]; |
312 | 56495 | std::unordered_map<int, std::size_t> node_counter; | |
313 |
2/2✓ Branch 4 taken 544394402 times.
✓ Branch 5 taken 56495 times.
|
544450897 | for (auto& r_manual : rManualRefListNodes) { |
314 |
1/2✓ Branch 2 taken 544394402 times.
✗ Branch 3 not taken.
|
544394402 | node_counter.insert(std::pair<int, std::size_t>(rRef + r_manual.second, 0)); |
315 | } | ||
316 | |||
317 |
2/2✓ Branch 4 taken 172799 times.
✓ Branch 5 taken 54838 times.
|
227637 | for (auto& r_id : r_connectivity) { |
318 |
1/2✓ Branch 1 taken 172799 times.
✗ Branch 2 not taken.
|
172799 | auto find_id = rManualRefListNodes.find(r_id); |
319 |
2/2✓ Branch 2 taken 1657 times.
✓ Branch 3 taken 171142 times.
|
172799 | if (find_id == rManualRefListNodes.end()) { // If one node is not in the manual list assigned to the default ref |
320 |
2/4✓ Branch 1 taken 1657 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1657 times.
✗ Branch 5 not taken.
|
1657 | r_list_elements[rRef].insert(r_counter); |
321 | 1657 | break; | |
322 | } else { | ||
323 |
1/2✓ Branch 2 taken 171142 times.
✗ Branch 3 not taken.
|
171142 | ++node_counter[rRef + find_id->second]; |
324 | } | ||
325 | } | ||
326 | // Adding the corresponding ref if all nodes are manually set | ||
327 | 56495 | bool added = false; | |
328 |
2/2✓ Branch 5 taken 112990 times.
✓ Branch 6 taken 56495 times.
|
169485 | for (auto& r_count : node_counter) { |
329 |
2/2✓ Branch 1 taken 54838 times.
✓ Branch 2 taken 58152 times.
|
112990 | if (r_count.second == r_connectivity.size()) { |
330 |
2/4✓ Branch 1 taken 54838 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 54838 times.
✗ Branch 5 not taken.
|
54838 | r_list_elements[r_count.first].insert(r_counter); |
331 | 54838 | added = true; | |
332 | } | ||
333 | } | ||
334 | // Otherwise added to default | ||
335 |
2/2✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 54838 times.
|
56495 | if (!added) { |
336 |
2/4✓ Branch 1 taken 1657 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1657 times.
✗ Branch 5 not taken.
|
1657 | r_list_elements[rRef].insert(r_counter); |
337 | } | ||
338 | 56495 | ++r_counter; | |
339 | 56495 | } | |
340 | // Copy the auxiliary list into our target list | ||
341 |
3/4✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 10 taken 208 times.
✓ Branch 11 taken 52 times.
|
260 | for (auto& r_element_types : std::vector<GeometricMeshRegion::ElementType>({GeometricMeshRegion::Seg2, GeometricMeshRegion::Tria3, GeometricMeshRegion::Quad4, GeometricMeshRegion::Quad6})) { |
342 |
1/2✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
|
208 | auto& r_map = list_elements[r_element_types]; |
343 |
1/2✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
|
208 | auto& r_auxiliar_map = auxiliar_list_elements[r_element_types]; |
344 |
2/2✓ Branch 5 taken 624 times.
✓ Branch 6 taken 208 times.
|
832 | for (auto& r_component : r_auxiliar_map) { |
345 |
1/2✓ Branch 1 taken 624 times.
✗ Branch 2 not taken.
|
624 | auto& r_list = r_map[r_component.first]; |
346 | 624 | auto& r_auxiliar_list = r_component.second; | |
347 |
1/2✓ Branch 2 taken 624 times.
✗ Branch 3 not taken.
|
624 | r_list.resize(r_auxiliar_list.size()); |
348 | 624 | std::size_t counter = 0; | |
349 |
2/2✓ Branch 4 taken 56495 times.
✓ Branch 5 taken 624 times.
|
57119 | for (auto& r_id : r_auxiliar_list) { |
350 | 56495 | r_list[counter] = r_id; | |
351 | 56495 | ++counter; | |
352 | } | ||
353 | } | ||
354 | 52 | } | |
355 | 52 | } | |
356 | |||
357 | // Last calls | ||
358 |
2/2✓ Branch 5 taken 300 times.
✓ Branch 6 taken 75 times.
|
375 | for (auto& r_counter : geometry_counter) { |
359 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 172 times.
|
300 | if (r_counter.second > 0) { |
360 | // Reference list | ||
361 |
1/2✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
|
128 | std::map<int,std::vector<felInt>>& r_list_elements = list_elements[r_counter.first]; |
362 | |||
363 | // Generate references | ||
364 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 2 taken 103 times.
|
128 | if (rManualRefListNodes.size() == 0) { |
365 |
2/4✓ Branch 1 taken 25 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
75 | r_list_elements = |
366 | { | ||
367 |
1/2✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
|
50 | std::pair<int,std::vector<felInt>>(rRef, std::vector<felInt>(r_counter.second, 0)) |
368 |
1/2✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
|
50 | }; |
369 |
1/2✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
|
25 | auto& r_vector = r_list_elements[rRef]; |
370 |
2/2✓ Branch 1 taken 976 times.
✓ Branch 2 taken 25 times.
|
1001 | for (std::size_t i = 1; i < r_vector.size(); ++i) { |
371 | 976 | r_vector[i] = i; | |
372 | } | ||
373 | } | ||
374 | |||
375 | // Adding references | ||
376 |
2/2✓ Branch 5 taken 334 times.
✓ Branch 6 taken 128 times.
|
462 | for (auto& r_id : r_list_elements) { |
377 |
2/2✓ Branch 1 taken 180 times.
✓ Branch 2 taken 154 times.
|
334 | if (r_id.second.size() > 0) { |
378 |
2/4✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 180 times.
✗ Branch 5 not taken.
|
180 | r_int_ref_to_enum[r_id.first].insert(r_counter.first); |
379 | } | ||
380 | } | ||
381 | |||
382 | // Calling API | ||
383 |
1/2✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
|
128 | rMesh.reorderListElePerRef(r_list_elements, r_counter.first); |
384 | } | ||
385 | } | ||
386 | |||
387 |
1/2✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
|
75 | rMesh.setBagElementTypeDomain(); |
388 |
1/2✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
|
75 | rMesh.setBagElementTypeDomainBoundary(); |
389 | 75 | } | |
390 | } // namespace ContourUtilities | ||
391 | |||
392 | } // namespace felisce | ||
393 |