Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
DLR-AMR
GitHub Repository: DLR-AMR/t8code
Path: blob/main/src/t8_eclass.c
898 views
1
/*
2
This file is part of t8code.
3
t8code is a C library to manage a collection (a forest) of multiple
4
connected adaptive space-trees of general element classes in parallel.
5
6
Copyright (C) 2025 the developers
7
8
t8code is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
12
13
t8code is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU General Public License
19
along with t8code; if not, write to the Free Software Foundation, Inc.,
20
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
*/
22
23
/** \file t8_eclass.c
24
* Definition of C const integers using the value macros from \ref t8_eclass.h.
25
*/
26
27
#define KEEP_ECLASS_VALUE_DEFINITIONS
28
#include <t8_eclass.h>
29
#undef KEEP_ECLASS_VALUE_DEFINITIONS
30
31
const int t8_eclass_to_dimension[T8_ECLASS_COUNT] = T8_ECLASS_TO_DIMENSION_VALUES;
32
33
const int t8_eclass_num_faces[T8_ECLASS_COUNT] = T8_ECLASS_NUM_FACES_VALUES;
34
35
const int t8_eclass_max_num_faces[T8_ECLASS_MAX_DIM + 1] = T8_ECLASS_MAX_NUM_FACES_VALUES;
36
37
const int t8_eclass_max_num_children[T8_ECLASS_COUNT] = T8_ECLASS_MAX_NUM_CHILDREN_VALUES;
38
39
const int t8_face_vertex_to_tree_vertex[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_CORNERS_2D]
40
= T8_FACE_VERTEX_TO_TREE_VERTEX_VALUES;
41
42
const int t8_face_edge_to_tree_edge[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_EDGES_2D]
43
= T8_FACE_EDGE_TO_TREE_EDGE_VALUES;
44
45
const int t8_face_to_edge_neighbor[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES][T8_ECLASS_MAX_CORNERS_2D]
46
= T8_FACE_TO_EDGE_NEIGHBOR_VALUES;
47
48
const int t8_edge_vertex_to_tree_vertex[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2] = T8_EDGE_VERTEX_TO_TREE_VERTEX_VALUES;
49
50
const int t8_edge_to_face[T8_ECLASS_COUNT][T8_ECLASS_MAX_EDGES][2] = T8_EDGE_TO_FACE_VALUES;
51
52
const int t8_eclass_face_orientation[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] = T8_ECLASS_FACE_ORIENTATION_VALUES;
53
54
const int t8_reference_face_normal_tet[T8_ECLASS_MAX_FACES][3] = T8_REFERENCE_FACE_NORMAL_TET_VALUES;
55
56
const int t8_eclass_num_vertices[T8_ECLASS_COUNT] = T8_ECLASS_NUM_VERTICES_VALUES;
57
58
const int t8_eclass_num_edges[T8_ECLASS_COUNT] = T8_ECLASS_NUM_EDGES_VALUES;
59
60
const int t8_eclass_vtk_type[T8_ECLASS_COUNT] = T8_ECLASS_VTK_TYPE_VALUES;
61
62
const int t8_eclass_vtk_to_t8_corner_number[T8_ECLASS_COUNT][T8_ECLASS_MAX_CORNERS]
63
= T8_ECLASS_VTK_TO_T8_CORNER_NUMBER_VALUES;
64
65
const int t8_eclass_t8_to_vtk_corner_number[T8_ECLASS_COUNT][T8_ECLASS_MAX_CORNERS]
66
= T8_ECLASS_T8_TO_VTK_CORNER_NUMBER_VALUES;
67
68
const int t8_eclass_face_types[T8_ECLASS_COUNT][T8_ECLASS_MAX_FACES] = T8_ECLASS_FACE_TYPES_VALUES;
69
70
const int t8_eclass_boundary_count[T8_ECLASS_COUNT][T8_ECLASS_COUNT] = T8_ECLASS_BOUNDARY_COUNT_VALUES;
71
72
const char *t8_eclass_to_string[T8_ECLASS_INVALID] = T8_ECLASS_TO_STRING_VALUES;
73
74
int
75
t8_eclass_count_boundary (t8_eclass_t theclass, int min_dim, int *per_eclass)
76
{
77
int sum = 0;
78
for (int t = T8_ECLASS_ZERO; t < T8_ECLASS_COUNT; ++t) {
79
if (t8_eclass_to_dimension[t] >= min_dim) {
80
sum += (per_eclass[t] = t8_eclass_boundary_count[theclass][t]);
81
}
82
else {
83
per_eclass[t] = 0;
84
}
85
}
86
87
return sum;
88
}
89
90
/* Compares two eclasses within the order
91
* Tri < Quad
92
* Tet < Hex < Prism < Pyramid
93
* Eclasses of different dimension are not allowed to be compared.
94
*/
95
int
96
t8_eclass_compare (t8_eclass_t eclass1, t8_eclass_t eclass2)
97
{
98
int dim = t8_eclass_to_dimension[eclass1];
99
T8_ASSERT (dim == t8_eclass_to_dimension[eclass2]);
100
101
if (eclass1 == eclass2) {
102
/* If both are equal return 0.
103
* This also captures the case dim <= 1. */
104
return 0;
105
}
106
else if (dim == 2) {
107
/* Either eclass1 = tri and eclass2 = quad or the other way around. */
108
return eclass1 == T8_ECLASS_TRIANGLE ? -1 : 1;
109
}
110
else {
111
T8_ASSERT (dim == 3);
112
switch (eclass1) {
113
case T8_ECLASS_TET:
114
return -1;
115
case T8_ECLASS_HEX:
116
return eclass2 == T8_ECLASS_TET ? 1 : -1;
117
case T8_ECLASS_PRISM:
118
return eclass2 == T8_ECLASS_PYRAMID ? -1 : 1;
119
default:
120
T8_ASSERT (eclass1 == T8_ECLASS_PYRAMID);
121
return 1;
122
}
123
}
124
}
125
126
int
127
t8_eclass_is_valid (t8_eclass_t eclass)
128
{
129
/* every eclass up to T8_ECLASS_COUNT is a valid class T8_ECLASS_COUNT
130
* itself is invalid, every class higher than eclass count is considered
131
* invalid.*/
132
return eclass < T8_ECLASS_COUNT;
133
}
134
135