BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_MeshChecker.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11#ifndef CL_MESHCHECKER_HPP
12#define CL_MESHCHECKER_HPP
13#include "typedefs.hpp"
14#include "cl_Mesh.hpp"
15#include "cl_Pipette.hpp"
16namespace belfem
17{
19 {
20 const proc_t mCommRank ;
21
22 Mesh * mMesh = nullptr;
23
24 mesh::Pipette * mPipette = nullptr;
25
26 index_t mElementCount = 0 ;
27
29 using SwapFunction = void ( MeshChecker::* )( mesh::Element * aElement );
30
31 SwapFunction mFunSwap;
32
33//------------------------------------------------------------------------------
34 public:
35//------------------------------------------------------------------------------
36
37 MeshChecker( Mesh * aMesh );
38
39//------------------------------------------------------------------------------
40
42
43//------------------------------------------------------------------------------
44
46 element_count() const ;
47
48//------------------------------------------------------------------------------
49 private:
50//------------------------------------------------------------------------------
51
52 void
53 link_to_block( mesh::Block * aBlock );
54
55//------------------------------------------------------------------------------
56
57 void
58 process_block( mesh::Block * aBlock );
59
60 void
61 swap( mesh::Element * aElement );
62
63 void
64 swap( mesh::Element * aElement, uint aNode1, uint aNode2 );
65
66 void
67 swap_tri3( mesh::Element * aElement );
68
69 void
70 swap_tri6( mesh::Element * aElement );
71
72 void
73 swap_tri10( mesh::Element * aElement );
74
75 void
76 swap_tri15( mesh::Element * aElement );
77
78 void
79 swap_quad4( mesh::Element * aElement );
80
81 void
82 swap_quad9( mesh::Element * aElement );
83
84 void
85 swap_quad16( mesh::Element * aElement );
86
87 void
88 swap_tet4( mesh::Element * aElement );
89
90 void
91 swap_tet10( mesh::Element * aElement );
92
93 void
94 swap_tet20( mesh::Element * aElement );
95
96 void
97 swap_tet35( mesh::Element * aElement );
98
99 void
100 swap_penta6( mesh::Element * aElement );
101
102 void
103 swap_penta15( mesh::Element * aElement );
104
105 void
106 swap_penta18( mesh::Element * aElement );
107
108 void
109 swap_pyra5( mesh::Element * aElement );
110
111 void
112 swap_pyra14( mesh::Element * aElement );
113
114 void
115 swap_hex8( mesh::Element * aElement );
116
117 void
118 swap_hex8tb( mesh::Element * aElement );
119
120 void
121 swap_hex20( mesh::Element * aElement );
122
123 void
124 swap_hex27( mesh::Element * aElement );
125
126 void
127 swap_hex64( mesh::Element * aElement );
128
129//------------------------------------------------------------------------------
130 };
131
132//------------------------------------------------------------------------------
133
134 inline
135 index_t
137 {
138 return mElementCount;
139 }
140
141//------------------------------------------------------------------------------
142
143 inline void
144 MeshChecker::swap( mesh::Element * aElement )
145 {
146 (this->*mFunSwap)( aElement );
147 }
148
149//------------------------------------------------------------------------------
150
151 inline void
152 MeshChecker::swap( mesh::Element * aElement, uint aNode1, uint aNode2 )
153 {
154 mesh::Node * tSwap = aElement->node( aNode1 );
155 aElement->insert_node( aElement->node( aNode2 ), aNode1 );
156 aElement->insert_node( tSwap, aNode2 );
157 }
158
159//------------------------------------------------------------------------------
160
161 inline void
162 MeshChecker::swap_tri3( mesh::Element * aElement )
163 {
164 // flip nodes
165 this->swap( aElement, 1, 2 );
166 }
167
168//------------------------------------------------------------------------------
169
170 inline void
171 MeshChecker::swap_tri6( mesh::Element * aElement )
172 {
173 // flip nodes
174 this->swap( aElement, 1, 2 );
175 this->swap( aElement, 3, 5 );
176 }
177
178//------------------------------------------------------------------------------
179
180 inline void
181 MeshChecker::swap_tri10( mesh::Element * aElement )
182 {
183 // flip nodes
184 this->swap( aElement, 1, 2 );
185 this->swap( aElement, 3, 8 );
186 this->swap( aElement, 4, 7 );
187 this->swap( aElement, 5, 6 );
188 }
189
190//------------------------------------------------------------------------------
191
192 inline void
193 MeshChecker::swap_tri15( mesh::Element * aElement )
194 {
195 // flip nodes
196 this->swap( aElement, 1, 2 );
197 this->swap( aElement, 3, 11 );
198 this->swap( aElement, 4, 10 );
199 this->swap( aElement, 5, 9 );
200 this->swap( aElement, 6, 8 );
201 this->swap( aElement, 13, 14 );
202 }
203
204//------------------------------------------------------------------------------
205
206 inline void
207 MeshChecker::swap_quad4( mesh::Element * aElement )
208 {
209 // flip nodes
210 this->swap( aElement, 1, 3 );
211 }
212
213//------------------------------------------------------------------------------
214
215 inline void
216 MeshChecker::swap_quad9( mesh::Element * aElement )
217 {
218 // flip nodes
219 this->swap( aElement, 1, 3 );
220 this->swap( aElement, 4, 7 );
221 this->swap( aElement, 5, 6 );
222 }
223
224//------------------------------------------------------------------------------
225
226 inline void
227 MeshChecker::swap_quad16( mesh::Element * aElement )
228 {
229 this->swap( aElement, 1, 3 );
230 this->swap( aElement, 4, 11 );
231 this->swap( aElement, 5, 10 );
232 this->swap( aElement, 6, 9 );
233 this->swap( aElement, 7, 8 );
234 this->swap( aElement, 13, 15 );
235 }
236
237//------------------------------------------------------------------------------
238
239 inline void
240 MeshChecker::swap_tet4( mesh::Element * aElement )
241 {
242 this->swap( aElement, 1, 2 );
243 }
244
245//------------------------------------------------------------------------------
246
247 inline void
248 MeshChecker::swap_tet10( mesh::Element * aElement )
249 {
250 this->swap( aElement, 1, 2 );
251 this->swap( aElement, 4, 6 );
252 this->swap( aElement, 8, 9 );
253 }
254
255//------------------------------------------------------------------------------
256
257 inline void
258 MeshChecker::swap_tet20( mesh::Element * aElement )
259 {
260 this->swap( aElement, 1, 2 );
261 this->swap( aElement, 4, 9 );
262 this->swap( aElement, 5, 8 );
263 this->swap( aElement, 6, 7 );
264 this->swap( aElement, 12, 14 );
265 this->swap( aElement, 13, 15 );
266 this->swap( aElement, 17, 18 );
267 }
268
269//------------------------------------------------------------------------------
270
271 inline void
272 MeshChecker::swap_tet35( mesh::Element * aElement )
273 {
274 this->swap( aElement, 1, 2 );
275 this->swap( aElement, 4, 12 );
276 this->swap( aElement, 5, 11 );
277 this->swap( aElement, 6, 10 );
278 this->swap( aElement, 7, 9 );
279 this->swap( aElement, 16, 19 );
280 this->swap( aElement, 17, 20 );
281 this->swap( aElement, 18, 21 );
282 this->swap( aElement, 23, 24 );
283 this->swap( aElement, 25, 28 );
284 this->swap( aElement, 26, 30 );
285 this->swap( aElement, 27, 29 );
286 this->swap( aElement, 32, 33 );
287 }
288
289//------------------------------------------------------------------------------
290
291 inline void
292 MeshChecker::swap_penta6( mesh::Element * aElement )
293 {
294 this->swap( aElement, 1, 2 );
295 this->swap( aElement, 4, 5 );
296 }
297
298//------------------------------------------------------------------------------
299
300 inline void
301 MeshChecker::swap_penta15( mesh::Element * aElement )
302 {
303 this->swap( aElement, 1, 2 );
304 this->swap( aElement, 4, 5 );
305 this->swap( aElement, 6, 9 );
306 this->swap( aElement, 10,11 );
307 this->swap( aElement, 12,14 );
308 }
309
310//------------------------------------------------------------------------------
311
312 inline void
313 MeshChecker::swap_penta18( mesh::Element * aElement )
314 {
315 this->swap( aElement, 1, 2 );
316 this->swap( aElement, 4, 5 );
317 this->swap( aElement, 6, 9 );
318 this->swap( aElement, 10,11 );
319 this->swap( aElement, 12,14 );
320 this->swap( aElement, 15,17 );
321 }
322
323//------------------------------------------------------------------------------
324
325 inline void
326 MeshChecker::swap_pyra5( mesh::Element * aElement )
327 {
328 this->swap( aElement, 0, 2 );
329 }
330
331//------------------------------------------------------------------------------
332
333 inline void
334 MeshChecker::swap_pyra14( mesh::Element * aElement )
335 {
336 this->swap( aElement, 0, 2 );
337 this->swap( aElement, 5, 6 );
338 this->swap( aElement, 7, 8 );
339 this->swap( aElement, 9, 11 );
340 }
341
342//------------------------------------------------------------------------------
343
344 inline void
345 MeshChecker::swap_hex8( mesh::Element * aElement )
346 {
347 this->swap( aElement, 1, 3 );
348 this->swap( aElement, 5, 7 );
349 }
350
351//------------------------------------------------------------------------------
352
353 inline void
354 MeshChecker::swap_hex8tb( mesh::Element * aElement )
355 {
356 // side connector elements carry edges that are tied to fixed node
357 // slots; swapping the nodes would silently corrupt that pairing.
358 // A negative volume means the factory built a left-handed element
359 // and must be fixed there.
360 BELFEM_ERROR( false,
361 "side connector element %lu has negative volume",
362 ( long unsigned int ) aElement->id() );
363 }
364
365//------------------------------------------------------------------------------
366
367 inline void
368 MeshChecker::swap_hex20( mesh::Element * aElement )
369 {
370 this->swap( aElement, 1, 3 );
371 this->swap( aElement, 5, 7 );
372 this->swap( aElement, 8,11 );
373 this->swap( aElement, 9,12 );
374 this->swap( aElement, 10,15 );
375 this->swap( aElement, 16,18 );
376 this->swap( aElement, 19,17 );
377 }
378
379//------------------------------------------------------------------------------
380
381 inline void
382 MeshChecker::swap_hex27( mesh::Element * aElement )
383 {
384 this->swap( aElement, 1, 3 );
385 this->swap( aElement, 5, 7 );
386 this->swap( aElement, 8,11 );
387 this->swap( aElement, 9,12 );
388 this->swap( aElement, 10,15 );
389 this->swap( aElement, 16,18 );
390 this->swap( aElement, 19,17 );
391 this->swap( aElement, 20,25 );
392 this->swap( aElement, 22,23 );
393 }
394//------------------------------------------------------------------------------
395
396 inline void
397 MeshChecker::swap_hex64( mesh::Element * aElement )
398 {
399 this->swap( aElement, 1, 3 );
400 this->swap( aElement, 5, 7 );
401 this->swap( aElement, 8, 10 );
402 this->swap( aElement, 9, 11 );
403 this->swap( aElement, 14, 19 );
404 this->swap( aElement, 15, 18 );
405 this->swap( aElement, 16, 22 );
406 this->swap( aElement, 17, 23 );
407 this->swap( aElement, 24, 26 );
408 this->swap( aElement, 25, 27 );
409 this->swap( aElement, 28, 31 );
410 this->swap( aElement, 29, 30 );
411 this->swap( aElement, 33, 35 );
412 this->swap( aElement, 36, 40 );
413 this->swap( aElement, 37, 43 );
414 this->swap( aElement, 38, 42 );
415 this->swap( aElement, 39, 41 );
416 this->swap( aElement, 44, 49 );
417 this->swap( aElement, 45, 48 );
418 this->swap( aElement, 46, 51 );
419 this->swap( aElement, 47, 50 );
420 this->swap( aElement, 53, 55 );
421 this->swap( aElement, 57, 59 );
422 this->swap( aElement, 61, 63 );
423 }
424
425
426}
427#endif //CL_MESHCHECKER_HPP
#define BELFEM_ERROR(aCheck,...)
Definition assert.hpp:264
MeshChecker(Mesh *aMesh)
Definition cl_MeshChecker.cpp:21
index_t element_count() const
Definition cl_MeshChecker.hpp:136
Top-level container for all mesh entities.
Definition cl_Mesh.hpp:60
Definition cl_Block.hpp:27
Lagrange Element baseclass.
Definition cl_Element.hpp:35
the pipette is a class that measures the volume of an element
Definition cl_Pipette.hpp:32
int id
ID of this element.
Definition Element.py:18
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
int proc_t
Definition commtypes.hpp:29
uint32_t index_t
Definition typedefs.hpp:52
Definition Element.py:1
Definition Node.py:1