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