Intrepid2
Intrepid2_CellTopologyTags.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Intrepid2 Package
4//
5// Copyright 2007 NTESS and the Intrepid2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
33#ifndef __INTREPID2_CELLTOPOLOGYTAGS_HPP__
34#define __INTREPID2_CELLTOPOLOGYTAGS_HPP__
35
36#include "Intrepid2_ConfigDefs.hpp"
37
38//#include "Intrepid2_Types.hpp"
39#include "Intrepid2_Utils.hpp"
40//#include "Intrepid2_Kernels.hpp"
41
42namespace Intrepid2 {
43
44 namespace Impl {
45
46
47 // ---------------------------------------------------------------------------------------
48
49 template<int N>
50 struct Line;
51
55 template<>
56 struct Line<2> {
57 typedef struct Line<2> base_cell_topology_type;
58 enum : int { dimension = 1,
59 numNode = 2,
60 numVert = 2,
61 numEdge = 0,
62 numFace = 0,
63 numIntr = 1 };
64 static constexpr double coords[2][3]{ {-1.0, 0.0, 0.0}, { 1.0, 0.0, 0.0} };
65
66 // base topology has this check method
67 template<typename PointViewType>
68 KOKKOS_INLINE_FUNCTION
69 static bool
70 checkPointInclusion(const PointViewType &point,
71 const double threshold) {
72 const double minus_one = -1.0 - threshold, plus_one = 1.0 + threshold;
73 return (minus_one <= point(0) && point(0) <= plus_one);
74 }
75 };
76
80 template<>
81 struct Line<3> {
82 typedef struct Line<2> base_cell_topology_type;
83 enum : int { dimension = 1,
84 numNode = 3,
85 numVert = 2,
86 numEdge = 0,
87 numFace = 0,
88 numIntr = 1 };
89 static constexpr double coords[3][3]{ {-1.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 0.0, 0.0} };
90
91 template<typename PointViewType>
92 KOKKOS_INLINE_FUNCTION
93 static bool
94 checkPointInclusion(const PointViewType &point,
95 const double threshold) {
96 return base_cell_topology_type::checkPointInclusion(point, threshold);
97 }
98 };
99
100 // ---------------------------------------------------------------------------------------
101
102 template<int N>
103 struct Triangle;
104
108 template<>
109 struct Triangle<3> {
110 typedef struct Triangle<3> base_cell_topology_type;
111 enum : int { dimension = 2,
112 numNode = 3,
113 numVert = 3,
114 numEdge = 3,
115 numFace = 0,
116 numIntr = 1 };
117 static constexpr double coords[3][3]{ { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0} };
118
119 template<typename PointViewType>
120 KOKKOS_INLINE_FUNCTION
121 static bool
122 checkPointInclusion(const PointViewType &point,
123 const double threshold) {
124 const double distance = max( max( -point(0), -point(1) ), point(0) + point(1) - 1.0 );
125 return distance < threshold;
126 }
127 };
128
132 template<>
133 struct Triangle<4> {
134 typedef struct Triangle<3> base_cell_topology_type;
135 enum : int { dimension = 2,
136 numNode = 4,
137 numVert = 3,
138 numEdge = 3,
139 numFace = 0,
140 numIntr = 1 };
141 static constexpr double coords[4][3]{ { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 1.0/3.0, 1.0/3.0, 0.0} };
142
143 template<typename PointViewType>
144 KOKKOS_INLINE_FUNCTION
145 static bool
146 checkPointInclusion(const PointViewType &point,
147 const double threshold) {
148 return base_cell_topology_type::checkPointInclusion(point, threshold);
149 }
150 };
151
155 template<>
156 struct Triangle<6> {
157 typedef struct Triangle<3> base_cell_topology_type;
158 enum : int { dimension = 2,
159 numNode = 6,
160 numVert = 3,
161 numEdge = 3,
162 numFace = 0,
163 numIntr = 1 };
164 static constexpr double coords[6][3]{ { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0},
165 { 0.5, 0.0, 0.0}, { 0.5, 0.5, 0.0}, { 0.0, 0.5, 0.0} };
166
167 template<typename PointViewType>
168 KOKKOS_INLINE_FUNCTION
169 static bool
170 checkPointInclusion(const PointViewType &point,
171 const double threshold) {
172 return base_cell_topology_type::checkPointInclusion(point, threshold);
173 }
174 };
175
176 // ---------------------------------------------------------------------------------------
177
178 template<int N>
180
184 template<>
185 struct Quadrilateral<4> {
186 typedef struct Quadrilateral<4> base_cell_topology_type;
187 enum : int { dimension = 2,
188 numNode = 4,
189 numVert = 4,
190 numEdge = 4,
191 numFace = 0,
192 numIntr = 1 };
193 static constexpr double coords[4][3]{ {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0} };
194
195 template<typename PointViewType>
196 KOKKOS_INLINE_FUNCTION
197 static bool
198 checkPointInclusion(const PointViewType &point,
199 const double threshold) {
200 const double minus_one = -1.0 - threshold, plus_one = 1.0 + threshold;
201 return ((minus_one <= point(0) && point(0) <= plus_one) &&
202 (minus_one <= point(1) && point(1) <= plus_one));
203 }
204 };
205
209 template<>
210 struct Quadrilateral<8> {
211 typedef struct Quadrilateral<4> base_cell_topology_type;
212 enum : int { dimension = 2,
213 numNode = 8,
214 numVert = 4,
215 numEdge = 4,
216 numFace = 0,
217 numIntr = 1 };
218 static constexpr double coords[8][3]{ {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0},
219 { 0.0,-1.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0} };
220
221 template<typename PointViewType>
222 KOKKOS_INLINE_FUNCTION
223 static bool
224 checkPointInclusion(const PointViewType &point,
225 const double threshold) {
226 return base_cell_topology_type::checkPointInclusion(point, threshold);
227 }
228 };
229
233 template<>
234 struct Quadrilateral<9> {
235 typedef struct Quadrilateral<4> base_cell_topology_type;
236 enum : int { dimension = 2,
237 numNode = 9,
238 numVert = 4,
239 numEdge = 4,
240 numFace = 0,
241 numIntr = 1 };
242 static constexpr double coords[9][3]{ {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0},
243 { 0.0,-1.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0}, { 0.0, 0.0, 0.0} };
244
245 template<typename PointViewType>
246 KOKKOS_INLINE_FUNCTION
247 static bool
248 checkPointInclusion(const PointViewType &point,
249 const double threshold) {
250 return base_cell_topology_type::checkPointInclusion(point, threshold);
251 }
252 };
253
254 // ---------------------------------------------------------------------------------------
255
256 template<int N>
258
262 template<>
263 struct Tetrahedron<4> {
264 typedef struct Tetrahedron<4> base_cell_topology_type;
265 enum : int { dimension = 3,
266 numNode = 4,
267 numVert = 4,
268 numEdge = 6,
269 numFace = 4,
270 numIntr = 1 };
271 static constexpr double coords[4][3]{ { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.0, 0.0, 1.0} };
272
273 template<typename PointViewType>
274 KOKKOS_INLINE_FUNCTION
275 static bool
276 checkPointInclusion(const PointViewType &point,
277 const double threshold) {
278 const double distance = max( max(-point(0),-point(1)),
279 max(-point(2), point(0) + point(1) + point(2) - 1) );
280
281 return distance < threshold;
282 }
283 };
284
288 template<>
289 struct Tetrahedron<8> {
290 typedef struct Tetrahedron<4> base_cell_topology_type;
291 enum : int { dimension = 3,
292 numNode = 8,
293 numVert = 4,
294 numEdge = 6,
295 numFace = 4,
296 numIntr = 1 };
297 static constexpr double coords[8][3]{ { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.0, 0.0, 1.0},
298 { 1/3, 0.0, 1/3}, { 1/3, 1/3, 1/3}, { 1/3, 1/3, 0.0}, { 0.0, 1/3, 1/3} };
299
300 template<typename PointViewType>
301 KOKKOS_INLINE_FUNCTION
302 static bool
303 checkPointInclusion(const PointViewType &point,
304 const double threshold) {
305 return base_cell_topology_type::checkPointInclusion(point, threshold);
306 }
307 };
308
312 template<>
313 struct Tetrahedron<10> {
314 typedef struct Tetrahedron<4> base_cell_topology_type;
315 enum : int { dimension = 3,
316 numNode = 10,
317 numVert = 4,
318 numEdge = 6,
319 numFace = 4,
320 numIntr = 1 };
321 static constexpr double coords[10][3]{ { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.0, 0.0, 1.0},
322 { 0.5, 0.0, 0.0}, { 0.5, 0.5, 0.0}, { 0.0, 0.5, 0.0}, { 0.0, 0.0, 0.5}, { 0.5, 0.0, 0.5}, { 0.0, 0.5, 0.5} };
323
324 template<typename PointViewType>
325 KOKKOS_INLINE_FUNCTION
326 static bool
327 checkPointInclusion(const PointViewType &point,
328 const double threshold) {
329 return base_cell_topology_type::checkPointInclusion(point, threshold);
330 }
331 };
332
336 template<>
337 struct Tetrahedron<11> {
338 typedef struct Tetrahedron<4> base_cell_topology_type;
339 enum : int { dimension = 3,
340 numNode = 11,
341 numVert = 4,
342 numEdge = 6,
343 numFace = 4,
344 numIntr = 1 };
345 static constexpr double coords[11][3]{ { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, { 0.0, 0.0, 1.0},
346 { 0.5, 0.0, 0.0}, { 0.5, 0.5, 0.0}, { 0.0, 0.5, 0.0}, { 0.0, 0.0, 0.5}, { 0.5, 0.0, 0.5}, { 0.0, 0.5, 0.5} };
347
348 template<typename PointViewType>
349 KOKKOS_INLINE_FUNCTION
350 static bool
351 checkPointInclusion(const PointViewType &point,
352 const double threshold) {
353 return base_cell_topology_type::checkPointInclusion(point, threshold);
354 }
355 };
356
357 // ---------------------------------------------------------------------------------------
358
359 template<int N>
361
365 template<>
366 struct Hexahedron<8> {
367 typedef struct Hexahedron<8> base_cell_topology_type;
368 enum : int { dimension = 3,
369 numNode = 8,
370 numVert = 8,
371 numEdge = 12,
372 numFace = 6,
373 numIntr = 1 };
374 static constexpr double coords[8][3]{ {-1.0,-1.0,-1.0}, { 1.0,-1.0,-1.0}, { 1.0, 1.0,-1.0}, {-1.0, 1.0,-1.0},
375 {-1.0,-1.0, 1.0}, { 1.0,-1.0, 1.0}, { 1.0, 1.0, 1.0}, {-1.0, 1.0, 1.0} };
376
377 template<typename PointViewType>
378 KOKKOS_INLINE_FUNCTION
379 static bool
380 checkPointInclusion(const PointViewType &point,
381 const double threshold) {
382 const double minus_one = -1.0 - threshold, plus_one = 1.0 + threshold;
383 return ((minus_one <= point(0) && point(0) <= plus_one) &&
384 (minus_one <= point(1) && point(1) <= plus_one) &&
385 (minus_one <= point(2) && point(2) <= plus_one));
386 }
387 };
388
392 template<>
393 struct Hexahedron<20> {
394 typedef struct Hexahedron<8> base_cell_topology_type;
395 enum : int { dimension = 3,
396 numNode = 20,
397 numVert = 8,
398 numEdge = 12,
399 numFace = 6,
400 numIntr = 1 };
401 static constexpr double coords[20][3]{ {-1.0,-1.0,-1.0}, { 1.0,-1.0,-1.0}, { 1.0, 1.0,-1.0}, {-1.0, 1.0,-1.0},
402 {-1.0,-1.0, 1.0}, { 1.0,-1.0, 1.0}, { 1.0, 1.0, 1.0}, {-1.0, 1.0, 1.0},
403 { 0.0,-1.0,-1.0}, { 1.0, 0.0,-1.0}, { 0.0, 1.0,-1.0}, {-1.0, 0.0,-1.0},
404 {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0},
405 { 0.0,-1.0, 1.0}, { 1.0, 0.0, 1.0}, { 0.0, 1.0, 1.0}, {-1.0, 0.0, 1.0} };
406
407 template<typename PointViewType>
408 KOKKOS_INLINE_FUNCTION
409 static bool
410 checkPointInclusion(const PointViewType &point,
411 const double threshold) {
412 return base_cell_topology_type::checkPointInclusion(point, threshold);
413 }
414
415 };
416
420 template<>
421 struct Hexahedron<27> {
422 typedef struct Hexahedron<8> base_cell_topology_type;
423 enum : int { dimension = 3,
424 numNode = 27,
425 numVert = 8,
426 numEdge = 12,
427 numFace = 6,
428 numIntr = 1 };
429 static constexpr double coords[27][3]{ {-1.0,-1.0,-1.0}, { 1.0,-1.0,-1.0}, { 1.0, 1.0,-1.0}, {-1.0, 1.0,-1.0},
430 {-1.0,-1.0, 1.0}, { 1.0,-1.0, 1.0}, { 1.0, 1.0, 1.0}, {-1.0, 1.0, 1.0},
431 { 0.0,-1.0,-1.0}, { 1.0, 0.0,-1.0}, { 0.0, 1.0,-1.0}, {-1.0, 0.0,-1.0},
432 {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0},
433 { 0.0,-1.0, 1.0}, { 1.0, 0.0, 1.0}, { 0.0, 1.0, 1.0}, {-1.0, 0.0, 1.0},
434 { 0.0, 0.0, 0.0},
435 { 0.0, 0.0,-1.0}, { 0.0, 0.0, 1.0}, {-1.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, {0.0,-1.0, 0.0}, {0.0, 1.0, 0.0} };
436
437 template<typename PointViewType>
438 KOKKOS_INLINE_FUNCTION
439 static bool
440 checkPointInclusion(const PointViewType &point,
441 const double threshold) {
442 return base_cell_topology_type::checkPointInclusion(point, threshold);
443 }
444 };
445
446 // ---------------------------------------------------------------------------------------
447
448 template<int N>
449 struct Pyramid;
450
454 template<>
455 struct Pyramid<5> {
456 typedef struct Pyramid<5> base_cell_topology_type;
457 enum : int { dimension = 3,
458 numNode = 5,
459 numVert = 5,
460 numEdge = 8,
461 numFace = 5,
462 numIntr = 1 };
463 static constexpr double coords[5][3]{ {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0}, { 0.0, 0.0, 1.0} };
464
465 template<typename PointViewType>
466 KOKKOS_INLINE_FUNCTION
467 static bool
468 checkPointInclusion(const PointViewType &point,
469 const double threshold) {
470 const double minus_one = -1.0 - threshold, plus_one = 1.0 + threshold, minus_zero = -threshold;
471 const double left = minus_one + point(2);
472 const double right = plus_one - point(2);
473 return ((left <= point(0) && point(0) <= right) &&
474 (left <= point(1) && point(1) <= right) &&
475 (minus_zero <= point(2) && point(2) <= plus_one));
476 }
477 };
478
482 template<>
483 struct Pyramid<13> {
484 typedef struct Pyramid<5> base_cell_topology_type;
485 enum : int { dimension = 3,
486 numNode = 13,
487 numVert = 5,
488 numEdge = 8,
489 numFace = 5,
490 numIntr = 1 };
491 static constexpr double coords[13][3]{ {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0}, { 0.0, 0.0, 1.0},
492 { 0.0,-1.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0},
493 {-0.5,-0.5, 0.5}, { 0.5,-0.5, 0.5}, { 0.5, 0.5, 0.5}, {-0.5, 0.5, 0.5} };
494
495 template<typename PointViewType>
496 KOKKOS_INLINE_FUNCTION
497 static bool
498 checkPointInclusion(const PointViewType &point,
499 const double threshold) {
500 return base_cell_topology_type::checkPointInclusion(point, threshold);
501 }
502 };
503
507 template<>
508 struct Pyramid<14> {
509 typedef struct Pyramid<5> base_cell_topology_type;
510 enum : int { dimension = 3,
511 numNode = 14,
512 numVert = 5,
513 numEdge = 8,
514 numFace = 5,
515 numIntr = 1 };
516 static constexpr double coords[14][3]{ {-1.0,-1.0, 0.0}, { 1.0,-1.0, 0.0}, { 1.0, 1.0, 0.0}, {-1.0, 1.0, 0.0}, { 0.0, 0.0, 1.0},
517 { 0.0,-1.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0}, {-1.0, 0.0, 0.0},
518 {-0.5,-0.5, 0.5}, { 0.5,-0.5, 0.5}, { 0.5, 0.5, 0.5}, {-0.5, 0.5, 0.5}, { 0.0, 0.0, 0.0} };
519
520 template<typename PointViewType>
521 KOKKOS_INLINE_FUNCTION
522 static bool
523 checkPointInclusion(const PointViewType &point,
524 const double threshold) {
525 return base_cell_topology_type::checkPointInclusion(point, threshold);
526 }
527 };
528
529 // ---------------------------------------------------------------------------------------
530
531 template<int N>
532 struct Wedge;
533
537 template<>
538 struct Wedge<6> {
539 typedef struct Wedge<6> base_cell_topology_type;
540 enum : int { dimension = 3,
541 numNode = 6,
542 numVert = 6,
543 numEdge = 9,
544 numFace = 5,
545 numIntr = 1 };
546 static constexpr double coords[6][3]{ { 0.0, 0.0,-1.0}, { 1.0, 0.0,-1.0}, { 0.0, 1.0,-1.0}, { 0.0, 0.0, 1.0}, { 1.0, 0.0, 1.0}, { 0.0, 1.0, 1.0} };
547
548 template<typename PointViewType>
549 KOKKOS_INLINE_FUNCTION
550 static bool
551 checkPointInclusion(const PointViewType &point,
552 const double threshold) {
553 const double minus_one = -1.0 - threshold, plus_one = 1.0 + threshold;
554 const double distance = max( max( -point(0), -point(1) ), point(0) + point(1) - 1 );
555 return (distance < threshold && (minus_one <= point(2) && point(2) <= plus_one));
556 }
557 };
558
562 template<>
563 struct Wedge<15> {
564 typedef struct Wedge<6> base_cell_topology_type;
565 enum : int { dimension = 3,
566 numNode = 15,
567 numVert = 6,
568 numEdge = 9,
569 numFace = 5,
570 numIntr = 1 };
571 static constexpr double coords[15][3]{ { 0.0, 0.0,-1.0}, { 1.0, 0.0,-1.0}, { 0.0, 1.0,-1.0}, { 0.0, 0.0, 1.0}, { 1.0, 0.0, 1.0}, { 0.0, 1.0, 1.0},
572 { 0.5, 0.0,-1.0}, { 0.5, 0.5,-1.0}, { 0.0, 0.5,-1.0}, { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0},
573 { 0.5, 0.0, 1.0}, { 0.5, 0.5, 1.0}, { 0.0, 0.5, 1.0} };
574
575 template<typename PointViewType>
576 KOKKOS_INLINE_FUNCTION
577 static bool
578 checkPointInclusion(const PointViewType &point,
579 const double threshold) {
580 return base_cell_topology_type::checkPointInclusion(point, threshold);
581 }
582 };
583
587 template<>
588 struct Wedge<18> {
589 typedef struct Wedge<6> base_cell_topology_type;
590 enum : int { dimension = 3,
591 numNode = 18,
592 numVert = 6,
593 numEdge = 9,
594 numFace = 5,
595 numIntr = 1 };
596 static constexpr double coords[18][3]{ { 0.0, 0.0,-1.0}, { 1.0, 0.0,-1.0}, { 0.0, 1.0,-1.0}, { 0.0, 0.0, 1.0}, { 1.0, 0.0, 1.0}, { 0.0, 1.0, 1.0},
597 { 0.5, 0.0,-1.0}, { 0.5, 0.5,-1.0}, { 0.0, 0.5,-1.0}, { 0.0, 0.0, 0.0}, { 1.0, 0.0, 0.0}, { 0.0, 1.0, 0.0},
598 { 0.5, 0.0, 1.0}, { 0.5, 0.5, 1.0}, { 0.0, 0.5, 1.0},
599 { 0.5, 0.0, 0.0}, { 0.5, 0.5, 0.0}, { 0.0, 0.5, 0.0} };
600
601
602 template<typename PointViewType>
603 KOKKOS_INLINE_FUNCTION
604 static bool
605 checkPointInclusion(const PointViewType &point,
606 const double threshold) {
607 return base_cell_topology_type::checkPointInclusion(point, threshold);
608 }
609 };
610
611 }
612}
613
614#endif
615
Header function for Intrepid2::Util class and other utility functions.