MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
ncmesh_tables.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12namespace mfem
13{
14
15namespace // make everything static
16{
17
18const int ref_type_num_children[8] = { 0, 2, 2, 4, 2, 4, 4, 8 };
19
20
21// derefinement tables
22// The first n numbers in each line are the refined elements that contain
23// the vertices of the parent element. The next m numbers in each line
24// are the refined elements that contain the faces attributes of the parent
25// element.
26
27const int quad_deref_table[3][4 + 4] =
28{
29 { 0, 1, 1, 0, /**/ 1, 1, 0, 0 }, // 1 - X
30 { 0, 0, 1, 1, /**/ 0, 0, 1, 1 }, // 2 - Y
31 { 0, 1, 2, 3, /**/ 1, 1, 3, 3 } // 3 - iso
32};
33
34const int hex_deref_table[7][8 + 6] =
35{
36 { 0, 1, 1, 0, 0, 1, 1, 0, /**/ 1, 1, 1, 0, 0, 0 }, // 1 - X
37 { 0, 0, 1, 1, 0, 0, 1, 1, /**/ 0, 0, 0, 1, 1, 1 }, // 2 - Y
38 { 0, 1, 2, 3, 0, 1, 2, 3, /**/ 1, 1, 1, 3, 3, 3 }, // 3 - XY
39 { 0, 0, 0, 0, 1, 1, 1, 1, /**/ 0, 0, 0, 1, 1, 1 }, // 4 - Z
40 { 0, 1, 1, 0, 3, 2, 2, 3, /**/ 1, 1, 1, 3, 3, 3 }, // 5 - XZ
41 { 0, 0, 1, 1, 2, 2, 3, 3, /**/ 0, 0, 0, 3, 3, 3 }, // 6 - YZ
42 { 0, 1, 2, 3, 4, 5, 6, 7, /**/ 1, 1, 1, 7, 7, 7 } // 7 - iso
43};
44
45const int prism_deref_table[7][6 + 5] =
46{
47 {-1,-1,-1,-1,-1,-1, /**/ -1,-1,-1,-1,-1 }, // 1
48 {-1,-1,-1,-1,-1,-1, /**/ -1,-1,-1,-1,-1 }, // 2
49 { 0, 1, 2, 0, 1, 2, /**/ 0, 0, 0, 1, 0 }, // 3 - XY
50 { 0, 0, 0, 1, 1, 1, /**/ 0, 1, 0, 0, 0 }, // 4 - Z
51 {-1,-1,-1,-1,-1,-1, /**/ -1,-1,-1,-1,-1 }, // 5
52 {-1,-1,-1,-1,-1,-1, /**/ -1,-1,-1,-1,-1 }, // 6
53 { 0, 1, 2, 4, 5, 6, /**/ 0, 5, 0, 5, 0 } // 7 - iso
54};
55
56const int pyramid_deref_table[7][5 + 5] =
57{
58 {-1,-1,-1,-1,-1, /**/ -1,-1,-1,-1,-1 }, // 1
59 {-1,-1,-1,-1,-1, /**/ -1,-1,-1,-1,-1 }, // 2
60 {-1,-1,-1,-1,-1, /**/ -1,-1,-1,-1,-1 }, // 3
61 {-1,-1,-1,-1,-1, /**/ -1,-1,-1,-1,-1 }, // 4
62 {-1,-1,-1,-1,-1, /**/ -1,-1,-1,-1,-1 }, // 5
63 {-1,-1,-1,-1,-1, /**/ -1,-1,-1,-1,-1 }, // 6
64 { 0, 1, 2, 3, 5, /**/ 0, 5, 5, 5, 5 } // 7 - iso
65};
66
67// child ordering tables
68
69const char quad_hilbert_child_order[8][4] =
70{
71 {0,1,2,3}, {0,3,2,1}, {1,2,3,0}, {1,0,3,2},
72 {2,3,0,1}, {2,1,0,3}, {3,0,1,2}, {3,2,1,0}
73};
74
75const char quad_hilbert_child_state[8][4] =
76{
77 {1,0,0,5}, {0,1,1,4}, {3,2,2,7}, {2,3,3,6},
78 {5,4,4,1}, {4,5,5,0}, {7,6,6,3}, {6,7,7,2}
79};
80
81const char hex_hilbert_child_order[24][8] =
82{
83 {0,1,2,3,7,6,5,4}, {0,3,7,4,5,6,2,1}, {0,4,5,1,2,6,7,3},
84 {1,0,3,2,6,7,4,5}, {1,2,6,5,4,7,3,0}, {1,5,4,0,3,7,6,2},
85 {2,1,5,6,7,4,0,3}, {2,3,0,1,5,4,7,6}, {2,6,7,3,0,4,5,1},
86 {3,0,4,7,6,5,1,2}, {3,2,1,0,4,5,6,7}, {3,7,6,2,1,5,4,0},
87 {4,0,1,5,6,2,3,7}, {4,5,6,7,3,2,1,0}, {4,7,3,0,1,2,6,5},
88 {5,1,0,4,7,3,2,6}, {5,4,7,6,2,3,0,1}, {5,6,2,1,0,3,7,4},
89 {6,2,3,7,4,0,1,5}, {6,5,1,2,3,0,4,7}, {6,7,4,5,1,0,3,2},
90 {7,3,2,6,5,1,0,4}, {7,4,0,3,2,1,5,6}, {7,6,5,4,0,1,2,3}
91};
92
93const char hex_hilbert_child_state[24][8] =
94{
95 {1,2,2,7,7,21,21,17}, {2,0,0,22,22,16,16,8}, {0,1,1,15,15,6,6,23},
96 {4,5,5,10,10,18,18,14}, {5,3,3,19,19,13,13,11}, {3,4,4,12,12,9,9,20},
97 {8,7,7,17,17,23,23,2}, {6,8,8,0,0,15,15,22}, {7,6,6,21,21,1,1,16},
98 {11,10,10,14,14,20,20,5}, {9,11,11,3,3,12,12,19}, {10,9,9,18,18,4,4,13},
99 {13,14,14,5,5,19,19,10}, {14,12,12,20,20,11,11,4}, {12,13,13,9,9,3,3,18},
100 {16,17,17,2,2,22,22,7}, {17,15,15,23,23,8,8,1}, {15,16,16,6,6,0,0,21},
101 {20,19,19,11,11,14,14,3}, {18,20,20,4,4,10,10,12}, {19,18,18,13,13,5,5,9},
102 {23,22,22,8,8,17,17,0}, {21,23,23,1,1,7,7,15}, {22,21,21,16,16,2,2,6}
103};
104
105
106// child/parent reference domain transforms
107
108typedef NCMesh::RefCoord RefCoord;
109
110// reference domain coordinates as fixed point numbers
111const RefCoord T_HALF = (1ll << 59);
112const RefCoord T_ONE = (1ll << 60);
113const RefCoord T_TWO = (1ll << 61);
114
115// (scaling factors have a different fixed point multiplier)
116const RefCoord S_HALF = 1;
117const RefCoord S_ONE = 2;
118const RefCoord S_TWO = 4;
119
120const RefCoord tri_corners[3][3] =
121{
122 { 0, 0, 0},
123 {T_ONE, 0, 0},
124 { 0, T_ONE, 0}
125};
126
127const RefCoord quad_corners[4][3] =
128{
129 { 0, 0, 0},
130 {T_ONE, 0, 0},
131 {T_ONE, T_ONE, 0},
132 { 0, T_ONE, 0}
133};
134
135const RefCoord hex_corners[8][3] =
136{
137 { 0, 0, 0},
138 {T_ONE, 0, 0},
139 {T_ONE, T_ONE, 0},
140 { 0, T_ONE, 0},
141 { 0, 0, T_ONE},
142 {T_ONE, 0, T_ONE},
143 {T_ONE, T_ONE, T_ONE},
144 { 0, T_ONE, T_ONE}
145};
146
147const RefCoord prism_corners[6][3] =
148{
149 { 0, 0, 0},
150 {T_ONE, 0, 0},
151 { 0, T_ONE, 0},
152 { 0, 0, T_ONE},
153 {T_ONE, 0, T_ONE},
154 { 0, T_ONE, T_ONE}
155};
156
157const RefCoord pyramid_corners[5][3] =
158{
159 { 0, 0, 0},
160 {T_ONE, 0, 0},
161 {T_ONE, T_ONE, 0},
162 { 0, T_ONE, 0},
163 { 0, 0, T_ONE}
164};
165
166typedef RefCoord RefPoint[3];
167const RefPoint* geom_corners[8] =
168{
169 NULL, // point
170 NULL, // segment
171 tri_corners,
172 quad_corners,
173 NULL, // tetrahedron
174 hex_corners,
175 prism_corners,
176 pyramid_corners
177};
178
179// reference domain transform: 3 scales, 3 translations
180struct RefTrf
181{
182 RefCoord s[3], t[3];
183
184 void Apply(const RefCoord src[3], RefCoord dst[3]) const
185 {
186 for (int i = 0; i < 3; i++)
187 {
188 dst[i] = (src[i]*s[i] >> 1) + t[i];
189 }
190 }
191};
192
193const RefTrf quad_parent_rt1[2] =
194{
195 { {S_HALF, S_ONE, 0}, { 0, 0, 0} },
196 { {S_HALF, S_ONE, 0}, {T_HALF, 0, 0} }
197};
198
199const RefTrf quad_child_rt1[2] =
200{
201 { {S_TWO, S_ONE, 0}, { 0, 0, 0} },
202 { {S_TWO, S_ONE, 0}, {-T_ONE, 0, 0} }
203};
204
205const RefTrf quad_parent_rt2[2] =
206{
207 { {S_ONE, S_HALF, 0}, {0, 0, 0} },
208 { {S_ONE, S_HALF, 0}, {0, T_HALF, 0} }
209};
210
211const RefTrf quad_child_rt2[2] =
212{
213 { {S_ONE, S_TWO, 0}, {0, 0, 0} },
214 { {S_ONE, S_TWO, 0}, {0, -T_ONE, 0} }
215};
216
217const RefTrf quad_parent_rt3[4] =
218{
219 { {S_HALF, S_HALF, 0}, { 0, 0, 0} },
220 { {S_HALF, S_HALF, 0}, {T_HALF, 0, 0} },
221 { {S_HALF, S_HALF, 0}, {T_HALF, T_HALF, 0} },
222 { {S_HALF, S_HALF, 0}, { 0, T_HALF, 0} }
223};
224
225const RefTrf quad_child_rt3[4] =
226{
227 { {S_TWO, S_TWO, 0}, { 0, 0, 0} },
228 { {S_TWO, S_TWO, 0}, {-T_ONE, 0, 0} },
229 { {S_TWO, S_TWO, 0}, {-T_ONE, -T_ONE, 0} },
230 { {S_TWO, S_TWO, 0}, { 0, -T_ONE, 0} }
231};
232
233const RefTrf* quad_parent[4] =
234{
235 NULL,
236 quad_parent_rt1,
237 quad_parent_rt2,
238 quad_parent_rt3
239};
240
241const RefTrf* quad_child[4] =
242{
243 NULL,
244 quad_child_rt1,
245 quad_child_rt2,
246 quad_child_rt3
247};
248
249const RefTrf hex_parent_rt1[2] =
250{
251 { {S_HALF, S_ONE, S_ONE}, { 0, 0, 0} },
252 { {S_HALF, S_ONE, S_ONE}, {T_HALF, 0, 0} }
253};
254
255const RefTrf hex_child_rt1[2] =
256{
257 { {S_TWO, S_ONE, S_ONE}, { 0, 0, 0} },
258 { {S_TWO, S_ONE, S_ONE}, {-T_ONE, 0, 0} }
259};
260
261const RefTrf hex_parent_rt2[2] =
262{
263 { {S_ONE, S_HALF, S_ONE}, {0, 0, 0} },
264 { {S_ONE, S_HALF, S_ONE}, {0, T_HALF, 0} }
265};
266
267const RefTrf hex_child_rt2[2] =
268{
269 { {S_ONE, S_TWO, S_ONE}, {0, 0, 0} },
270 { {S_ONE, S_TWO, S_ONE}, {0, -T_ONE, 0} }
271};
272
273const RefTrf hex_parent_rt3[4] =
274{
275 { {S_HALF, S_HALF, S_ONE}, { 0, 0, 0} },
276 { {S_HALF, S_HALF, S_ONE}, {T_HALF, 0, 0} },
277 { {S_HALF, S_HALF, S_ONE}, {T_HALF, T_HALF, 0} },
278 { {S_HALF, S_HALF, S_ONE}, { 0, T_HALF, 0} }
279};
280
281const RefTrf hex_child_rt3[4] =
282{
283 { {S_TWO, S_TWO, S_ONE}, { 0, 0, 0} },
284 { {S_TWO, S_TWO, S_ONE}, {-T_ONE, 0, 0} },
285 { {S_TWO, S_TWO, S_ONE}, {-T_ONE, -T_ONE, 0} },
286 { {S_TWO, S_TWO, S_ONE}, { 0, -T_ONE, 0} }
287};
288
289const RefTrf hex_parent_rt4[2] =
290{
291 { {S_ONE, S_ONE, S_HALF}, {0, 0, 0} },
292 { {S_ONE, S_ONE, S_HALF}, {0, 0, T_HALF} }
293};
294
295const RefTrf hex_child_rt4[2] =
296{
297 { {S_ONE, S_ONE, S_TWO}, {0, 0, 0} },
298 { {S_ONE, S_ONE, S_TWO}, {0, 0, -T_ONE} }
299};
300
301const RefTrf hex_parent_rt5[4] =
302{
303 { {S_HALF, S_ONE, S_HALF}, { 0, 0, 0} },
304 { {S_HALF, S_ONE, S_HALF}, {T_HALF, 0, 0} },
305 { {S_HALF, S_ONE, S_HALF}, {T_HALF, 0, T_HALF} },
306 { {S_HALF, S_ONE, S_HALF}, { 0, 0, T_HALF} }
307};
308
309const RefTrf hex_child_rt5[4] =
310{
311 { {S_TWO, S_ONE, S_TWO}, { 0, 0, 0} },
312 { {S_TWO, S_ONE, S_TWO}, {-T_ONE, 0, 0} },
313 { {S_TWO, S_ONE, S_TWO}, {-T_ONE, 0, -T_ONE} },
314 { {S_TWO, S_ONE, S_TWO}, { 0, 0, -T_ONE} }
315};
316
317const RefTrf hex_parent_rt6[4] =
318{
319 { {S_ONE, S_HALF, S_HALF}, {0, 0, 0} },
320 { {S_ONE, S_HALF, S_HALF}, {0, T_HALF, 0} },
321 { {S_ONE, S_HALF, S_HALF}, {0, 0, T_HALF} },
322 { {S_ONE, S_HALF, S_HALF}, {0, T_HALF, T_HALF} }
323};
324
325const RefTrf hex_child_rt6[4] =
326{
327 { {S_ONE, S_TWO, S_TWO}, {0, 0, 0} },
328 { {S_ONE, S_TWO, S_TWO}, {0, -T_ONE, 0} },
329 { {S_ONE, S_TWO, S_TWO}, {0, 0, -T_ONE} },
330 { {S_ONE, S_TWO, S_TWO}, {0, -T_ONE, -T_ONE} }
331};
332
333const RefTrf hex_parent_rt7[8] =
334{
335 { {S_HALF, S_HALF, S_HALF}, { 0, 0, 0} },
336 { {S_HALF, S_HALF, S_HALF}, {T_HALF, 0, 0} },
337 { {S_HALF, S_HALF, S_HALF}, {T_HALF, T_HALF, 0} },
338 { {S_HALF, S_HALF, S_HALF}, { 0, T_HALF, 0} },
339 { {S_HALF, S_HALF, S_HALF}, { 0, 0, T_HALF} },
340 { {S_HALF, S_HALF, S_HALF}, {T_HALF, 0, T_HALF} },
341 { {S_HALF, S_HALF, S_HALF}, {T_HALF, T_HALF, T_HALF} },
342 { {S_HALF, S_HALF, S_HALF}, { 0, T_HALF, T_HALF} }
343};
344
345const RefTrf hex_child_rt7[8] =
346{
347 { {S_TWO, S_TWO, S_TWO}, { 0, 0, 0} },
348 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, 0} },
349 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, -T_ONE, 0} },
350 { {S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, 0} },
351 { {S_TWO, S_TWO, S_TWO}, { 0, 0, -T_ONE} },
352 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, -T_ONE} },
353 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, -T_ONE, -T_ONE} },
354 { {S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, -T_ONE} }
355};
356
357const RefTrf* hex_parent[8] =
358{
359 NULL,
360 hex_parent_rt1,
361 hex_parent_rt2,
362 hex_parent_rt3,
363 hex_parent_rt4,
364 hex_parent_rt5,
365 hex_parent_rt6,
366 hex_parent_rt7
367};
368
369const RefTrf* hex_child[8] =
370{
371 NULL,
372 hex_child_rt1,
373 hex_child_rt2,
374 hex_child_rt3,
375 hex_child_rt4,
376 hex_child_rt5,
377 hex_child_rt6,
378 hex_child_rt7
379};
380
381const RefTrf tri_parent_rt3[4] =
382{
383 { { S_HALF, S_HALF, 0}, { 0, 0, 0} },
384 { { S_HALF, S_HALF, 0}, {T_HALF, 0, 0} },
385 { { S_HALF, S_HALF, 0}, { 0, T_HALF, 0} },
386 { {-S_HALF, -S_HALF, 0}, {T_HALF, T_HALF, 0} }
387};
388
389const RefTrf tri_child_rt3[4] =
390{
391 { { S_TWO, S_TWO, 0}, { 0, 0, 0} },
392 { { S_TWO, S_TWO, 0}, {-T_ONE, 0, 0} },
393 { { S_TWO, S_TWO, 0}, { 0, -T_ONE, 0} },
394 { {-S_TWO, -S_TWO, 0}, { T_ONE, T_ONE, 0} }
395};
396
397const RefTrf* tri_parent[4] =
398{
399 NULL, NULL, NULL,
400 tri_parent_rt3
401};
402
403const RefTrf* tri_child[4] =
404{
405 NULL, NULL, NULL,
406 tri_child_rt3
407};
408
409const RefTrf prism_parent_rt3[4] =
410{
411 { { S_HALF, S_HALF, S_ONE}, { 0, 0, 0} },
412 { { S_HALF, S_HALF, S_ONE}, {T_HALF, 0, 0} },
413 { { S_HALF, S_HALF, S_ONE}, { 0, T_HALF, 0} },
414 { {-S_HALF, -S_HALF, S_ONE}, {T_HALF, T_HALF, 0} }
415};
416
417const RefTrf prism_child_rt3[4] =
418{
419 { { S_TWO, S_TWO, S_ONE}, { 0, 0, 0} },
420 { { S_TWO, S_TWO, S_ONE}, {-T_ONE, 0, 0} },
421 { { S_TWO, S_TWO, S_ONE}, { 0, -T_ONE, 0} },
422 { {-S_TWO, -S_TWO, S_ONE}, { T_ONE, T_ONE, 0} }
423};
424
425const RefTrf prism_parent_rt4[2] =
426{
427 { {S_ONE, S_ONE, S_HALF}, {0, 0, 0} },
428 { {S_ONE, S_ONE, S_HALF}, {0, 0, T_HALF} }
429};
430
431const RefTrf prism_child_rt4[2] =
432{
433 { {S_ONE, S_ONE, S_TWO}, {0, 0, 0} },
434 { {S_ONE, S_ONE, S_TWO}, {0, 0, -T_ONE} }
435};
436
437const RefTrf prism_parent_rt7[8] =
438{
439 { { S_HALF, S_HALF, S_HALF}, { 0, 0, 0} },
440 { { S_HALF, S_HALF, S_HALF}, {T_HALF, 0, 0} },
441 { { S_HALF, S_HALF, S_HALF}, { 0, T_HALF, 0} },
442 { {-S_HALF, -S_HALF, S_HALF}, {T_HALF, T_HALF, 0} },
443 { { S_HALF, S_HALF, S_HALF}, { 0, 0, T_HALF} },
444 { { S_HALF, S_HALF, S_HALF}, {T_HALF, 0, T_HALF} },
445 { { S_HALF, S_HALF, S_HALF}, { 0, T_HALF, T_HALF} },
446 { {-S_HALF, -S_HALF, S_HALF}, {T_HALF, T_HALF, T_HALF} }
447};
448
449const RefTrf prism_child_rt7[8] =
450{
451 { { S_TWO, S_TWO, S_TWO}, { 0, 0, 0} },
452 { { S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, 0} },
453 { { S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, 0} },
454 { {-S_TWO, -S_TWO, S_TWO}, { T_ONE, T_ONE, 0} },
455 { { S_TWO, S_TWO, S_TWO}, { 0, 0, -T_ONE} },
456 { { S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, -T_ONE} },
457 { { S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, -T_ONE} },
458 { {-S_TWO, -S_TWO, S_TWO}, { T_ONE, T_ONE, -T_ONE} }
459};
460
461const RefTrf* prism_parent[8] =
462{
463 NULL, NULL, NULL,
464 prism_parent_rt3,
465 prism_parent_rt4,
466 NULL, NULL,
467 prism_parent_rt7
468};
469
470const RefTrf* prism_child[8] =
471{
472 NULL, NULL, NULL,
473 prism_child_rt3,
474 prism_child_rt4,
475 NULL, NULL,
476 prism_child_rt7
477};
478
479const RefTrf** geom_parent[7] =
480{
481 NULL,
482 NULL,
483 tri_parent,
484 quad_parent,
485 NULL,
486 hex_parent,
487 prism_parent
488};
489
490const RefTrf** geom_child[7] =
491{
492 NULL,
493 NULL,
494 tri_child,
495 quad_child,
496 NULL,
497 hex_child,
498 prism_child
499};
500
501
502} // namespace
503
504} // namespace mfem
std::int64_t RefCoord
Definition ncmesh.hpp:462
RefCoord t[3]
RefCoord s[3]