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