16 #ifndef dealii_geometry_info_h
17 #define dealii_geometry_info_h
36 namespace GeometryInfoHelper
44 struct Initializers<1>
46 static constexpr std::array<unsigned int, 2>
52 static constexpr std::array<unsigned int, 2>
53 unit_normal_direction()
58 static constexpr std::array<int, 2>
59 unit_normal_orientation()
64 static constexpr std::array<Tensor<1, 1>, 2>
70 static constexpr std::array<std::array<Tensor<1, 1>, 0>, 2>
71 unit_tangential_vectors()
73 return {{{{}}, {{}}}};
76 static constexpr std::array<unsigned int, 2>
82 static constexpr std::array<unsigned int, 2>
88 static constexpr std::array<std::array<unsigned int, 1>, 2>
91 return {{{{0}}, {{1}}}};
96 struct Initializers<2>
98 static constexpr std::array<unsigned int, 4>
101 return {{0, 1, 3, 2}};
104 static constexpr std::array<unsigned int, 4>
105 unit_normal_direction()
107 return {{0, 0, 1, 1}};
110 static constexpr std::array<int, 4>
111 unit_normal_orientation()
113 return {{-1, 1, -1, 1}};
116 static constexpr std::array<Tensor<1, 2>, 4>
125 static constexpr std::array<std::array<Tensor<1, 2>, 1>, 4>
126 unit_tangential_vectors()
134 static constexpr std::array<unsigned int, 4>
137 return {{1, 0, 3, 2}};
140 static constexpr std::array<unsigned int, 4>
143 return {{0, 2, 1, 3}};
146 static constexpr std::array<std::array<unsigned int, 2>, 4>
149 return {{{{0, 2}}, {{1, 2}}, {{0, 3}}, {{1, 3}}}};
154 struct Initializers<3>
156 static constexpr std::array<unsigned int, 8>
159 return {{0, 1, 5, 4, 2, 3, 7, 6}};
162 static constexpr std::array<unsigned int, 6>
163 unit_normal_direction()
165 return {{0, 0, 1, 1, 2, 2}};
168 static constexpr std::array<int, 6>
169 unit_normal_orientation()
171 return {{-1, 1, -1, 1, -1, 1}};
174 static constexpr std::array<Tensor<1, 3>, 6>
185 static constexpr std::array<std::array<Tensor<1, 3>, 2>, 6>
186 unit_tangential_vectors()
196 static constexpr std::array<unsigned int, 6>
199 return {{1, 0, 3, 2, 5, 4}};
202 static constexpr std::array<unsigned int, 8>
205 return {{0, 4, 2, 6, 1, 5, 3, 7}};
208 static constexpr std::array<std::array<unsigned int, 3>, 8>
211 return {{{{0, 2, 4}},
223 struct Initializers<4>
225 static constexpr std::array<unsigned int, 16>
246 static constexpr std::array<unsigned int, 8>
247 unit_normal_direction()
249 return {{0, 0, 1, 1, 2, 2, 3, 3}};
252 static constexpr std::array<int, 8>
253 unit_normal_orientation()
255 return {{-1, 1, -1, 1, -1, 1, -1, 1}};
258 static constexpr std::array<Tensor<1, 4>, 8>
271 static constexpr std::array<std::array<Tensor<1, 4>, 3>, 8>
272 unit_tangential_vectors()
300 static constexpr std::array<unsigned int, 8>
303 return {{1, 0, 3, 2, 5, 4, 7, 6}};
306 static constexpr std::array<unsigned int, 16>
327 static constexpr std::array<std::array<unsigned int, 4>, 16>
464 operator unsigned int()
const;
680 cut_xy = cut_x | cut_y,
756 cut_xy = cut_x | cut_y,
764 cut_xz = cut_x | cut_z,
768 cut_yz = cut_y | cut_z,
772 cut_xyz = cut_x | cut_y | cut_z,
828 operator std::uint8_t()
const;
872 template <
class Archive>
874 serialize(Archive &ar,
const unsigned int version);
882 <<
"The refinement flags given (" << arg1
883 <<
") contain set bits that do not "
884 <<
"make sense for the space dimension of the object to which they are applied.");
891 std::uint8_t
value : (dim > 0 ? dim : 1);
1181 subface_possibility);
1194 operator std::uint8_t()
const;
1199 static constexpr std::size_t
1208 <<
"The subface case given (" << arg1 <<
") does not make sense "
1209 <<
"for the space dimension of the object to which they are applied.");
1216 std::uint8_t
value : (dim == 3 ? 4 : 1);
1278 static std::array<unsigned int, 0>
1321 static std::array<unsigned int, vertices_per_cell>
1389 static const std::array<unsigned int, vertices_per_cell>
dx_to_deal;
2053 static constexpr std::array<unsigned int, vertices_per_cell>
ucd_to_deal =
2054 internal::GeometryInfoHelper::Initializers<dim>::ucd_to_deal();
2069 static constexpr std::array<unsigned int, vertices_per_cell>
dx_to_deal =
2070 internal::GeometryInfoHelper::Initializers<dim>::dx_to_deal();
2084 internal::GeometryInfoHelper::Initializers<dim>::vertex_to_face();
2111 const unsigned int subface_no);
2120 const unsigned int face_no,
2121 const bool face_orientation =
true,
2122 const bool face_flip =
false,
2123 const bool face_rotation =
false);
2133 const unsigned int face_no,
2134 const bool face_orientation =
true,
2135 const bool face_flip =
false,
2136 const bool face_rotation =
false);
2144 const unsigned int line_no);
2201 const unsigned int face,
2202 const unsigned int subface,
2203 const bool face_orientation =
true,
2204 const bool face_flip =
false,
2205 const bool face_rotation =
false,
2247 const unsigned int vertex,
2248 const bool face_orientation =
true,
2249 const bool face_flip =
false,
2250 const bool face_rotation =
false);
2265 const unsigned int line,
2266 const bool face_orientation =
true,
2267 const bool face_flip =
false,
2268 const bool face_rotation =
false);
2281 const bool face_orientation =
true,
2282 const bool face_flip =
false,
2283 const bool face_rotation =
false);
2296 const bool face_orientation =
true,
2297 const bool face_flip =
false,
2298 const bool face_rotation =
false);
2311 const bool face_orientation =
true,
2312 const bool face_flip =
false,
2313 const bool face_rotation =
false);
2326 const bool face_orientation =
true,
2327 const bool face_flip =
false,
2328 const bool face_rotation =
false);
2359 const unsigned int child_index,
2370 const unsigned int child_index,
2475 template <
int spacedim>
2478 #ifndef DEAL_II_CONSTEXPR_BUG
2494 static constexpr std::array<unsigned int, faces_per_cell>
2496 internal::GeometryInfoHelper::Initializers<dim>::unit_normal_direction();
2515 internal::GeometryInfoHelper::Initializers<dim>::unit_normal_orientation();
2529 internal::GeometryInfoHelper::Initializers<dim>::unit_normal_vector();
2544 static constexpr std::array<std::array<Tensor<1, dim>, dim - 1>,
2555 internal::GeometryInfoHelper::Initializers<dim>::opposite_face();
2563 <<
"The coordinates must satisfy 0 <= x_i <= 1, "
2564 <<
"but here we have x_i=" << arg1);
2573 <<
"RefinementCase<dim> " << arg1 <<
": face " << arg2
2574 <<
" has no subface " << arg3);
2588 const unsigned int i);
2592 const unsigned int i);
2596 const unsigned int i);
2610 : object(static_cast<Object>(object_dimension))
2614 inline GeometryPrimitive::operator
unsigned int()
const
2616 return static_cast<unsigned int>(object);
2626 :
value(subface_possibility)
2631 inline SubfaceCase<dim>::operator std::uint8_t()
const
2645 return static_cast<std::uint8_t
>(-1);
2698 :
value(refinement_case)
2704 Assert((refinement_case &
2707 ExcInvalidRefinementCase(refinement_case));
2714 :
value(refinement_case)
2720 Assert((refinement_case &
2723 ExcInvalidRefinementCase(refinement_case));
2774 template <
class Archive>
2780 std::uint8_t uchar_value =
value;
2782 value = uchar_value;
2793 return Point<1>(
static_cast<double>(vertex));
2804 return {
static_cast<double>(vertex % 2),
static_cast<double>(vertex / 2)};
2815 return {
static_cast<double>(vertex % 2),
2816 static_cast<double>(vertex / 2 % 2),
2817 static_cast<double>(vertex / 4)};
2822 inline std::array<unsigned int, 0>
2830 inline std::array<unsigned int, 1>
2842 return {0
U, faces_per_cell};
2851 return {0
U, vertices_per_cell};
2871 Assert((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
2873 return (p[0] <= 0.5 ? 0 : 1);
2882 Assert((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
2883 Assert((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1]));
2885 return (p[0] <= 0.5 ? (p[1] <= 0.5 ? 0 : 2) : (p[1] <= 0.5 ? 1 : 3));
2894 Assert((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
2895 Assert((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1]));
2896 Assert((p[2] >= 0) && (p[2] <= 1), ExcInvalidCoordinate(p[2]));
2898 return (p[0] <= 0.5 ?
2899 (p[1] <= 0.5 ? (p[2] <= 0.5 ? 0 : 4) : (p[2] <= 0.5 ? 2 : 6)) :
2900 (p[1] <= 0.5 ? (p[2] <= 0.5 ? 1 : 5) : (p[2] <= 0.5 ? 3 : 7)));
2918 const unsigned int child_index,
2926 return Point<1>(p * 2.0 - unit_cell_vertex(child_index));
2934 const unsigned int child_index,
2941 switch (refine_case)
2945 if (child_index == 1)
2950 if (child_index == 1)
2955 point -= unit_cell_vertex(child_index);
2969 const unsigned int child_index,
2981 switch (refine_case)
2985 if (child_index == 1)
2990 if (child_index == 1)
2995 if (child_index == 1)
3001 if (child_index % 2 == 1)
3003 if (child_index / 2 == 1)
3013 if (child_index / 2 == 1)
3015 if (child_index % 2 == 1)
3021 if (child_index % 2 == 1)
3023 if (child_index / 2 == 1)
3028 point -= unit_cell_vertex(child_index);
3043 const unsigned int ,
3056 const unsigned int child_index,
3064 return (p + unit_cell_vertex(child_index)) * 0.5;
3072 const unsigned int child_index,
3084 switch (refine_case)
3087 if (child_index == 1)
3092 if (child_index == 1)
3097 if (child_index == 1)
3102 if (child_index % 2 == 1)
3104 if (child_index / 2 == 1)
3114 if (child_index / 2 == 1)
3116 if (child_index % 2 == 1)
3122 if (child_index % 2 == 1)
3124 if (child_index / 2 == 1)
3130 point += unit_cell_vertex(child_index);
3145 const unsigned int child_index,
3151 switch (refine_case)
3154 if (child_index == 1)
3159 if (child_index == 1)
3164 point += unit_cell_vertex(child_index);
3180 const unsigned int ,
3201 return (p[0] >= 0.) && (p[0] <= 1.);
3210 return (p[0] >= 0.) && (p[0] <= 1.) && (p[1] >= 0.) && (p[1] <= 1.);
3219 return (p[0] >= 0.) && (p[0] <= 1.) && (p[1] >= 0.) && (p[1] <= 1.) &&
3220 (p[2] >= 0.) && (p[2] <= 1.);
3237 return (p[0] >= -
eps) && (p[0] <= 1. +
eps);
3246 const double l = -
eps, u = 1 +
eps;
3247 return (p[0] >=
l) && (p[0] <= u) && (p[1] >=
l) && (p[1] <= u);
3256 const double l = -
eps, u = 1.0 +
eps;
3257 return (p[0] >=
l) && (p[0] <= u) && (p[1] >=
l) && (p[1] <= u) &&
3258 (p[2] >=
l) && (p[2] <= u);
3266 const unsigned int vertex)
3279 const unsigned int vertex)
3281 constexpr
unsigned int cell_vertices[4][2] = {{0, 2}, {1, 3}, {0, 1}, {2, 3}};
3282 return cell_vertices[line][vertex];
3290 const unsigned int vertex)
3295 constexpr
unsigned vertices[lines_per_cell][2] = {{0, 2},
3323 const bool face_orientation,
3324 const bool face_flip,
3325 const bool face_rotation)
3347 constexpr
unsigned int vertex_translation[4][2][2][2] = {
3369 return vertex_translation[vertex][face_orientation][face_flip][face_rotation];
3391 0, 2, 2, 4, 2, 4, 4, 8};
3393 return n_children[ref_case];
3428 0, 2, 3, 3, 4, 2, 3, 3, 4, 4};
3429 return nsubs[subface_case];
3458 switch (subface_case)
3495 const unsigned int subface_no)
3498 switch (subface_case)
3533 if (subface_no == 0)
3580 const unsigned int face_no,
3585 const unsigned int dim = 2;
3603 return ref_cases[cell_refinement_case][face_no / 2];
3611 const unsigned int face_no,
3612 const bool face_orientation,
3614 const bool face_rotation)
3616 const unsigned int dim = 3;
3658 ref_cases[cell_refinement_case][face_no / 2];
3678 return (face_orientation == face_rotation) ? flip[ref_case] : ref_case;
3696 const unsigned int line_no)
3699 const unsigned int dim = 1;
3705 return cell_refinement_case;
3713 const unsigned int line_no)
3716 return face_refinement_case(cell_refinement_case, line_no);
3724 const unsigned int line_no)
3726 const unsigned int dim = 3;
3743 const unsigned int direction[lines_per_cell] = {
3744 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 2, 2};
3746 return ((cell_refinement_case & cut_one[direction[line_no]]) ?
3776 const unsigned int dim = 1;
3787 const unsigned int face_no,
3792 const unsigned int dim = 2;
3809 const unsigned int face_no,
3810 const bool face_orientation,
3812 const bool face_rotation)
3814 const unsigned int dim = 3;
3838 (face_orientation == face_rotation) ? flip[face_refinement_case] :
3839 face_refinement_case;
3858 return face_to_cell[face_no / 2][std_face_ref];
3876 const unsigned int line_no)
3888 const unsigned int line_no)
3890 const unsigned int dim = 2;
3901 const unsigned int line_no)
3903 const unsigned int dim = 3;
3914 return ref_cases[line_no / 2];
3922 const bool face_orientation,
3923 const bool face_flip,
3924 const bool face_rotation)
3946 const unsigned int vertex_translation[4][2][2][2] = {
3968 return vertex_translation[vertex][face_orientation][face_flip][face_rotation];
3990 const bool face_orientation,
3991 const bool face_flip,
3992 const bool face_rotation)
4014 const unsigned int line_translation[4][2][2][2] = {
4036 return line_translation[line][face_orientation][face_flip][face_rotation];
4057 const bool face_orientation,
4058 const bool face_flip,
4059 const bool face_rotation)
4081 const unsigned int line_translation[4][2][2][2] = {
4103 return line_translation[line][face_orientation][face_flip][face_rotation];
4124 const unsigned int face,
4125 const unsigned int subface,
4143 const unsigned int face,
4144 const unsigned int subface,
4146 const bool face_flip,
4162 [max_children_per_face] = {
4165 {{0, 0}, {1, 1}, {0, 1}, {0, 1}},
4166 {{0, 1}, {0, 1}, {0, 0}, {1, 1}},
4167 {{0, 2}, {1, 3}, {0, 1}, {2, 3}}
4171 {{0, 0}, {1, 1}, {1, 0}, {1, 0}},
4172 {{1, 0}, {1, 0}, {0, 0}, {1, 1}},
4173 {{2, 0}, {3, 1}, {1, 0}, {3, 2}}
4176 return subcells[face_flip][ref_case - 1][face][subface];
4184 const unsigned int face,
4185 const unsigned int subface,
4186 const bool face_orientation,
4187 const bool face_flip,
4188 const bool face_rotation,
4191 const unsigned int dim = 3;
4196 if (!(subface == 0 &&
4234 (face_orientation == face_rotation) ? flip[face_ref_case] : face_ref_case;
4246 const unsigned int subface_exchange[4][2][2][2][4] = {
4249 {{{{0,
e,
e,
e}, {0,
e,
e,
e}}, {{0,
e,
e,
e}, {0,
e,
e,
e}}},
4250 {{{0,
e,
e,
e}, {0,
e,
e,
e}}, {{0,
e,
e,
e}, {0,
e,
e,
e}}}},
4264 {{{{0, 1,
e,
e}, {0, 1,
e,
e}}, {{1, 0,
e,
e}, {1, 0,
e,
e}}},
4265 {{{0, 1,
e,
e}, {0, 1,
e,
e}}, {{1, 0,
e,
e}, {1, 0,
e,
e}}}},
4268 {{{{0, 1,
e,
e}, {1, 0,
e,
e}}, {{1, 0,
e,
e}, {0, 1,
e,
e}}},
4269 {{{0, 1,
e,
e}, {1, 0,
e,
e}}, {{1, 0,
e,
e}, {0, 1,
e,
e}}}},
4291 const unsigned int std_subface =
4292 subface_exchange[face_ref_case][face_orientation][face_flip][face_rotation]
4304 [max_children_per_face] = {
4366 if ((std_face_ref & face_refinement_case(ref_case, face)) ==
4367 face_refinement_case(ref_case, face))
4376 const unsigned int equivalent_iso_subface[4][4] = {
4382 const unsigned int equ_std_subface =
4383 equivalent_iso_subface[std_face_ref][std_subface];
4386 return iso_children[ref_case - 1][face][equ_std_subface];
4393 ExcMessage(
"The face RefineCase is too coarse "
4394 "for the given cell RefineCase."));
4421 const unsigned int line,
4439 const unsigned int line,
4440 const bool face_orientation,
4441 const bool face_flip,
4442 const bool face_rotation)
4447 const unsigned lines[faces_per_cell][lines_per_face] = {
4454 return lines[face][real_to_standard_face_line(
4455 line, face_orientation, face_flip, face_rotation)];
4477 const unsigned int vertex,
4478 const bool face_orientation,
4479 const bool face_flip,
4480 const bool face_rotation)
4497 for (
unsigned int i = 0; i < dim; i++)
4512 double result = 0.0;
4514 for (
unsigned int i = 0; i < dim; i++)
4515 if ((-p[i]) > result)
4517 else if ((p[i] - 1.) > result)
4518 result = (p[i] - 1.);
4528 const unsigned int i)
4536 const double x = xi[0];
4549 const double x = xi[0];
4550 const double y = xi[1];
4554 return (1 - x) * (1 - y);
4567 const double x = xi[0];
4568 const double y = xi[1];
4569 const double z = xi[2];
4573 return (1 - x) * (1 - y) * (1 - z);
4575 return x * (1 - y) * (1 - z);
4577 return (1 - x) * y * (1 - z);
4579 return x * y * (1 - z);
4581 return (1 - x) * (1 - y) * z;
4583 return x * (1 - y) * z;
4585 return (1 - x) * y * z;
4603 const unsigned int i)
4623 const unsigned int i)
4627 const double x = xi[0];
4628 const double y = xi[1];
4632 return Point<2>(-(1 - y), -(1 - x));
4648 const unsigned int i)
4652 const double x = xi[0];
4653 const double y = xi[1];
4654 const double z = xi[2];
4658 return Point<3>(-(1 - y) * (1 - z),
4660 -(1 - x) * (1 - y));
4662 return Point<3>((1 - y) * (1 - z), -x * (1 - z), -x * (1 - y));
4664 return Point<3>(-y * (1 - z), (1 - x) * (1 - z), -(1 - x) * y);
4666 return Point<3>(y * (1 - z), x * (1 - z), -x * y);
4668 return Point<3>(-(1 - y) * z, -(1 - x) * z, (1 - x) * (1 - y));
4670 return Point<3>((1 - y) * z, -x * z, x * (1 - y));
4672 return Point<3>(-y * z, (1 - x) * z, (1 - x) * y);
4674 return Point<3>(y * z, x * z, x * y);
4700 namespace GeometryInfoHelper
4710 result[0] = derivative[0][1];
4711 result[1] = -derivative[0][0];
4734 for (
unsigned int i = 0; i < dim; ++i)
4735 jacobian[i] = derivative[i];
4744 template <
int spacedim>
4747 # ifndef DEAL_II_CONSTEXPR_BUG
4749 Tensor<spacedim - dim, spacedim> (&forms)[vertices_per_cell])
4783 for (
unsigned int i = 0; i < vertices_per_cell; ++i)
4787 for (
unsigned int j = 0; j < vertices_per_cell; ++j)
4790 d_linear_shape_function_gradient(unit_cell_vertex(i), j);
4791 for (
unsigned int l = 0;
l < dim; ++
l)
4792 derivatives[
l] +=
vertices[j] * grad_phi_j[
l];
4795 forms[i] = internal::GeometryInfoHelper::wedge_product(derivatives);