deal.II version GIT relicensing-7182-g951947b1c4 2026-11-26 10:30:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
geometry_info.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 1998 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_geometry_info_h
14#define dealii_geometry_info_h
15
16
17#include <deal.II/base/config.h>
18
22#include <deal.II/base/point.h>
24#include <deal.II/base/tensor.h>
25#include <deal.II/base/types.h>
26
27#include <Kokkos_Macros.hpp>
28
29#include <algorithm>
30#include <array>
31#include <cstddef>
32#include <cstdint>
33#include <ostream>
34#include <string>
35
36
37
39
40#ifndef DOXYGEN
41namespace internal
42{
43 namespace GeometryInfoHelper
44 {
45 // A struct that holds the values for all the arrays we want to initialize
46 // in GeometryInfo
47 template <int dim>
48 struct Initializers;
49
50 template <>
51 struct Initializers<1>
52 {
53 static constexpr std::array<unsigned int, 2>
54 ucd_to_deal()
55 {
56 return {{0, 1}};
57 }
58
59 static constexpr std::array<unsigned int, 2>
60 unit_normal_direction()
61 {
62 return {{0, 0}};
63 }
64
65 static constexpr std::array<int, 2>
66 unit_normal_orientation()
67 {
68 return {{-1, 1}};
69 }
70
71 static constexpr std::array<Tensor<1, 1>, 2>
72 unit_normal_vector()
73 {
74 return {{Tensor<1, 1>{{-1}}, Tensor<1, 1>{{1}}}};
75 }
76
77 static constexpr ::ndarray<Tensor<1, 1>, 2, 0>
78 unit_tangential_vectors()
79 {
80 return {{{{}}, {{}}}};
81 }
83 static constexpr std::array<unsigned int, 2>
84 opposite_face()
85 {
86 return {{1, 0}};
87 }
88
89 static constexpr std::array<unsigned int, 2>
90 dx_to_deal()
91 {
92 return {{0, 1}};
93 }
94
95 static constexpr ::ndarray<unsigned int, 2, 1>
96 vertex_to_face()
97 {
98 return {{{{0}}, {{1}}}};
99 }
100 };
101
102 template <>
103 struct Initializers<2>
104 {
105 static constexpr std::array<unsigned int, 4>
106 ucd_to_deal()
107 {
108 return {{0, 1, 3, 2}};
109 }
110
111 static constexpr std::array<unsigned int, 4>
112 unit_normal_direction()
113 {
114 return {{0, 0, 1, 1}};
115 }
116
117 static constexpr std::array<int, 4>
118 unit_normal_orientation()
119 {
120 return {{-1, 1, -1, 1}};
121 }
122
123 static constexpr std::array<Tensor<1, 2>, 4>
124 unit_normal_vector()
125 {
126 return {{Tensor<1, 2>{{-1., 0.}},
127 Tensor<1, 2>{{1., 0.}},
128 Tensor<1, 2>{{0., -1.}},
129 Tensor<1, 2>{{0., 1.}}}};
130 }
131
132 static constexpr ::ndarray<Tensor<1, 2>, 4, 1>
133 unit_tangential_vectors()
134 {
135 return {{{{Tensor<1, 2>{{0, -1}}}},
136 {{Tensor<1, 2>{{0, 1}}}},
137 {{Tensor<1, 2>{{1, 0}}}},
138 {{Tensor<1, 2>{{-1, 0}}}}}};
139 }
140
141 static constexpr std::array<unsigned int, 4>
142 opposite_face()
143 {
144 return {{1, 0, 3, 2}};
145 }
146
147 static constexpr std::array<unsigned int, 4>
148 dx_to_deal()
149 {
150 return {{0, 2, 1, 3}};
151 }
152
153 static constexpr ::ndarray<unsigned int, 4, 2>
154 vertex_to_face()
155 {
156 return {{{{0, 2}}, {{1, 2}}, {{0, 3}}, {{1, 3}}}};
157 }
158 };
159
160 template <>
161 struct Initializers<3>
162 {
163 static constexpr std::array<unsigned int, 8>
164 ucd_to_deal()
165 {
166 return {{0, 4, 5, 1, 2, 6, 7, 3}};
167 }
168
169 static constexpr std::array<unsigned int, 6>
170 unit_normal_direction()
171 {
172 return {{0, 0, 1, 1, 2, 2}};
173 }
174
175 static constexpr std::array<int, 6>
176 unit_normal_orientation()
177 {
178 return {{-1, 1, -1, 1, -1, 1}};
179 }
180
181 static constexpr std::array<Tensor<1, 3>, 6>
182 unit_normal_vector()
183 {
184 return {{Tensor<1, 3>{{-1, 0, 0}},
185 Tensor<1, 3>{{1, 0, 0}},
186 Tensor<1, 3>{{0, -1, 0}},
187 Tensor<1, 3>{{0, 1, 0}},
188 Tensor<1, 3>{{0, 0, -1}},
189 Tensor<1, 3>{{0, 0, 1}}}};
190 }
191
192 static constexpr ::ndarray<Tensor<1, 3>, 6, 2>
193 unit_tangential_vectors()
194 {
195 return {{{{Tensor<1, 3>{{0, -1, 0}}, Tensor<1, 3>{{0, 0, 1}}}},
196 {{Tensor<1, 3>{{0, 1, 0}}, Tensor<1, 3>{{0, 0, 1}}}},
197 {{Tensor<1, 3>{{0, 0, -1}}, Tensor<1, 3>{{1, 0, 0}}}},
198 {{Tensor<1, 3>{{0, 0, 1}}, Tensor<1, 3>{{1, 0, 0}}}},
199 {{Tensor<1, 3>{{-1, 0, 0}}, Tensor<1, 3>{{0, 1, 0}}}},
200 {{Tensor<1, 3>{{1, 0, 0}}, Tensor<1, 3>{{0, 1, 0}}}}}};
201 }
202
203 static constexpr std::array<unsigned int, 6>
204 opposite_face()
205 {
206 return {{1, 0, 3, 2, 5, 4}};
207 }
208
209 static constexpr std::array<unsigned int, 8>
210 dx_to_deal()
211 {
212 return {{0, 4, 2, 6, 1, 5, 3, 7}};
213 }
214
215 static constexpr ::ndarray<unsigned int, 8, 3>
216 vertex_to_face()
217 {
218 return {{{{0, 2, 4}},
219 {{1, 2, 4}},
220 {{0, 3, 4}},
221 {{1, 3, 4}},
222 {{0, 2, 5}},
223 {{1, 2, 5}},
224 {{0, 3, 5}},
225 {{1, 3, 5}}}};
226 }
227 };
228
229 template <>
230 struct Initializers<4>
231 {
232 static constexpr std::array<unsigned int, 16>
233 ucd_to_deal()
234 {
251 }
252
253 static constexpr std::array<unsigned int, 8>
254 unit_normal_direction()
255 {
256 return {{0, 0, 1, 1, 2, 2, 3, 3}};
257 }
258
259 static constexpr std::array<int, 8>
260 unit_normal_orientation()
261 {
262 return {{-1, 1, -1, 1, -1, 1, -1, 1}};
263 }
264
265 static constexpr std::array<Tensor<1, 4>, 8>
266 unit_normal_vector()
267 {
268 return {{Tensor<1, 4>{{-1, 0, 0, 0}},
269 Tensor<1, 4>{{1, 0, 0, 0}},
270 Tensor<1, 4>{{0, -1, 0, 0}},
271 Tensor<1, 4>{{0, 1, 0, 0}},
272 Tensor<1, 4>{{0, 0, -1, 0}},
273 Tensor<1, 4>{{0, 0, 1, 0}},
274 Tensor<1, 4>{{0, 0, 0, -1}},
275 Tensor<1, 4>{{0, 0, 0, 1}}}};
276 }
277
278 static constexpr ::ndarray<Tensor<1, 4>, 8, 3>
279 unit_tangential_vectors()
280 {
281 return {{{{Tensor<1, 4>{{0, -1, 0, 0}},
282 Tensor<1, 4>{{0, 0, 1, 0}},
283 Tensor<1, 4>{{0, 0, 0, 1}}}},
284 {{Tensor<1, 4>{{0, 1, 0, 0}},
285 Tensor<1, 4>{{0, 0, 1, 0}},
286 Tensor<1, 4>{{0, 0, 0, 1}}}},
287 {{Tensor<1, 4>{{0, 0, -1, 0}},
288 Tensor<1, 4>{{0, 0, 0, 1}},
289 Tensor<1, 4>{{1, 0, 0, 0}}}},
290 {{Tensor<1, 4>{{0, 0, 1, 0}},
291 Tensor<1, 4>{{0, 0, 0, 1}},
292 Tensor<1, 4>{{1, 0, 0, 0}}}},
293 {{Tensor<1, 4>{{0, 0, 0, -1}},
294 Tensor<1, 4>{{1, 0, 0, 0}},
295 Tensor<1, 4>{{0, 1, 0, 0}}}},
296 {{Tensor<1, 4>{{0, 0, 0, 1}},
297 Tensor<1, 4>{{1, 0, 0, 0}},
298 Tensor<1, 4>{{0, 1, 0, 0}}}},
299 {{Tensor<1, 4>{{-1, 0, 0, 0}},
300 Tensor<1, 4>{{0, 1, 0, 0}},
301 Tensor<1, 4>{{0, 0, 1, 0}}}},
302 {{Tensor<1, 4>{{1, 0, 0, 0}},
303 Tensor<1, 4>{{0, 1, 0, 0}},
304 Tensor<1, 4>{{0, 0, 1, 0}}}}}};
305 }
306
307 static constexpr std::array<unsigned int, 8>
308 opposite_face()
309 {
310 return {{1, 0, 3, 2, 5, 4, 7, 6}};
311 }
312
313 static constexpr std::array<unsigned int, 16>
314 dx_to_deal()
315 {
332 }
333
334 static constexpr ::ndarray<unsigned int, 16, 4>
335 vertex_to_face()
336 {
401 }
402 };
403 } // namespace GeometryInfoHelper
404} // namespace internal
405#endif // DOXYGEN
406
407
424{
425public:
433 {
441 line = 1,
445 quad = 2,
449 hex = 3
450 };
451
457
463 GeometryPrimitive(const unsigned int object_dimension);
464
469 operator unsigned int() const;
470
471private:
476};
477
478
479
490template <int dim>
492{
527 enum Possibilities : std::uint8_t
528 {
533
546 };
547};
548
549
550
558template <>
560{
595 enum Possibilities : std::uint8_t
596 {
604 cut_x = 1,
609 };
610};
611
612
613
622template <>
624{
659 enum Possibilities : std::uint8_t
660 {
668 cut_x = 1,
672 cut_y = 2,
676 cut_xy = cut_x | cut_y,
677
681 isotropic_refinement = cut_xy
682 };
683};
684
685
686
695template <>
697{
732 enum Possibilities : std::uint8_t
733 {
741 cut_x = 1,
745 cut_y = 2,
749 cut_xy = cut_x | cut_y,
753 cut_z = 4,
757 cut_xz = cut_x | cut_z,
761 cut_yz = cut_y | cut_z,
765 cut_xyz = cut_x | cut_y | cut_z,
766
770 isotropic_refinement = cut_xyz
771 };
772};
773
774
775
784template <int dim>
786{
787public:
791 static constexpr unsigned int n_refinement_cases = (1 << dim);
792
796 constexpr RefinementCase();
797
802 constexpr RefinementCase(
803 const typename RefinementPossibilities<dim>::Possibilities refinement_case);
804
810 constexpr explicit RefinementCase(const std::uint8_t refinement_case);
811
824 constexpr
825 operator std::uint8_t() const;
826
831 constexpr RefinementCase
832 operator|(const RefinementCase &r) const;
833
838 constexpr RefinementCase
839 operator&(const RefinementCase &r) const;
840
848 constexpr RefinementCase
849 operator~() const;
850
851
857 static constexpr RefinementCase
858 cut_axis(const unsigned int i);
859
868 static constexpr std::array<RefinementCase<dim>, n_refinement_cases>
870
874 static constexpr std::size_t
876
882 template <class Archive>
883 void
884 serialize(Archive &ar, const unsigned int version);
885
891 int,
892 << "The refinement flags given (" << arg1
893 << ") contain set bits that do not "
894 << "make sense for the space dimension of the object to which they are applied.");
895
896private:
901 std::uint8_t value : (dim > 0 ? dim : 1);
902};
903
904
905
906namespace internal
907{
925 template <int dim>
927 {
932 {
937
941 case_isotropic = static_cast<std::uint8_t>(-1)
942 };
943 };
944
945
952 template <>
954 {
972 };
973
974
975
983 template <>
985 {
1003 };
1004
1005
1006
1015 template <>
1017 {
1025 {
1033 case_x = 1,
1037 case_isotropic = case_x
1039 };
1040
1041
1042
1132 template <>
1134 {
1142 {
1144 case_x = 1,
1145 case_x1y = 2,
1146 case_x2y = 3,
1147 case_x1y2y = 4,
1148 case_y = 5,
1149 case_y1x = 6,
1150 case_y2x = 7,
1151 case_y1x2x = 8,
1152 case_xy = 9,
1153
1154 case_isotropic = case_xy
1156 };
1157
1158
1159
1164 template <int dim>
1166 {
1167 public:
1174 subface_possibility);
1175
1187 operator std::uint8_t() const;
1188
1192 static constexpr std::size_t
1194
1200 int,
1201 << "The subface case given (" << arg1 << ") does not make sense "
1202 << "for the space dimension of the object to which they are applied.");
1203
1204 private:
1209 std::uint8_t value : (dim == 3 ? 4 : 1);
1210 };
1211
1212} // namespace internal
1213
1214
1215
1216template <int dim>
1217struct GeometryInfo;
1218
1219
1220
1240template <>
1242{
1250 static constexpr unsigned int max_children_per_cell = 1;
1251
1255 static constexpr unsigned int faces_per_cell = 0;
1256
1273 static std::array<unsigned int, 0>
1275
1283 static constexpr unsigned int max_children_per_face = 0;
1284
1290 static unsigned int
1291 n_children(const RefinementCase<0> &refinement_case);
1292
1296 static constexpr unsigned int vertices_per_cell = 1;
1297
1316 static std::array<unsigned int, vertices_per_cell>
1318
1342 static unsigned int
1343 face_to_cell_vertices(const unsigned int face,
1344 const unsigned int vertex,
1345 const bool face_orientation = true,
1346 const bool face_flip = false,
1347 const bool face_rotation = false);
1348
1363 static unsigned int
1364 face_to_cell_lines(const unsigned int face,
1365 const unsigned int line,
1366 const bool face_orientation = true,
1367 const bool face_flip = false,
1368 const bool face_rotation = false);
1369
1376 static constexpr unsigned int vertices_per_face = 0;
1377
1381 static constexpr unsigned int lines_per_face = 0;
1382
1386 static constexpr unsigned int quads_per_face = 0;
1387
1391 static constexpr unsigned int lines_per_cell = 0;
1392
1396 static constexpr unsigned int quads_per_cell = 0;
1397
1401 static constexpr unsigned int hexes_per_cell = 0;
1402
1420 static const std::array<unsigned int, vertices_per_cell> ucd_to_deal;
1421
1435 static const std::array<unsigned int, vertices_per_cell> dx_to_deal;
1436};
1437
1438
1439
1970template <int dim>
1972{
1980 static constexpr unsigned int max_children_per_cell = 1 << dim;
1981
1985 static constexpr unsigned int faces_per_cell = 2 * dim;
1986
2005
2013 static constexpr unsigned int max_children_per_face =
2015
2019 static constexpr unsigned int vertices_per_cell = 1 << dim;
2020
2038
2042 static constexpr unsigned int vertices_per_face =
2044
2048 static constexpr unsigned int lines_per_face =
2050
2054 static constexpr unsigned int quads_per_face =
2056
2066 static constexpr unsigned int lines_per_cell =
2067 (2 * GeometryInfo<dim - 1>::lines_per_cell +
2069
2077 static constexpr unsigned int quads_per_cell =
2078 (2 * GeometryInfo<dim - 1>::quads_per_cell +
2080
2084 static constexpr unsigned int hexes_per_cell =
2085 (2 * GeometryInfo<dim - 1>::hexes_per_cell +
2087
2105 static constexpr std::array<unsigned int, vertices_per_cell> ucd_to_deal =
2106 internal::GeometryInfoHelper::Initializers<dim>::ucd_to_deal();
2107
2121 static constexpr std::array<unsigned int, vertices_per_cell> dx_to_deal =
2122 internal::GeometryInfoHelper::Initializers<dim>::dx_to_deal();
2123
2136 internal::GeometryInfoHelper::Initializers<dim>::vertex_to_face();
2137
2142 static unsigned int
2143 n_children(const RefinementCase<dim> &refinement_case);
2144
2149 static unsigned int
2151
2161 static double
2163 const unsigned int subface_no);
2164
2170 static RefinementCase<dim - 1>
2171 face_refinement_case(const RefinementCase<dim> &cell_refinement_case,
2172 const unsigned int face_no,
2173 const bool face_orientation = true,
2174 const bool face_flip = false,
2175 const bool face_rotation = false);
2176
2182 static RefinementCase<dim>
2185 const unsigned int face_no,
2186 const bool face_orientation = true,
2187 const bool face_flip = false,
2188 const bool face_rotation = false);
2189
2194 static RefinementCase<1>
2195 line_refinement_case(const RefinementCase<dim> &cell_refinement_case,
2196 const unsigned int line_no);
2197
2202 static RefinementCase<dim>
2204
2251 static unsigned int
2253 const unsigned int face,
2254 const unsigned int subface,
2255 const bool face_orientation = true,
2256 const bool face_flip = false,
2257 const bool face_rotation = false,
2260
2274 static unsigned int
2275 line_to_cell_vertices(const unsigned int line, const unsigned int vertex);
2276
2297 static unsigned int
2298 face_to_cell_vertices(const unsigned int face,
2299 const unsigned int vertex,
2300 const bool face_orientation = true,
2301 const bool face_flip = false,
2302 const bool face_rotation = false);
2303
2315 static unsigned int
2316 face_to_cell_lines(const unsigned int face,
2317 const unsigned int line,
2318 const bool face_orientation = true,
2319 const bool face_flip = false,
2320 const bool face_rotation = false);
2321
2331 static unsigned int
2332 standard_to_real_face_vertex(const unsigned int vertex,
2333 const bool face_orientation = true,
2334 const bool face_flip = false,
2335 const bool face_rotation = false);
2336
2346 static unsigned int
2347 real_to_standard_face_vertex(const unsigned int vertex,
2348 const bool face_orientation = true,
2349 const bool face_flip = false,
2350 const bool face_rotation = false);
2351
2361 static unsigned int
2362 standard_to_real_face_line(const unsigned int line,
2363 const bool face_orientation = true,
2364 const bool face_flip = false,
2365 const bool face_rotation = false);
2366
2372 static unsigned int
2373 standard_to_real_line_vertex(const unsigned int vertex,
2374 const bool line_orientation = true);
2375
2383 static std::array<unsigned int, 2>
2385
2393 static std::array<unsigned int, 2>
2395
2403 static std::array<unsigned int, 2>
2405
2415 static unsigned int
2416 real_to_standard_face_line(const unsigned int line,
2417 const bool face_orientation = true,
2418 const bool face_flip = false,
2419 const bool face_rotation = false);
2420
2426 static Point<dim>
2427 unit_cell_vertex(const unsigned int vertex);
2428
2438 static unsigned int
2440
2448 static Point<dim>
2450 const unsigned int child_index,
2451 const RefinementCase<dim> refine_case =
2453
2459 static Point<dim>
2461 const unsigned int child_index,
2462 const RefinementCase<dim> refine_case =
2464
2469 static bool
2471
2483 static bool
2484 is_inside_unit_cell(const Point<dim> &p, const double eps);
2485
2490 template <typename Number = double>
2491 static Point<dim, Number>
2493
2499 static double
2501
2506 static double
2507 d_linear_shape_function(const Point<dim> &xi, const unsigned int i);
2508
2513 static Tensor<1, dim>
2514 d_linear_shape_function_gradient(const Point<dim> &xi, const unsigned int i);
2515
2567 template <int spacedim>
2568 static void
2570#ifndef DEAL_II_CXX14_CONSTEXPR_BUG
2571 (const Point<spacedim> (&vertices)[vertices_per_cell],
2572 Tensor<spacedim - dim, spacedim> (&forms)[vertices_per_cell]);
2573#else
2574 (const Point<spacedim> *vertices, Tensor<spacedim - dim, spacedim> *forms);
2575#endif
2576
2586 static constexpr std::array<unsigned int, faces_per_cell>
2588 internal::GeometryInfoHelper::Initializers<dim>::unit_normal_direction();
2589
2606 static constexpr std::array<int, faces_per_cell> unit_normal_orientation =
2607 internal::GeometryInfoHelper::Initializers<dim>::unit_normal_orientation();
2608
2619 static constexpr std::array<Tensor<1, dim>, faces_per_cell>
2621 internal::GeometryInfoHelper::Initializers<dim>::unit_normal_vector();
2622
2636 static constexpr ndarray<Tensor<1, dim>, faces_per_cell, dim - 1>
2637 unit_tangential_vectors = internal::GeometryInfoHelper::Initializers<
2639
2645 static constexpr std::array<unsigned int, faces_per_cell> opposite_face =
2646 internal::GeometryInfoHelper::Initializers<dim>::opposite_face();
2647
2648
2653 double,
2654 << "The coordinates must satisfy 0 <= x_i <= 1, "
2655 << "but here we have x_i=" << arg1);
2656
2661 int,
2662 int,
2663 int,
2664 << "RefinementCase<dim> " << arg1 << ": face " << arg2
2665 << " has no subface " << arg3);
2666};
2667
2668
2669
2670#ifndef DOXYGEN
2671
2672
2673/* -------------- declaration of explicit specializations ------------- */
2674
2675
2676template <>
2679 const unsigned int i);
2680template <>
2683 const unsigned int i);
2684template <>
2687 const unsigned int i);
2688
2689
2690
2691/* -------------- inline functions ------------- */
2692
2693
2694inline GeometryPrimitive::GeometryPrimitive(const Object object)
2695 : object(object)
2696{}
2697
2698
2699
2700inline GeometryPrimitive::GeometryPrimitive(const unsigned int object_dimension)
2701 : object(static_cast<Object>(object_dimension))
2702{}
2703
2704
2705inline GeometryPrimitive::
2706operator unsigned int() const
2707{
2708 return static_cast<unsigned int>(object);
2709}
2710
2711
2712
2713namespace internal
2714{
2715 template <int dim>
2717 const typename SubfacePossibilities<dim>::Possibilities subface_possibility)
2718 : value(subface_possibility)
2719 {}
2720
2721
2722 template <int dim>
2723 inline SubfaceCase<dim>::
2724 operator std::uint8_t() const
2725 {
2726 return value;
2727 }
2728
2729
2730} // namespace internal
2731
2732
2733template <int dim>
2734inline constexpr RefinementCase<dim>
2735RefinementCase<dim>::cut_axis(const unsigned int)
2736{
2738 return static_cast<std::uint8_t>(-1);
2739}
2740
2741
2742template <>
2743inline constexpr RefinementCase<1>
2744RefinementCase<1>::cut_axis(const unsigned int i)
2745{
2746 AssertIndexRange(i, 1);
2747
2749 return options[i];
2750}
2751
2752
2753
2754template <>
2755inline constexpr RefinementCase<2>
2756RefinementCase<2>::cut_axis(const unsigned int i)
2757{
2758 AssertIndexRange(i, 2);
2759
2762 return options[i];
2763}
2764
2765
2766
2767template <>
2768inline constexpr RefinementCase<3>
2769RefinementCase<3>::cut_axis(const unsigned int i)
2770{
2771 AssertIndexRange(i, 3);
2772
2776 return options[i];
2777}
2778
2779
2780
2781template <>
2782inline constexpr std::array<RefinementCase<1>, 2>
2784{
2787}
2788
2789
2790
2791template <>
2792inline constexpr std::array<RefinementCase<2>, 4>
2794{
2799}
2800
2801
2802
2803template <>
2804inline constexpr std::array<RefinementCase<3>, 8>
2806{
2815}
2816
2817
2818
2819template <int dim>
2820inline constexpr RefinementCase<dim>::RefinementCase()
2821 : value(RefinementPossibilities<dim>::no_refinement)
2822{}
2823
2824
2825
2826template <int dim>
2828 const typename RefinementPossibilities<dim>::Possibilities refinement_case)
2829 : value(refinement_case)
2830{
2831 // check that only those bits of
2832 // the given argument are set that
2833 // make sense for a given space
2834 // dimension
2835 Assert((refinement_case &
2837 refinement_case,
2838 ExcInvalidRefinementCase(refinement_case));
2839}
2840
2841
2842
2843template <int dim>
2845 const std::uint8_t refinement_case)
2846 : value(refinement_case)
2847{
2848 // check that only those bits of
2849 // the given argument are set that
2850 // make sense for a given space
2851 // dimension
2852 Assert((refinement_case &
2854 refinement_case,
2855 ExcInvalidRefinementCase(refinement_case));
2856}
2857
2858
2859
2860template <int dim>
2862operator std::uint8_t() const
2863{
2864 return value;
2865}
2866
2867
2868
2869template <int dim>
2870inline constexpr RefinementCase<dim>
2872{
2873 return RefinementCase<dim>(static_cast<std::uint8_t>(value | r.value));
2874}
2875
2876
2877
2878template <int dim>
2879inline constexpr RefinementCase<dim>
2881{
2882 return RefinementCase<dim>(static_cast<std::uint8_t>(value & r.value));
2883}
2884
2885
2886
2887template <int dim>
2888inline constexpr RefinementCase<dim>
2890{
2891 return RefinementCase<dim>(static_cast<std::uint8_t>(
2893}
2894
2895
2896
2897template <int dim>
2898inline constexpr std::size_t
2900{
2901 return sizeof(RefinementCase<dim>);
2902}
2903
2904
2905
2906template <int dim>
2907template <class Archive>
2908inline void
2909RefinementCase<dim>::serialize(Archive &ar, const unsigned int)
2910{
2911 // serialization can't deal with bitfields, so copy from/to a full sized
2912 // std::uint8_t
2913 std::uint8_t uchar_value = value;
2914 ar & uchar_value;
2915 value = uchar_value;
2916}
2917
2918
2919
2920template <>
2921inline Point<1>
2922GeometryInfo<1>::unit_cell_vertex(const unsigned int vertex)
2923{
2924 AssertIndexRange(vertex, vertices_per_cell);
2925
2926 return Point<1>(static_cast<double>(vertex));
2927}
2928
2929
2930
2931template <>
2932inline Point<2>
2933GeometryInfo<2>::unit_cell_vertex(const unsigned int vertex)
2934{
2935 AssertIndexRange(vertex, vertices_per_cell);
2936
2937 return {static_cast<double>(vertex % 2), static_cast<double>(vertex / 2)};
2938}
2939
2940
2941
2942template <>
2943inline Point<3>
2944GeometryInfo<3>::unit_cell_vertex(const unsigned int vertex)
2945{
2946 AssertIndexRange(vertex, vertices_per_cell);
2947
2948 return {static_cast<double>(vertex % 2),
2949 static_cast<double>(vertex / 2 % 2),
2950 static_cast<double>(vertex / 4)};
2951}
2952
2953
2954
2955inline std::array<unsigned int, 0>
2957{
2958 return {{}};
2959}
2960
2961
2962
2963inline std::array<unsigned int, 1>
2965{
2966 return {{0}};
2967}
2968
2969
2970
2971template <int dim>
2974{
2976 0U, faces_per_cell);
2977}
2978
2979
2980
2981template <int dim>
2984{
2986 0U, vertices_per_cell);
2987}
2988
2989
2990
2991template <int dim>
2992inline Point<dim>
2993GeometryInfo<dim>::unit_cell_vertex(const unsigned int)
2994{
2996
2997 return {};
2998}
2999
3000
3001
3002template <>
3003inline unsigned int
3005{
3006 Assert((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
3007
3008 return (p[0] <= 0.5 ? 0 : 1);
3009}
3010
3011
3012
3013template <>
3014inline unsigned int
3016{
3017 Assert((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
3018 Assert((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1]));
3019
3020 return (p[0] <= 0.5 ? (p[1] <= 0.5 ? 0 : 2) : (p[1] <= 0.5 ? 1 : 3));
3021}
3022
3023
3024
3025template <>
3026inline unsigned int
3028{
3029 Assert((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
3030 Assert((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1]));
3031 Assert((p[2] >= 0) && (p[2] <= 1), ExcInvalidCoordinate(p[2]));
3032
3033 return (p[0] <= 0.5 ?
3034 (p[1] <= 0.5 ? (p[2] <= 0.5 ? 0 : 4) : (p[2] <= 0.5 ? 2 : 6)) :
3035 (p[1] <= 0.5 ? (p[2] <= 0.5 ? 1 : 5) : (p[2] <= 0.5 ? 3 : 7)));
3036}
3037
3038
3039template <int dim>
3040inline unsigned int
3042{
3044
3045 return 0;
3046}
3047
3048
3049
3050template <>
3051inline Point<1>
3053 const unsigned int child_index,
3054 const RefinementCase<1> refine_case)
3055
3056{
3057 AssertIndexRange(child_index, 2);
3059 (void)refine_case; // removes -Wunused-parameter warning in optimized mode
3060
3061 return Point<1>(p * 2.0 - unit_cell_vertex(child_index));
3062}
3063
3064
3065
3066template <>
3067inline Point<2>
3069 const unsigned int child_index,
3070 const RefinementCase<2> refine_case)
3071
3072{
3073 AssertIndexRange(child_index, GeometryInfo<2>::n_children(refine_case));
3074
3075 Point<2> point = p;
3076 switch (refine_case)
3077 {
3079 point[0] *= 2.0;
3080 if (child_index == 1)
3081 point[0] -= 1.0;
3082 break;
3084 point[1] *= 2.0;
3085 if (child_index == 1)
3086 point[1] -= 1.0;
3087 break;
3089 point *= 2.0;
3090 point -= unit_cell_vertex(child_index);
3091 break;
3092 default:
3094 }
3095
3096 return point;
3097}
3098
3099
3100
3101template <>
3102inline Point<3>
3104 const unsigned int child_index,
3105 const RefinementCase<3> refine_case)
3106
3107{
3108 AssertIndexRange(child_index, GeometryInfo<3>::n_children(refine_case));
3109
3110 Point<3> point = p;
3111 // there might be a cleverer way to do
3112 // this, but since this function is called
3113 // in very few places for initialization
3114 // purposes only, I don't care at the
3115 // moment
3116 switch (refine_case)
3117 {
3119 point[0] *= 2.0;
3120 if (child_index == 1)
3121 point[0] -= 1.0;
3122 break;
3124 point[1] *= 2.0;
3125 if (child_index == 1)
3126 point[1] -= 1.0;
3127 break;
3129 point[2] *= 2.0;
3130 if (child_index == 1)
3131 point[2] -= 1.0;
3132 break;
3134 point[0] *= 2.0;
3135 point[1] *= 2.0;
3136 if (child_index % 2 == 1)
3137 point[0] -= 1.0;
3138 if (child_index / 2 == 1)
3139 point[1] -= 1.0;
3140 break;
3142 // careful, this is slightly
3143 // different from xy and yz due to
3144 // different internal numbering of
3145 // children!
3146 point[0] *= 2.0;
3147 point[2] *= 2.0;
3148 if (child_index / 2 == 1)
3149 point[0] -= 1.0;
3150 if (child_index % 2 == 1)
3151 point[2] -= 1.0;
3152 break;
3154 point[1] *= 2.0;
3155 point[2] *= 2.0;
3156 if (child_index % 2 == 1)
3157 point[1] -= 1.0;
3158 if (child_index / 2 == 1)
3159 point[2] -= 1.0;
3160 break;
3162 point *= 2.0;
3163 point -= unit_cell_vertex(child_index);
3164 break;
3165 default:
3167 }
3168
3169 return point;
3170}
3171
3172
3173
3174template <int dim>
3175inline Point<dim>
3177 const Point<dim> & /*p*/,
3178 const unsigned int /*child_index*/,
3179 const RefinementCase<dim> /*refine_case*/)
3180
3181{
3183 return {};
3184}
3185
3186
3187
3188template <>
3189inline Point<1>
3191 const unsigned int child_index,
3192 const RefinementCase<1> refine_case)
3193
3194{
3195 AssertIndexRange(child_index, 2);
3197 (void)refine_case; // removes -Wunused-parameter warning in optimized mode
3198
3199 return (p + unit_cell_vertex(child_index)) * 0.5;
3200}
3201
3202
3203
3204template <>
3205inline Point<3>
3207 const unsigned int child_index,
3208 const RefinementCase<3> refine_case)
3209
3210{
3211 AssertIndexRange(child_index, GeometryInfo<3>::n_children(refine_case));
3212
3213 Point<3> point = p;
3214 // there might be a cleverer way to do
3215 // this, but since this function is called
3216 // in very few places for initialization
3217 // purposes only, I don't care at the
3218 // moment
3219 switch (refine_case)
3220 {
3222 if (child_index == 1)
3223 point[0] += 1.0;
3224 point[0] *= 0.5;
3225 break;
3227 if (child_index == 1)
3228 point[1] += 1.0;
3229 point[1] *= 0.5;
3230 break;
3232 if (child_index == 1)
3233 point[2] += 1.0;
3234 point[2] *= 0.5;
3235 break;
3237 if (child_index % 2 == 1)
3238 point[0] += 1.0;
3239 if (child_index / 2 == 1)
3240 point[1] += 1.0;
3241 point[0] *= 0.5;
3242 point[1] *= 0.5;
3243 break;
3245 // careful, this is slightly
3246 // different from xy and yz due to
3247 // different internal numbering of
3248 // children!
3249 if (child_index / 2 == 1)
3250 point[0] += 1.0;
3251 if (child_index % 2 == 1)
3252 point[2] += 1.0;
3253 point[0] *= 0.5;
3254 point[2] *= 0.5;
3255 break;
3257 if (child_index % 2 == 1)
3258 point[1] += 1.0;
3259 if (child_index / 2 == 1)
3260 point[2] += 1.0;
3261 point[1] *= 0.5;
3262 point[2] *= 0.5;
3263 break;
3265 point += unit_cell_vertex(child_index);
3266 point *= 0.5;
3267 break;
3268 default:
3270 }
3271
3272 return point;
3273}
3274
3275
3276
3277template <>
3278inline Point<2>
3280 const unsigned int child_index,
3281 const RefinementCase<2> refine_case)
3282{
3283 AssertIndexRange(child_index, GeometryInfo<2>::n_children(refine_case));
3284
3285 Point<2> point = p;
3286 switch (refine_case)
3287 {
3289 if (child_index == 1)
3290 point[0] += 1.0;
3291 point[0] *= 0.5;
3292 break;
3294 if (child_index == 1)
3295 point[1] += 1.0;
3296 point[1] *= 0.5;
3297 break;
3299 point += unit_cell_vertex(child_index);
3300 point *= 0.5;
3301 break;
3302 default:
3304 }
3305
3306 return point;
3307}
3308
3309
3310
3311template <int dim>
3312inline Point<dim>
3314 const Point<dim> & /*p*/,
3315 const unsigned int /*child_index*/,
3316 const RefinementCase<dim> /*refine_case*/)
3317{
3319 return {};
3320}
3321
3322
3323
3324template <int dim>
3325inline bool
3327{
3329 return false;
3330}
3331
3332template <>
3333inline bool
3335{
3336 return (p[0] >= 0.) && (p[0] <= 1.);
3337}
3338
3339
3340
3341template <>
3342inline bool
3344{
3345 return (p[0] >= 0.) && (p[0] <= 1.) && (p[1] >= 0.) && (p[1] <= 1.);
3346}
3347
3348
3349
3350template <>
3351inline bool
3353{
3354 return (p[0] >= 0.) && (p[0] <= 1.) && (p[1] >= 0.) && (p[1] <= 1.) &&
3355 (p[2] >= 0.) && (p[2] <= 1.);
3356}
3357
3358
3359
3360template <int dim>
3361inline bool
3363{
3365 return false;
3366}
3367
3368template <>
3369inline bool
3370GeometryInfo<1>::is_inside_unit_cell(const Point<1> &p, const double eps)
3371{
3372 return (p[0] >= -eps) && (p[0] <= 1. + eps);
3373}
3374
3375
3376
3377template <>
3378inline bool
3379GeometryInfo<2>::is_inside_unit_cell(const Point<2> &p, const double eps)
3380{
3381 const double l = -eps, u = 1 + eps;
3382 return (p[0] >= l) && (p[0] <= u) && (p[1] >= l) && (p[1] <= u);
3383}
3384
3385
3386
3387template <>
3388inline bool
3389GeometryInfo<3>::is_inside_unit_cell(const Point<3> &p, const double eps)
3390{
3391 const double l = -eps, u = 1.0 + eps;
3392 return (p[0] >= l) && (p[0] <= u) && (p[1] >= l) && (p[1] <= u) &&
3393 (p[2] >= l) && (p[2] <= u);
3394}
3395
3396
3397
3398template <>
3399inline unsigned int
3400GeometryInfo<1>::line_to_cell_vertices(const unsigned int line,
3401 const unsigned int vertex)
3402{
3403 (void)line;
3404 AssertIndexRange(line, lines_per_cell);
3405 AssertIndexRange(vertex, 2);
3406
3407 return vertex;
3408}
3409
3410
3411template <>
3412inline unsigned int
3413GeometryInfo<2>::line_to_cell_vertices(const unsigned int line,
3414 const unsigned int vertex)
3415{
3416 constexpr unsigned int cell_vertices[4][2] = {{0, 2}, {1, 3}, {0, 1}, {2, 3}};
3417 return cell_vertices[line][vertex];
3418}
3419
3420
3421
3422template <>
3423inline unsigned int
3424GeometryInfo<3>::line_to_cell_vertices(const unsigned int line,
3425 const unsigned int vertex)
3426{
3427 AssertIndexRange(line, lines_per_cell);
3428 AssertIndexRange(vertex, 2);
3429
3430 constexpr unsigned vertices[lines_per_cell][2] = {{0, 2}, // bottom face
3431 {1, 3},
3432 {0, 1},
3433 {2, 3},
3434 {4, 6}, // top face
3435 {5, 7},
3436 {4, 5},
3437 {6, 7},
3438 {0,
3439 4}, // connects of bottom
3440 {1, 5}, // top face
3441 {2, 6},
3442 {3, 7}};
3443 return vertices[line][vertex];
3444}
3445
3446
3447template <>
3448inline unsigned int
3449GeometryInfo<4>::line_to_cell_vertices(const unsigned int, const unsigned int)
3450{
3453}
3454
3455template <>
3456inline unsigned int
3457GeometryInfo<3>::standard_to_real_face_vertex(const unsigned int vertex,
3458 const bool face_orientation,
3459 const bool face_flip,
3460 const bool face_rotation)
3461{
3463
3464 // set up a table to make sure that
3465 // we handle non-standard faces correctly
3466 //
3467 // so set up a table that for each vertex (of
3468 // a quad in standard position) describes
3469 // which vertex to take
3470 //
3471 // first index: four vertices 0...3
3472 //
3473 // second index: face_orientation; 0:
3474 // opposite normal, 1: standard
3475 //
3476 // third index: face_flip; 0: standard, 1:
3477 // face rotated by 180 degrees
3478 //
3479 // forth index: face_rotation: 0: standard,
3480 // 1: face rotated by 90 degrees
3481
3482 constexpr unsigned int vertex_translation[4][2][2][2] = {
3483 {{{0, 2}, // vertex 0, face_orientation=false, face_flip=false,
3484 // face_rotation=false and true
3485 {3, 1}}, // vertex 0, face_orientation=false, face_flip=true,
3486 // face_rotation=false and true
3487 {{0, 2}, // vertex 0, face_orientation=true, face_flip=false,
3488 // face_rotation=false and true
3489 {3, 1}}}, // vertex 0, face_orientation=true, face_flip=true,
3490 // face_rotation=false and true
3491
3492 {{{2, 3}, // vertex 1 ...
3493 {1, 0}},
3494 {{1, 0}, {2, 3}}},
3495
3496 {{{1, 0}, // vertex 2 ...
3497 {2, 3}},
3498 {{2, 3}, {1, 0}}},
3499
3500 {{{3, 1}, // vertex 3 ...
3501 {0, 2}},
3502 {{3, 1}, {0, 2}}}};
3503
3504 return vertex_translation[vertex][face_orientation][face_flip][face_rotation];
3505}
3506
3507
3508
3509template <int dim>
3510inline unsigned int
3511GeometryInfo<dim>::standard_to_real_face_vertex(const unsigned int vertex,
3512 const bool,
3513 const bool,
3514 const bool)
3515{
3516 Assert(dim > 1, ExcImpossibleInDim(dim));
3518 return vertex;
3519}
3520
3521template <int dim>
3522inline unsigned int
3524{
3525 constexpr unsigned int n_children[RefinementCase<3>::cut_xyz + 1] = {
3526 0, 2, 2, 4, 2, 4, 4, 8};
3527
3528 return n_children[ref_case];
3529}
3530
3531
3532
3533template <int dim>
3534inline unsigned int
3536{
3538 return 0;
3539}
3540
3541template <>
3542inline unsigned int
3544{
3545 Assert(false, ExcImpossibleInDim(1));
3546 return 0;
3547}
3548
3549template <>
3550inline unsigned int
3552{
3553 return (subface_case == internal::SubfaceCase<2>::case_x) ? 2 : 0;
3554}
3555
3556
3557
3558template <>
3559inline unsigned int
3561{
3562 const unsigned int nsubs[internal::SubfaceCase<3>::case_isotropic + 1] = {
3563 0, 2, 3, 3, 4, 2, 3, 3, 4, 4};
3564 return nsubs[subface_case];
3565}
3566
3567
3568
3569template <int dim>
3570inline double
3572 const unsigned int)
3573{
3575 return 0.;
3576}
3577
3578template <>
3579inline double
3581 const unsigned int)
3582{
3583 return 1;
3584}
3585
3586
3587template <>
3588inline double
3590 const unsigned int)
3591{
3592 double ratio = 1;
3593 switch (subface_case)
3594 {
3596 // Here, an
3597 // Assert(false,ExcInternalError())
3598 // would be the right
3599 // choice, but
3600 // unfortunately the
3601 // current function is
3602 // also called for faces
3603 // without children (see
3604 // tests/fe/mapping.cc).
3605 // Assert(false, ExcMessage("Face has no subfaces."));
3606 // Furthermore, assign
3607 // following value as
3608 // otherwise the
3609 // bits/volume_x tests
3610 // break
3612 break;
3614 ratio = 0.5;
3615 break;
3616 default:
3617 // there should be no
3618 // cases left
3620 break;
3621 }
3622
3623 return ratio;
3624}
3625
3626
3627template <>
3628inline double
3630 const unsigned int subface_no)
3631{
3632 double ratio = 1;
3633 switch (subface_case)
3634 {
3636 // Here, an
3637 // Assert(false,ExcInternalError())
3638 // would be the right
3639 // choice, but
3640 // unfortunately the
3641 // current function is
3642 // also called for faces
3643 // without children (see
3644 // tests/bits/mesh_3d_16.cc). Add
3645 // following switch to
3646 // avoid diffs in
3647 // tests/bits/mesh_3d_16
3649 break;
3652 ratio = 0.5;
3653 break;
3657 ratio = 0.25;
3658 break;
3661 if (subface_no < 2)
3662 ratio = 0.25;
3663 else
3664 ratio = 0.5;
3665 break;
3668 if (subface_no == 0)
3669 ratio = 0.5;
3670 else
3671 ratio = 0.25;
3672 break;
3673 default:
3674 // there should be no
3675 // cases left
3677 break;
3678 }
3679
3680 return ratio;
3681}
3682
3683
3684
3685template <int dim>
3687 const RefinementCase<dim> &,
3688 const unsigned int,
3689 const bool,
3690 const bool,
3691 const bool)
3692{
3694 return RefinementCase<dim - 1>::no_refinement;
3695}
3696
3697template <>
3699 const RefinementCase<1> &,
3700 const unsigned int,
3701 const bool,
3702 const bool,
3703 const bool)
3704{
3705 Assert(false, ExcImpossibleInDim(1));
3706
3708}
3709
3710
3711template <>
3712inline RefinementCase<1>
3714 const RefinementCase<2> &cell_refinement_case,
3715 const unsigned int face_no,
3716 const bool,
3717 const bool,
3718 const bool)
3719{
3720 const unsigned int dim = 2;
3721 AssertIndexRange(cell_refinement_case,
3724
3725 // simple special case
3726 if (cell_refinement_case == RefinementCase<dim>::cut_xy)
3728
3729 const RefinementCase<dim - 1>
3732 {RefinementCase<dim - 1>::no_refinement, // no_refinement
3733 RefinementCase<dim - 1>::no_refinement},
3734
3735 {RefinementCase<dim - 1>::no_refinement, RefinementCase<dim - 1>::cut_x},
3736
3737 {RefinementCase<dim - 1>::cut_x, RefinementCase<dim - 1>::no_refinement},
3738
3739 {RefinementCase<dim - 1>::cut_x, // cut_xy
3740 RefinementCase<dim - 1>::cut_x}};
3741
3742 return ref_cases[cell_refinement_case][face_no / 2];
3743}
3744
3745
3746template <>
3747inline RefinementCase<2>
3749 const RefinementCase<3> &cell_refinement_case,
3750 const unsigned int face_no,
3751 const bool face_orientation,
3752 const bool /*face_flip*/,
3753 const bool face_rotation)
3754{
3755 const unsigned int dim = 3;
3756 AssertIndexRange(cell_refinement_case,
3759
3760 // simple special case
3761 if (cell_refinement_case == RefinementCase<dim>::cut_xyz)
3762 return RefinementCase<dim - 1>::cut_xy;
3763
3764 const RefinementCase<dim - 1>
3767 {RefinementCase<dim - 1>::no_refinement, // no_refinement
3768 RefinementCase<dim - 1>::no_refinement,
3769 RefinementCase<dim - 1>::no_refinement},
3770
3771 {RefinementCase<dim - 1>::no_refinement, // cut_x
3772 RefinementCase<dim - 1>::cut_y,
3773 RefinementCase<dim - 1>::cut_x},
3774
3775 {RefinementCase<dim - 1>::cut_x, // cut_y
3776 RefinementCase<dim - 1>::no_refinement,
3777 RefinementCase<dim - 1>::cut_y},
3778
3779 {RefinementCase<dim - 1>::cut_x, // cut_xy
3780 RefinementCase<dim - 1>::cut_y,
3781 RefinementCase<dim - 1>::cut_xy},
3782
3783 {RefinementCase<dim - 1>::cut_y, // cut_z
3784 RefinementCase<dim - 1>::cut_x,
3785 RefinementCase<dim - 1>::no_refinement},
3786
3787 {RefinementCase<dim - 1>::cut_y, // cut_xz
3788 RefinementCase<dim - 1>::cut_xy,
3789 RefinementCase<dim - 1>::cut_x},
3790
3791 {RefinementCase<dim - 1>::cut_xy, // cut_yz
3792 RefinementCase<dim - 1>::cut_x,
3793 RefinementCase<dim - 1>::cut_y},
3794
3795 {RefinementCase<dim - 1>::cut_xy, // cut_xyz
3796 RefinementCase<dim - 1>::cut_xy,
3797 RefinementCase<dim - 1>::cut_xy},
3798 };
3799
3800 const RefinementCase<dim - 1> ref_case =
3801 ref_cases[cell_refinement_case][face_no / 2];
3802
3803 const RefinementCase<dim - 1> flip[4] = {
3804 RefinementCase<dim - 1>::no_refinement,
3805 RefinementCase<dim - 1>::cut_y,
3806 RefinementCase<dim - 1>::cut_x,
3807 RefinementCase<dim - 1>::cut_xy};
3808
3809 // correct the ref_case for face_orientation
3810 // and face_rotation. for face_orientation,
3811 // 'true' is the default value whereas for
3812 // face_rotation, 'false' is standard. If
3813 // <tt>face_rotation==face_orientation</tt>,
3814 // then one of them is non-standard and we
3815 // have to swap cut_x and cut_y, otherwise no
3816 // change is necessary. face_flip has no
3817 // influence. however, in order to keep the
3818 // interface consistent with other functions,
3819 // we still include it as an argument to this
3820 // function
3821 return (face_orientation == face_rotation) ? flip[ref_case] : ref_case;
3822}
3823
3824
3825
3826template <int dim>
3827inline RefinementCase<1>
3829 const unsigned int)
3830{
3833}
3834
3835template <>
3836inline RefinementCase<1>
3838 const RefinementCase<1> &cell_refinement_case,
3839 const unsigned int line_no)
3840{
3841 (void)line_no;
3842 const unsigned int dim = 1;
3843 (void)dim;
3844 AssertIndexRange(cell_refinement_case,
3847
3848 return cell_refinement_case;
3849}
3850
3851
3852template <>
3853inline RefinementCase<1>
3855 const RefinementCase<2> &cell_refinement_case,
3856 const unsigned int line_no)
3857{
3858 // Assertions are in face_refinement_case()
3859 return face_refinement_case(cell_refinement_case, line_no);
3860}
3861
3862
3863template <>
3864inline RefinementCase<1>
3866 const RefinementCase<3> &cell_refinement_case,
3867 const unsigned int line_no)
3868{
3869 const unsigned int dim = 3;
3870 AssertIndexRange(cell_refinement_case,
3873
3874 // simple special case
3875 if (cell_refinement_case == RefinementCase<dim>::cut_xyz)
3877
3878 // array indicating, which simple refine
3879 // case cuts a line in direction x, y or
3880 // z. For example, cut_y and everything
3881 // containing cut_y (cut_xy, cut_yz,
3882 // cut_xyz) cuts lines, which are in y
3883 // direction.
3884 const RefinementCase<dim> cut_one[dim] = {RefinementCase<dim>::cut_x,
3887
3888 // order the direction of lines
3889 // 0->x, 1->y, 2->z
3890 const unsigned int direction[lines_per_cell] = {
3891 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 2, 2};
3892
3893 return ((cell_refinement_case & cut_one[direction[line_no]]) ?
3895 RefinementCase<1>::no_refinement);
3896}
3897
3898
3899
3900template <int dim>
3904 const unsigned int,
3905 const bool,
3906 const bool,
3907 const bool)
3908{
3910
3912}
3913
3914template <>
3915inline RefinementCase<1>
3917 const RefinementCase<0> &,
3918 const unsigned int,
3919 const bool,
3920 const bool,
3921 const bool)
3922{
3923 const unsigned int dim = 1;
3924 Assert(false, ExcImpossibleInDim(dim));
3925
3927}
3928
3929
3930template <>
3931inline RefinementCase<2>
3933 const RefinementCase<1> &face_refinement_case,
3934 const unsigned int face_no,
3935 const bool,
3936 const bool,
3937 const bool)
3938{
3939 const unsigned int dim = 2;
3940 AssertIndexRange(face_refinement_case,
3943
3944 if (face_refinement_case == RefinementCase<dim>::cut_x)
3945 return (face_no / 2) != 0u ? RefinementCase<dim>::cut_x :
3947 else
3949}
3950
3951
3952template <>
3953inline RefinementCase<3>
3955 const RefinementCase<2> &face_refinement_case,
3956 const unsigned int face_no,
3957 const bool face_orientation,
3958 const bool /*face_flip*/,
3959 const bool face_rotation)
3960{
3961 const unsigned int dim = 3;
3962 AssertIndexRange(face_refinement_case,
3965
3970
3971 // correct the face_refinement_case for
3972 // face_orientation and face_rotation. for
3973 // face_orientation, 'true' is the default
3974 // value whereas for face_rotation, 'false'
3975 // is standard. If
3976 // <tt>face_rotation==face_orientation</tt>,
3977 // then one of them is non-standard and we
3978 // have to swap cut_x and cut_y, otherwise no
3979 // change is necessary. face_flip has no
3980 // influence. however, in order to keep the
3981 // interface consistent with other functions,
3982 // we still include it as an argument to this
3983 // function
3984 const RefinementCase<dim - 1> std_face_ref =
3985 (face_orientation == face_rotation) ? flip[face_refinement_case] :
3986 face_refinement_case;
3987
3988 const RefinementCase<dim> face_to_cell[3][4] = {
3989 {RefinementCase<dim>::no_refinement, // faces 0 and 1
3990 RefinementCase<dim>::cut_y, // cut_x in face 0 means cut_y for the cell
3993
3994 {RefinementCase<dim>::no_refinement, // faces 2 and 3 (note that x and y are
3995 // "exchanged on faces 2 and 3")
3999
4000 {RefinementCase<dim>::no_refinement, // faces 4 and 5
4004
4005 return face_to_cell[face_no / 2][std_face_ref];
4006}
4007
4008
4009
4010template <int dim>
4013 const unsigned int)
4014{
4016
4018}
4019
4020template <>
4021inline RefinementCase<1>
4023 const unsigned int line_no)
4024{
4025 (void)line_no;
4026 AssertIndexRange(line_no, 1);
4027
4029}
4030
4031
4032template <>
4033inline RefinementCase<2>
4035 const unsigned int line_no)
4036{
4037 const unsigned int dim = 2;
4038 (void)dim;
4040
4041 return (line_no / 2) != 0u ? RefinementCase<2>::cut_x :
4043}
4044
4045
4046template <>
4047inline RefinementCase<3>
4049 const unsigned int line_no)
4050{
4051 const unsigned int dim = 3;
4053
4054 const RefinementCase<dim> ref_cases[6] = {
4055 RefinementCase<dim>::cut_y, // lines 0 and 1
4056 RefinementCase<dim>::cut_x, // lines 2 and 3
4057 RefinementCase<dim>::cut_y, // lines 4 and 5
4058 RefinementCase<dim>::cut_x, // lines 6 and 7
4059 RefinementCase<dim>::cut_z, // lines 8 and 9
4060 RefinementCase<dim>::cut_z}; // lines 10 and 11
4061
4062 return ref_cases[line_no / 2];
4063}
4064
4065
4066
4067template <>
4068inline unsigned int
4069GeometryInfo<3>::real_to_standard_face_vertex(const unsigned int vertex,
4070 const bool face_orientation,
4071 const bool face_flip,
4072 const bool face_rotation)
4073{
4075
4076 // set up a table to make sure that
4077 // we handle non-standard faces correctly
4078 //
4079 // so set up a table that for each vertex (of
4080 // a quad in standard position) describes
4081 // which vertex to take
4082 //
4083 // first index: four vertices 0...3
4084 //
4085 // second index: face_orientation; 0:
4086 // opposite normal, 1: standard
4087 //
4088 // third index: face_flip; 0: standard, 1:
4089 // face rotated by 180 degrees
4090 //
4091 // forth index: face_rotation: 0: standard,
4092 // 1: face rotated by 90 degrees
4093
4094 const unsigned int vertex_translation[4][2][2][2] = {
4095 {{{0, 2}, // vertex 0, face_orientation=false, face_flip=false,
4096 // face_rotation=false and true
4097 {3, 1}}, // vertex 0, face_orientation=false, face_flip=true,
4098 // face_rotation=false and true
4099 {{0, 1}, // vertex 0, face_orientation=true, face_flip=false,
4100 // face_rotation=false and true
4101 {3, 2}}}, // vertex 0, face_orientation=true, face_flip=true,
4102 // face_rotation=false and true
4103
4104 {{{2, 3}, // vertex 1 ...
4105 {1, 0}},
4106 {{1, 3}, {2, 0}}},
4107
4108 {{{1, 0}, // vertex 2 ...
4109 {2, 3}},
4110 {{2, 0}, {1, 3}}},
4111
4112 {{{3, 1}, // vertex 3 ...
4113 {0, 2}},
4114 {{3, 2}, {0, 1}}}};
4115
4116 return vertex_translation[vertex][face_orientation][face_flip][face_rotation];
4117}
4118
4119
4120
4121template <int dim>
4122inline unsigned int
4123GeometryInfo<dim>::real_to_standard_face_vertex(const unsigned int vertex,
4124 const bool,
4125 const bool,
4126 const bool)
4127{
4128 Assert(dim > 1, ExcImpossibleInDim(dim));
4130 return vertex;
4131}
4132
4133
4134
4135template <>
4136inline unsigned int
4137GeometryInfo<3>::standard_to_real_face_line(const unsigned int line,
4138 const bool face_orientation,
4139 const bool face_flip,
4140 const bool face_rotation)
4141{
4143
4144
4145 // make sure we handle
4146 // non-standard faces correctly
4147 //
4148 // so set up a table that for each line (of a
4149 // quad) describes which line to take
4150 //
4151 // first index: four lines 0...3
4152 //
4153 // second index: face_orientation; 0:
4154 // opposite normal, 1: standard
4155 //
4156 // third index: face_flip; 0: standard, 1:
4157 // face rotated by 180 degrees
4158 //
4159 // forth index: face_rotation: 0: standard,
4160 // 1: face rotated by 90 degrees
4161
4162 const unsigned int line_translation[4][2][2][2] = {
4163 {{{2, 0}, // line 0, face_orientation=false, face_flip=false,
4164 // face_rotation=false and true
4165 {3, 1}}, // line 0, face_orientation=false, face_flip=true,
4166 // face_rotation=false and true
4167 {{0, 3}, // line 0, face_orientation=true, face_flip=false,
4168 // face_rotation=false and true
4169 {1, 2}}}, // line 0, face_orientation=true, face_flip=true,
4170 // face_rotation=false and true
4171
4172 {{{3, 1}, // line 1 ...
4173 {2, 0}},
4174 {{1, 2}, {0, 3}}},
4175
4176 {{{0, 3}, // line 2 ...
4177 {1, 2}},
4178 {{2, 0}, {3, 1}}},
4179
4180 {{{1, 2}, // line 3 ...
4181 {0, 3}},
4182 {{3, 1}, {2, 0}}}};
4183
4184 return line_translation[line][face_orientation][face_flip][face_rotation];
4185}
4186
4187
4188
4189template <int dim>
4190inline unsigned int
4191GeometryInfo<dim>::standard_to_real_face_line(const unsigned int line,
4192 const bool,
4193 const bool,
4194 const bool)
4195{
4197 return line;
4198}
4199
4200
4201
4202template <>
4203inline unsigned int
4204GeometryInfo<2>::standard_to_real_line_vertex(const unsigned int vertex,
4205 const bool line_orientation)
4206{
4207 return line_orientation ? vertex : (1 - vertex);
4208}
4209
4210
4211
4212template <int dim>
4213inline unsigned int
4214GeometryInfo<dim>::standard_to_real_line_vertex(const unsigned int vertex,
4215 const bool)
4216{
4218 return vertex;
4219}
4220
4221
4222
4223template <>
4224inline std::array<unsigned int, 2>
4226 const unsigned int vertex)
4227{
4228 return {{vertex % 2, vertex / 2}};
4229}
4230
4231
4232
4233template <int dim>
4234inline std::array<unsigned int, 2>
4236 const unsigned int vertex)
4237{
4239 (void)vertex;
4240 return {{0, 0}};
4241}
4242
4243
4244
4245template <>
4246inline std::array<unsigned int, 2>
4248{
4249 // set up a table that for each
4250 // line describes a) from which
4251 // quad to take it, b) which line
4252 // therein it is if the face is
4253 // oriented correctly
4254 static const unsigned int lookup_table[GeometryInfo<3>::lines_per_cell][2] = {
4255 {4, 0}, // take first four lines from bottom face
4256 {4, 1},
4257 {4, 2},
4258 {4, 3},
4259
4260 {5, 0}, // second four lines from top face
4261 {5, 1},
4262 {5, 2},
4263 {5, 3},
4264
4265 {0, 0}, // the rest randomly
4266 {1, 0},
4267 {0, 1},
4268 {1, 1}};
4269
4270 return {{lookup_table[i][0], lookup_table[i][1]}};
4271}
4272
4273
4274
4275template <int dim>
4276inline std::array<unsigned int, 2>
4278{
4280 (void)line;
4281 return {{0, 0}};
4282}
4283
4284
4285
4286template <>
4287inline std::array<unsigned int, 2>
4289 const unsigned int vertex)
4290{
4291 // get the corner indices by asking either the bottom or the top face for its
4292 // vertices. handle non-standard faces by calling the vertex reordering
4293 // function from GeometryInfo
4294
4295 // bottom face (4) for first four vertices, top face (5) for the rest
4296 return {{4 + vertex / 4, vertex % 4}};
4297}
4298
4299
4300
4301template <int dim>
4302inline std::array<unsigned int, 2>
4304 const unsigned int vertex)
4305{
4307 (void)vertex;
4308 return {{0, 0}};
4309}
4310
4311
4312
4313template <>
4314inline unsigned int
4315GeometryInfo<3>::real_to_standard_face_line(const unsigned int line,
4316 const bool face_orientation,
4317 const bool face_flip,
4318 const bool face_rotation)
4319{
4321
4322
4323 // make sure we handle
4324 // non-standard faces correctly
4325 //
4326 // so set up a table that for each line (of a
4327 // quad) describes which line to take
4328 //
4329 // first index: four lines 0...3
4330 //
4331 // second index: face_orientation; 0:
4332 // opposite normal, 1: standard
4333 //
4334 // third index: face_flip; 0: standard, 1:
4335 // face rotated by 180 degrees
4336 //
4337 // forth index: face_rotation: 0: standard,
4338 // 1: face rotated by 90 degrees
4339
4340 const unsigned int line_translation[4][2][2][2] = {
4341 {{{2, 0}, // line 0, face_orientation=false, face_flip=false,
4342 // face_rotation=false and true
4343 {3, 1}}, // line 0, face_orientation=false, face_flip=true,
4344 // face_rotation=false and true
4345 {{0, 2}, // line 0, face_orientation=true, face_flip=false,
4346 // face_rotation=false and true
4347 {1, 3}}}, // line 0, face_orientation=true, face_flip=true,
4348 // face_rotation=false and true
4349
4350 {{{3, 1}, // line 1 ...
4351 {2, 0}},
4352 {{1, 3}, {0, 2}}},
4353
4354 {{{0, 3}, // line 2 ...
4355 {1, 2}},
4356 {{2, 1}, {3, 0}}},
4357
4358 {{{1, 2}, // line 3 ...
4359 {0, 3}},
4360 {{3, 0}, {2, 1}}}};
4361
4362 return line_translation[line][face_orientation][face_flip][face_rotation];
4363}
4364
4365
4366
4367template <int dim>
4368inline unsigned int
4369GeometryInfo<dim>::real_to_standard_face_line(const unsigned int line,
4370 const bool,
4371 const bool,
4372 const bool)
4373{
4375 return line;
4376}
4377
4378
4379
4380template <>
4381inline unsigned int
4383 const unsigned int face,
4384 const unsigned int subface,
4385 const bool,
4386 const bool,
4387 const bool,
4388 const RefinementCase<0> &)
4389{
4390 (void)subface;
4391 AssertIndexRange(face, faces_per_cell);
4392 AssertIndexRange(subface, max_children_per_face);
4393
4394 return face;
4395}
4396
4397
4398
4399template <>
4400inline unsigned int
4402 const unsigned int face,
4403 const unsigned int subface,
4404 const bool face_orientation,
4405 const bool /*face_flip*/,
4406 const bool /*face_rotation*/,
4407 const RefinementCase<1> &)
4408{
4409 AssertIndexRange(face, faces_per_cell);
4410 AssertIndexRange(subface, max_children_per_face);
4411
4412 // always return the child adjacent to the specified
4413 // subface. if the face of a cell is not refined, don't
4414 // throw an assertion but deliver the child adjacent to
4415 // the face nevertheless, i.e. deliver the child of
4416 // this cell adjacent to the subface of a possibly
4417 // refined neighbor. this simplifies setting neighbor
4418 // information in execute_refinement.
4419 constexpr unsigned int
4420 subcells[/* possible face orientation */ 2]
4421 [/* number of different ways to refine a cell */ 4]
4422 [/* faces_per_cell */ 4][/* max_children_per_face */ 2] = {
4423 {
4424 // Flipped orientation (face_orientation = false)
4425 {{0, 0}, {1, 1}, {1, 0}, {1, 0}}, // cut_x
4426 {{1, 0}, {1, 0}, {0, 0}, {1, 1}}, // cut_y
4427 {{2, 0}, {3, 1}, {1, 0}, {3, 2}} // cut_xy, i.e., isotropic
4428 },
4429 {
4430 // Normal orientation (face_orientation = true)
4431 {{0, 0}, {1, 1}, {0, 1}, {0, 1}}, // cut_x
4432 {{0, 1}, {0, 1}, {0, 0}, {1, 1}}, // cut_y
4433 {{0, 2}, {1, 3}, {0, 1}, {2, 3}} // cut_xy, i.e., isotropic
4434 }};
4435
4436 return subcells[face_orientation][ref_case - 1][face][subface];
4437}
4438
4439
4440
4441template <>
4442inline unsigned int
4444 const unsigned int face,
4445 const unsigned int subface,
4446 const bool face_orientation,
4447 const bool face_flip,
4448 const bool face_rotation,
4449 const RefinementCase<2> &face_ref_case)
4450{
4451 const unsigned int dim = 3;
4452
4454 ExcMessage("Cell has no children."));
4455 AssertIndexRange(face, faces_per_cell);
4456 if (!(subface == 0 &&
4458 {
4459 AssertIndexRange(subface,
4460 GeometryInfo<dim - 1>::n_children(face_ref_case));
4461 }
4462
4463 // invalid number used for invalid cases,
4464 // e.g. when the children are more refined at
4465 // a given face than the face itself
4466 const unsigned int e = numbers::invalid_unsigned_int;
4467
4468 // the whole process of finding a child cell
4469 // at a given subface considering the
4470 // possibly anisotropic refinement cases of
4471 // the cell and the face as well as
4472 // orientation, flip and rotation of the face
4473 // is quite complicated. thus, we break it
4474 // down into several steps.
4475
4476 // first step: convert the given face refine
4477 // case to a face refine case concerning the
4478 // face in standard orientation (, flip and
4479 // rotation). This only affects cut_x and
4480 // cut_y
4481 const RefinementCase<dim - 1> flip[4] = {
4482 RefinementCase<dim - 1>::no_refinement,
4483 RefinementCase<dim - 1>::cut_y,
4484 RefinementCase<dim - 1>::cut_x,
4485 RefinementCase<dim - 1>::cut_xy};
4486 // for face_orientation, 'true' is the
4487 // default value whereas for face_rotation,
4488 // 'false' is standard. If
4489 // <tt>face_rotation==face_orientation</tt>,
4490 // then one of them is non-standard and we
4491 // have to swap cut_x and cut_y, otherwise no
4492 // change is necessary.
4493 const RefinementCase<dim - 1> std_face_ref =
4494 (face_orientation == face_rotation) ? flip[face_ref_case] : face_ref_case;
4495
4496 // second step: convert the given subface
4497 // index to the one for a standard face
4498 // respecting face_orientation, face_flip and
4499 // face_rotation
4500
4501 // first index: face_ref_case
4502 // second index: face_orientation
4503 // third index: face_flip
4504 // forth index: face_rotation
4505 // fifth index: subface index
4506 const unsigned int subface_exchange[4][2][2][2][4] = {
4507 // no_refinement (subface 0 stays 0,
4508 // all others are invalid)
4509 {{{{0, e, e, e}, {0, e, e, e}}, {{0, e, e, e}, {0, e, e, e}}},
4510 {{{0, e, e, e}, {0, e, e, e}}, {{0, e, e, e}, {0, e, e, e}}}},
4511 // cut_x (here, if the face is only
4512 // rotated OR only falsely oriented,
4513 // then subface 0 of the non-standard
4514 // face does NOT correspond to one of
4515 // the subfaces of a standard
4516 // face. Thus we indicate the subface
4517 // which is located at the lower left
4518 // corner (the origin of the face's
4519 // local coordinate system) with
4520 // '0'. The rest of this issue is
4521 // taken care of using the above
4522 // conversion to a 'standard face
4523 // refine case')
4524 {{{{0, 1, e, e}, {0, 1, e, e}}, {{1, 0, e, e}, {1, 0, e, e}}},
4525 {{{0, 1, e, e}, {0, 1, e, e}}, {{1, 0, e, e}, {1, 0, e, e}}}},
4526 // cut_y (the same applies as for
4527 // cut_x)
4528 {{{{0, 1, e, e}, {1, 0, e, e}}, {{1, 0, e, e}, {0, 1, e, e}}},
4529 {{{0, 1, e, e}, {1, 0, e, e}}, {{1, 0, e, e}, {0, 1, e, e}}}},
4530 // cut_xyz: this information is
4531 // identical to the information
4532 // returned by
4533 // GeometryInfo<3>::real_to_standard_face_vertex()
4534 {{{{0, 2, 1, 3}, // face_orientation=false, face_flip=false,
4535 // face_rotation=false, subfaces 0,1,2,3
4536 {2, 3, 0, 1}}, // face_orientation=false, face_flip=false,
4537 // face_rotation=true, subfaces 0,1,2,3
4538 {{3, 1, 2, 0}, // face_orientation=false, face_flip=true,
4539 // face_rotation=false, subfaces 0,1,2,3
4540 {1, 0, 3, 2}}}, // face_orientation=false, face_flip=true,
4541 // face_rotation=true, subfaces 0,1,2,3
4542 {{{0, 1, 2, 3}, // face_orientation=true, face_flip=false,
4543 // face_rotation=false, subfaces 0,1,2,3
4544 {1, 3, 0, 2}}, // face_orientation=true, face_flip=false,
4545 // face_rotation=true, subfaces 0,1,2,3
4546 {{3, 2, 1, 0}, // face_orientation=true, face_flip=true,
4547 // face_rotation=false, subfaces 0,1,2,3
4548 {2, 0, 3, 1}}}}}; // face_orientation=true, face_flip=true,
4549 // face_rotation=true, subfaces 0,1,2,3
4550
4551 const unsigned int std_subface =
4552 subface_exchange[face_ref_case][face_orientation][face_flip][face_rotation]
4553 [subface];
4554 Assert(std_subface != e, ExcInternalError());
4555
4556 // third step: these are the children, which
4557 // can be found at the given subfaces of an
4558 // isotropically refined (standard) face
4559 //
4560 // first index: (refinement_case-1)
4561 // second index: face_index
4562 // third index: subface_index (isotropic refinement)
4563 const unsigned int iso_children[RefinementCase<dim>::cut_xyz][faces_per_cell]
4564 [max_children_per_face] = {
4565 // cut_x
4566 {{0, 0, 0, 0}, // face 0, subfaces 0,1,2,3
4567 {1, 1, 1, 1}, // face 1, subfaces 0,1,2,3
4568 {0, 0, 1, 1}, // face 2, subfaces 0,1,2,3
4569 {0, 0, 1, 1}, // face 3, subfaces 0,1,2,3
4570 {0, 1, 0, 1}, // face 4, subfaces 0,1,2,3
4571 {0, 1, 0, 1}}, // face 5, subfaces 0,1,2,3
4572 // cut_y
4573 {{0, 1, 0, 1},
4574 {0, 1, 0, 1},
4575 {0, 0, 0, 0},
4576 {1, 1, 1, 1},
4577 {0, 0, 1, 1},
4578 {0, 0, 1, 1}},
4579 // cut_xy
4580 {{0, 2, 0, 2},
4581 {1, 3, 1, 3},
4582 {0, 0, 1, 1},
4583 {2, 2, 3, 3},
4584 {0, 1, 2, 3},
4585 {0, 1, 2, 3}},
4586 // cut_z
4587 {{0, 0, 1, 1},
4588 {0, 0, 1, 1},
4589 {0, 1, 0, 1},
4590 {0, 1, 0, 1},
4591 {0, 0, 0, 0},
4592 {1, 1, 1, 1}},
4593 // cut_xz
4594 {{0, 0, 1, 1},
4595 {2, 2, 3, 3},
4596 {0, 1, 2, 3},
4597 {0, 1, 2, 3},
4598 {0, 2, 0, 2},
4599 {1, 3, 1, 3}},
4600 // cut_yz
4601 {{0, 1, 2, 3},
4602 {0, 1, 2, 3},
4603 {0, 2, 0, 2},
4604 {1, 3, 1, 3},
4605 {0, 0, 1, 1},
4606 {2, 2, 3, 3}},
4607 // cut_xyz
4608 {{0, 2, 4, 6},
4609 {1, 3, 5, 7},
4610 {0, 4, 1, 5},
4611 {2, 6, 3, 7},
4612 {0, 1, 2, 3},
4613 {4, 5, 6, 7}}};
4614
4615 // forth step: check, whether the given face
4616 // refine case is valid for the given cell
4617 // refine case. this is the case, if the
4618 // given face refine case is at least as
4619 // refined as the face is for the given cell
4620 // refine case
4621
4622 // note, that we are considering standard
4623 // face refinement cases here and thus must
4624 // not pass the given orientation, flip and
4625 // rotation flags
4626 if ((std_face_ref & face_refinement_case(ref_case, face)) ==
4627 face_refinement_case(ref_case, face))
4628 {
4629 // all is fine. for anisotropic face
4630 // refine cases, select one of the
4631 // isotropic subfaces which neighbors the
4632 // same child
4633
4634 // first index: (standard) face refine case
4635 // second index: subface index
4636 const unsigned int equivalent_iso_subface[4][4] = {
4637 {0, e, e, e}, // no_refinement
4638 {0, 3, e, e}, // cut_x
4639 {0, 3, e, e}, // cut_y
4640 {0, 1, 2, 3}}; // cut_xy
4641
4642 const unsigned int equ_std_subface =
4643 equivalent_iso_subface[std_face_ref][std_subface];
4644 Assert(equ_std_subface != e, ExcInternalError());
4645
4646 return iso_children[ref_case - 1][face][equ_std_subface];
4647 }
4648 else
4649 {
4650 // the face_ref_case was too coarse,
4651 // throw an error
4652 Assert(false,
4653 ExcMessage("The face RefineCase is too coarse "
4654 "for the given cell RefineCase."));
4655 }
4656 // we only get here in case of an error
4657 return e;
4658}
4659
4660
4661
4662template <>
4663inline unsigned int
4665 const unsigned int,
4666 const unsigned int,
4667 const bool,
4668 const bool,
4669 const bool,
4670 const RefinementCase<3> &)
4671{
4674}
4675
4676
4677
4678template <>
4679inline unsigned int
4680GeometryInfo<2>::face_to_cell_lines(const unsigned int face,
4681 const unsigned int line,
4682 const bool,
4683 const bool,
4684 const bool)
4685{
4686 (void)line;
4687 AssertIndexRange(face, faces_per_cell);
4688 AssertIndexRange(line, lines_per_face);
4689
4690 // The face is a line itself.
4691 return face;
4692}
4693
4694
4695
4696template <>
4697inline unsigned int
4698GeometryInfo<3>::face_to_cell_lines(const unsigned int face,
4699 const unsigned int line,
4700 const bool face_orientation,
4701 const bool face_flip,
4702 const bool face_rotation)
4703{
4704 AssertIndexRange(face, faces_per_cell);
4705 AssertIndexRange(line, lines_per_face);
4706
4707 const unsigned lines[faces_per_cell][lines_per_face] = {
4708 {8, 10, 0, 4}, // left face
4709 {9, 11, 1, 5}, // right face
4710 {2, 6, 8, 9}, // front face
4711 {3, 7, 10, 11}, // back face
4712 {0, 1, 2, 3}, // bottom face
4713 {4, 5, 6, 7}}; // top face
4714 return lines[face][real_to_standard_face_line(
4715 line, face_orientation, face_flip, face_rotation)];
4716}
4717
4718
4719
4720inline unsigned int
4721GeometryInfo<0>::face_to_cell_lines(const unsigned int,
4722 const unsigned int,
4723 const bool,
4724 const bool,
4725 const bool)
4726{
4729}
4730
4731
4732
4733template <int dim>
4734inline unsigned int
4735GeometryInfo<dim>::face_to_cell_lines(const unsigned int,
4736 const unsigned int,
4737 const bool,
4738 const bool,
4739 const bool)
4740{
4743}
4744
4745
4746
4747template <int dim>
4748inline unsigned int
4749GeometryInfo<dim>::face_to_cell_vertices(const unsigned int face,
4750 const unsigned int vertex,
4751 const bool face_orientation,
4752 const bool face_flip,
4753 const bool face_rotation)
4754{
4755 return child_cell_on_face(RefinementCase<dim>::isotropic_refinement,
4756 face,
4757 vertex,
4758 face_orientation,
4759 face_flip,
4760 face_rotation);
4761}
4762
4763
4764
4765inline unsigned int
4767 const unsigned int,
4768 const bool,
4769 const bool,
4770 const bool)
4771{
4774}
4775
4776
4777
4778template <int dim>
4779template <typename Number>
4780inline Point<dim, Number>
4782{
4784 for (unsigned int i = 0; i < dim; ++i)
4785 p[i] = std::min(std::max(q[i], Number(0.)), Number(1.));
4786
4787 return p;
4788}
4789
4790
4791
4792template <int dim>
4793inline double
4795{
4796 double result = 0.0;
4797
4798 for (unsigned int i = 0; i < dim; ++i)
4799 {
4800 result = std::max(result, -p[i]);
4801 result = std::max(result, p[i] - 1.);
4802 }
4803
4804 return result;
4805}
4806
4807
4808
4809template <int dim>
4810inline double
4812 const unsigned int i)
4813{
4815
4816 switch (dim)
4817 {
4818 case 1:
4819 {
4820 const double x = xi[0];
4821 switch (i)
4822 {
4823 case 0:
4824 return 1 - x;
4825 case 1:
4826 return x;
4827 }
4828 break;
4829 }
4830
4831 case 2:
4832 {
4833 const double x = xi[0];
4834 const double y = xi[1];
4835 switch (i)
4836 {
4837 case 0:
4838 return (1 - x) * (1 - y);
4839 case 1:
4840 return x * (1 - y);
4841 case 2:
4842 return (1 - x) * y;
4843 case 3:
4844 return x * y;
4845 }
4846 break;
4847 }
4848
4849 case 3:
4850 {
4851 const double x = xi[0];
4852 const double y = xi[1];
4853 const double z = xi[2];
4854 switch (i)
4855 {
4856 case 0:
4857 return (1 - x) * (1 - y) * (1 - z);
4858 case 1:
4859 return x * (1 - y) * (1 - z);
4860 case 2:
4861 return (1 - x) * y * (1 - z);
4862 case 3:
4863 return x * y * (1 - z);
4864 case 4:
4865 return (1 - x) * (1 - y) * z;
4866 case 5:
4867 return x * (1 - y) * z;
4868 case 6:
4869 return (1 - x) * y * z;
4870 case 7:
4871 return x * y * z;
4872 }
4873 break;
4874 }
4875
4876 default:
4878 }
4879 return -1e9;
4880}
4881
4882
4883
4884template <>
4886 const Point<1> &,
4887 const unsigned int i)
4888{
4890
4891 switch (i)
4892 {
4893 case 0:
4894 return Point<1>(-1.);
4895 case 1:
4896 return Point<1>(1.);
4897 }
4898
4899 return Point<1>(-1e9);
4900}
4901
4902
4903
4904template <>
4906 const Point<2> &xi,
4907 const unsigned int i)
4908{
4910
4911 const double x = xi[0];
4912 const double y = xi[1];
4913 switch (i)
4914 {
4915 case 0:
4916 return Point<2>(-(1 - y), -(1 - x));
4917 case 1:
4918 return Point<2>(1 - y, -x);
4919 case 2:
4920 return Point<2>(-y, 1 - x);
4921 case 3:
4922 return Point<2>(y, x);
4923 }
4924 return Point<2>(-1e9, -1e9);
4925}
4926
4927
4928
4929template <>
4931 const Point<3> &xi,
4932 const unsigned int i)
4933{
4935
4936 const double x = xi[0];
4937 const double y = xi[1];
4938 const double z = xi[2];
4939 switch (i)
4940 {
4941 case 0:
4942 return Point<3>(-(1 - y) * (1 - z),
4943 -(1 - x) * (1 - z),
4944 -(1 - x) * (1 - y));
4945 case 1:
4946 return Point<3>((1 - y) * (1 - z), -x * (1 - z), -x * (1 - y));
4947 case 2:
4948 return Point<3>(-y * (1 - z), (1 - x) * (1 - z), -(1 - x) * y);
4949 case 3:
4950 return Point<3>(y * (1 - z), x * (1 - z), -x * y);
4951 case 4:
4952 return Point<3>(-(1 - y) * z, -(1 - x) * z, (1 - x) * (1 - y));
4953 case 5:
4954 return Point<3>((1 - y) * z, -x * z, x * (1 - y));
4955 case 6:
4956 return Point<3>(-y * z, (1 - x) * z, (1 - x) * y);
4957 case 7:
4958 return Point<3>(y * z, x * z, x * y);
4959 }
4960
4961 return Point<3>(-1e9, -1e9, -1e9);
4962}
4963
4964
4965
4966template <int dim>
4967inline Tensor<1, dim>
4969 const unsigned int)
4970{
4972 return Tensor<1, dim>();
4973}
4974
4975
4976unsigned int inline GeometryInfo<0>::n_children(const RefinementCase<0> &)
4977{
4978 return 0;
4979}
4980
4981
4982namespace internal
4983{
4984 namespace GeometryInfoHelper
4985 {
4986 // wedge product of a single
4987 // vector in 2d: we just have to
4988 // rotate it by 90 degrees to the
4989 // right
4990 inline Tensor<1, 2>
4991 wedge_product(const Tensor<1, 2> (&derivative)[1])
4992 {
4993 Tensor<1, 2> result;
4994 result[0] = derivative[0][1];
4995 result[1] = -derivative[0][0];
4996
4997 return result;
4998 }
4999
5000
5001 // wedge product of 2 vectors in
5002 // 3d is the cross product
5003 inline Tensor<1, 3>
5004 wedge_product(const Tensor<1, 3> (&derivative)[2])
5005 {
5006 return cross_product_3d(derivative[0], derivative[1]);
5007 }
5008
5009
5010 // wedge product of dim vectors
5011 // in dim-d: that's the
5012 // determinant of the matrix
5013 template <int dim>
5014 inline Tensor<0, dim>
5015 wedge_product(const Tensor<1, dim> (&derivative)[dim])
5016 {
5017 Tensor<2, dim> jacobian;
5018 for (unsigned int i = 0; i < dim; ++i)
5019 jacobian[i] = derivative[i];
5020
5021 return determinant(jacobian);
5022 }
5023 } // namespace GeometryInfoHelper
5024} // namespace internal
5025
5026
5027template <int dim>
5028template <int spacedim>
5029inline void
5031# ifndef DEAL_II_CXX14_CONSTEXPR_BUG
5032 (const Point<spacedim> (&vertices)[vertices_per_cell],
5033 Tensor<spacedim - dim, spacedim> (&forms)[vertices_per_cell])
5034# else
5035 (const Point<spacedim> *vertices, Tensor<spacedim - dim, spacedim> *forms)
5036# endif
5037{
5038 // for each of the vertices,
5039 // compute the alternating form
5040 // of the mapped unit
5041 // vectors. consider for
5042 // example the case of a quad
5043 // in spacedim==3: to do so, we
5044 // need to see how the
5045 // infinitesimal vectors
5046 // (d\xi_1,0) and (0,d\xi_2)
5047 // are transformed into
5048 // spacedim-dimensional space
5049 // and then form their cross
5050 // product (i.e. the wedge product
5051 // of two vectors). to this end, note
5052 // that
5053 // \vec x = sum_i \vec v_i phi_i(\vec xi)
5054 // so the transformed vectors are
5055 // [x(\xi+(d\xi_1,0))-x(\xi)]/d\xi_1
5056 // and
5057 // [x(\xi+(0,d\xi_2))-x(\xi)]/d\xi_2
5058 // which boils down to the columns
5059 // of the 3x2 matrix \grad_\xi x(\xi)
5060 //
5061 // a similar reasoning would
5062 // hold for all dim,spacedim
5063 // pairs -- we only have to
5064 // compute the wedge product of
5065 // the columns of the
5066 // derivatives
5067 for (unsigned int i = 0; i < vertices_per_cell; ++i)
5068 {
5069 Tensor<1, spacedim> derivatives[dim];
5070
5071 for (unsigned int j = 0; j < vertices_per_cell; ++j)
5072 {
5073 const Tensor<1, dim> grad_phi_j =
5074 d_linear_shape_function_gradient(unit_cell_vertex(i), j);
5075 for (unsigned int l = 0; l < dim; ++l)
5076 derivatives[l] += vertices[j] * grad_phi_j[l];
5077 }
5078
5079 forms[i] = internal::GeometryInfoHelper::wedge_product(derivatives);
5080 }
5081}
5082
5083#endif // DOXYGEN
5085
5086#endif
GeometryPrimitive(const unsigned int object_dimension)
GeometryPrimitive(const Object object)
Definition point.h:111
constexpr RefinementCase()
constexpr RefinementCase(const typename RefinementPossibilities< dim >::Possibilities refinement_case)
constexpr RefinementCase operator&(const RefinementCase &r) const
constexpr RefinementCase operator~() const
static constexpr unsigned int n_refinement_cases
std::uint8_t value
static constexpr RefinementCase cut_axis(const unsigned int i)
void serialize(Archive &ar, const unsigned int version)
constexpr RefinementCase operator|(const RefinementCase &r) const
constexpr RefinementCase(const std::uint8_t refinement_case)
static constexpr std::array< RefinementCase< dim >, n_refinement_cases > all_refinement_cases()
static constexpr std::size_t memory_consumption()
static constexpr std::size_t memory_consumption()
SubfaceCase(const typename SubfacePossibilities< dim >::Possibilities subface_possibility)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_HOST_DEVICE
Definition config.h:171
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
static ::ExceptionBase & ExcInvalidCoordinate(double arg1)
static ::ExceptionBase & ExcInvalidSubface(int arg1, int arg2, int arg3)
static ::ExceptionBase & ExcInvalidRefinementCase(int arg1)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcInvalidSubfaceCase(int arg1)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
Definition utilities.cc:190
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
*  *  *  RotationFunction< dim, Number >::RotationFunction Number(dim)
constexpr unsigned int invalid_unsigned_int
Definition types.h:228
boost::integer_range< IncrementableType > iota_view
Definition iota_view.h:43
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
typename internal::ndarray::HelperArray< T, Ns... >::type ndarray
Definition ndarray.h:105
static unsigned int n_children(const RefinementCase< 0 > &refinement_case)
static unsigned int face_to_cell_vertices(const unsigned int face, const unsigned int vertex, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static std::array< unsigned int, 0 > face_indices()
static std::array< unsigned int, vertices_per_cell > vertex_indices()
static unsigned int face_to_cell_lines(const unsigned int face, const unsigned int line, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static unsigned int child_cell_from_point(const Point< dim > &p)
static unsigned int standard_to_real_line_vertex(const unsigned int vertex, const bool line_orientation=true)
static constexpr std::array< unsigned int, vertices_per_cell > ucd_to_deal
static constexpr ndarray< Tensor< 1, dim >, faces_per_cell, dim - 1 > unit_tangential_vectors
static bool is_inside_unit_cell(const Point< dim > &p, const double eps)
static double distance_to_unit_cell(const Point< dim > &p)
static unsigned int child_cell_on_face(const RefinementCase< dim > &ref_case, const unsigned int face, const unsigned int subface, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false, const RefinementCase< dim - 1 > &face_refinement_case=RefinementCase< dim - 1 >::isotropic_refinement)
static constexpr unsigned int quads_per_face
static RefinementCase< dim - 1 > face_refinement_case(const RefinementCase< dim > &cell_refinement_case, const unsigned int face_no, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static unsigned int standard_to_real_face_vertex(const unsigned int vertex, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static RefinementCase< dim > min_cell_refinement_case_for_line_refinement(const unsigned int line_no)
static constexpr std::array< unsigned int, faces_per_cell > opposite_face
static constexpr unsigned int max_children_per_face
static unsigned int face_to_cell_vertices(const unsigned int face, const unsigned int vertex, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static constexpr unsigned int vertices_per_cell
static constexpr std::array< unsigned int, vertices_per_cell > dx_to_deal
static constexpr unsigned int lines_per_cell
static constexpr std::array< unsigned int, faces_per_cell > unit_normal_direction
static std::array< unsigned int, 2 > standard_hex_line_to_quad_line_index(const unsigned int line)
static constexpr unsigned int faces_per_cell
static unsigned int standard_to_real_face_line(const unsigned int line, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()
static double subface_ratio(const internal::SubfaceCase< dim > &subface_case, const unsigned int subface_no)
static constexpr unsigned int hexes_per_cell
static Point< dim, Number > project_to_unit_cell(const Point< dim, Number > &p)
static RefinementCase< 1 > line_refinement_case(const RefinementCase< dim > &cell_refinement_case, const unsigned int line_no)
static std::array< unsigned int, 2 > standard_hex_vertex_to_quad_vertex_index(const unsigned int vertex)
static std::array< unsigned int, 2 > standard_quad_vertex_to_line_vertex_index(const unsigned int vertex)
static double d_linear_shape_function(const Point< dim > &xi, const unsigned int i)
static constexpr std::array< Tensor< 1, dim >, faces_per_cell > unit_normal_vector
static constexpr unsigned int vertices_per_face
static unsigned int real_to_standard_face_line(const unsigned int line, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static unsigned int line_to_cell_vertices(const unsigned int line, const unsigned int vertex)
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices()
static bool is_inside_unit_cell(const Point< dim > &p)
static RefinementCase< dim > min_cell_refinement_case_for_face_refinement(const RefinementCase< dim - 1 > &face_refinement_case, const unsigned int face_no, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static unsigned int n_children(const RefinementCase< dim > &refinement_case)
static unsigned int real_to_standard_face_vertex(const unsigned int vertex, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static unsigned int face_to_cell_lines(const unsigned int face, const unsigned int line, const bool face_orientation=true, const bool face_flip=false, const bool face_rotation=false)
static Point< dim > cell_to_child_coordinates(const Point< dim > &p, const unsigned int child_index, const RefinementCase< dim > refine_case=RefinementCase< dim >::isotropic_refinement)
static constexpr ndarray< unsigned int, vertices_per_cell, dim > vertex_to_face
static Tensor< 1, dim > d_linear_shape_function_gradient(const Point< dim > &xi, const unsigned int i)
static void alternating_form_at_vertices(const Point< spacedim >(&vertices)[vertices_per_cell], Tensor< spacedim - dim, spacedim >(&forms)[vertices_per_cell])
static Point< dim > unit_cell_vertex(const unsigned int vertex)
static constexpr std::array< int, faces_per_cell > unit_normal_orientation
static constexpr unsigned int quads_per_cell
static Point< dim > child_to_cell_coordinates(const Point< dim > &p, const unsigned int child_index, const RefinementCase< dim > refine_case=RefinementCase< dim >::isotropic_refinement)
static constexpr unsigned int max_children_per_cell
static unsigned int n_subfaces(const internal::SubfaceCase< dim > &subface_case)
static constexpr unsigned int lines_per_face
constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)