16 #ifndef dealii_geometry_info_h 17 #define dealii_geometry_info_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/exceptions.h> 22 #include <deal.II/base/point.h> 28 DEAL_II_NAMESPACE_OPEN
33 namespace GeometryInfoHelper
40 struct Initializers<1>
42 static constexpr std::array<unsigned int, 2> ucd_to_deal
45 static constexpr std::array<unsigned int, 2> unit_normal_direction
48 static constexpr std::array<int, 2> unit_normal_orientation
51 static constexpr std::array<unsigned int, 2> opposite_face
54 static constexpr std::array<unsigned int, 2> dx_to_deal
57 static constexpr std::array<std::array<unsigned int, 1>, 2> vertex_to_face
66 struct Initializers<2>
68 static constexpr std::array<unsigned int, 4> ucd_to_deal
71 static constexpr std::array<unsigned int, 4> unit_normal_direction
74 static constexpr std::array<int, 4> unit_normal_orientation
77 static constexpr std::array<unsigned int, 4> opposite_face
80 static constexpr std::array<unsigned int, 4> dx_to_deal
83 static constexpr std::array<std::array<unsigned int, 2>, 4> vertex_to_face
94 struct Initializers<3>
96 static constexpr std::array<unsigned int, 8> ucd_to_deal
97 {{ 0, 1, 5, 4, 2, 3, 7, 6}};
99 static constexpr std::array<unsigned int, 6> unit_normal_direction
100 {{ 0, 0, 1, 1, 2, 2 }};
102 static constexpr std::array<int, 6> unit_normal_orientation
103 {{ -1, 1, -1, 1, -1, 1 }};
105 static constexpr std::array<unsigned int, 6> opposite_face
106 {{ 1, 0, 3, 2, 5, 4 }};
108 static constexpr std::array<unsigned int, 8> dx_to_deal
109 {{ 0, 4, 2, 6, 1, 5, 3, 7}};
111 static constexpr std::array<std::array<unsigned int, 3>, 8> vertex_to_face
126 struct Initializers<4>
128 static constexpr std::array<unsigned int, 16> ucd_to_deal
150 static constexpr std::array<unsigned int, 8> unit_normal_direction
151 {{ 0, 0, 1, 1, 2, 2, 3, 3 }};
153 static constexpr std::array<int, 8> unit_normal_orientation
154 {{ -1, 1, -1, 1, -1, 1, -1, 1 }};
156 static constexpr std::array<unsigned int, 8> opposite_face
157 {{ 1, 0, 3, 2, 5, 4, 7, 6 }};
159 static constexpr std::array<unsigned int, 16> dx_to_deal
181 static constexpr std::array<std::array<unsigned int, 4>, 16> vertex_to_face
270 operator unsigned int ()
const;
479 cut_xy = cut_x | cut_y,
555 cut_xy = cut_x | cut_y,
563 cut_xz = cut_x | cut_z,
567 cut_yz = cut_y | cut_z,
571 cut_xyz = cut_x | cut_y | cut_z,
626 operator std::uint8_t ()
const;
667 template <
class Archive>
669 const unsigned int version);
676 <<
"The refinement flags given (" << arg1 <<
") contain set bits that do not " 677 <<
"make sense for the space dimension of the object to which they are applied.");
989 operator std::uint8_t ()
const;
1001 <<
"The subface case given (" << arg1 <<
") does not make sense " 1002 <<
"for the space dimension of the object to which they are applied.");
1009 std::uint8_t
value :
1143 static const std::array<unsigned int, vertices_per_cell>
dx_to_deal;
1771 static constexpr std::array<unsigned int, vertices_per_cell>
ucd_to_deal 1772 = internal::GeometryInfoHelper::Initializers<dim>::ucd_to_deal;
1787 static constexpr std::array<unsigned int, vertices_per_cell>
dx_to_deal 1788 = internal::GeometryInfoHelper::Initializers<dim>::dx_to_deal;
1801 = internal::GeometryInfoHelper::Initializers<dim>::vertex_to_face;
1831 const unsigned int subface_no);
1841 const unsigned int face_no,
1842 const bool face_orientation =
true,
1843 const bool face_flip =
false,
1844 const bool face_rotation =
false);
1855 const unsigned int face_no,
1856 const bool face_orientation =
true,
1857 const bool face_flip =
false,
1858 const bool face_rotation =
false);
1867 const unsigned int line_no);
1926 const unsigned int face,
1927 const unsigned int subface,
1928 const bool face_orientation =
true,
1929 const bool face_flip =
false,
1930 const bool face_rotation =
false,
1950 const unsigned int vertex);
1975 const unsigned int vertex,
1976 const bool face_orientation =
true,
1977 const bool face_flip =
false,
1978 const bool face_rotation =
false);
1994 const unsigned int line,
1995 const bool face_orientation =
true,
1996 const bool face_flip =
false,
1997 const bool face_rotation =
false);
2011 const bool face_orientation =
true,
2012 const bool face_flip =
false,
2013 const bool face_rotation =
false);
2027 const bool face_orientation =
true,
2028 const bool face_flip =
false,
2029 const bool face_rotation =
false);
2043 const bool face_orientation =
true,
2044 const bool face_flip =
false,
2045 const bool face_rotation =
false);
2059 const bool face_orientation =
true,
2060 const bool face_flip =
false,
2061 const bool face_rotation =
false);
2095 const unsigned int child_index,
2107 const unsigned int child_index,
2159 const unsigned int i);
2168 const unsigned int i);
2221 template <
int spacedim>
2224 #ifndef DEAL_II_CONSTEXPR_BUG 2229 Tensor<spacedim-dim,spacedim> *forms);
2242 = internal::GeometryInfoHelper::Initializers<dim>::unit_normal_direction;
2261 = internal::GeometryInfoHelper::Initializers<dim>::unit_normal_orientation;
2268 static constexpr std::array<unsigned int, faces_per_cell>
opposite_face 2269 = internal::GeometryInfoHelper::Initializers<dim>::opposite_face;
2277 <<
"The coordinates must satisfy 0 <= x_i <= 1, " 2278 <<
"but here we have x_i=" << arg1);
2285 <<
"RefinementCase<dim> " << arg1 <<
": face " << arg2
2286 <<
" has no subface " << arg3);
2302 const unsigned int i);
2307 const unsigned int i);
2312 const unsigned int i);
2331 object (static_cast<Object>(object_dimension))
2336 GeometryPrimitive::operator
unsigned int ()
const 2338 return static_cast<unsigned int>(object);
2350 value (subface_possibility)
2356 SubfaceCase<dim>::operator std::uint8_t ()
const 2371 return static_cast<std::uint8_t
>(-1);
2433 value (refinement_case)
2441 ExcInvalidRefinementCase (refinement_case));
2450 value (refinement_case)
2458 ExcInvalidRefinementCase (refinement_case));
2515 template <
class Archive>
2522 std::uint8_t uchar_value = value;
2524 value = uchar_value;
2535 Assert (vertex < vertices_per_cell,
2538 return Point<1>(
static_cast<double>(vertex));
2548 Assert (vertex < vertices_per_cell,
2551 return Point<2>(vertex%2, vertex/2);
2561 Assert (vertex < vertices_per_cell,
2564 return Point<3>(vertex%2, vertex/2%2, vertex/4);
2586 Assert ((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
2588 return (p[0] <= 0.5 ? 0 : 1);
2598 Assert ((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
2599 Assert ((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1]));
2601 return (p[0] <= 0.5 ?
2602 (p[1] <= 0.5 ? 0 : 2) :
2603 (p[1] <= 0.5 ? 1 : 3));
2613 Assert ((p[0] >= 0) && (p[0] <= 1), ExcInvalidCoordinate(p[0]));
2614 Assert ((p[1] >= 0) && (p[1] <= 1), ExcInvalidCoordinate(p[1]));
2615 Assert ((p[2] >= 0) && (p[2] <= 1), ExcInvalidCoordinate(p[2]));
2617 return (p[0] <= 0.5 ?
2619 (p[2] <= 0.5 ? 0 : 4) :
2620 (p[2] <= 0.5 ? 2 : 6)) :
2622 (p[2] <= 0.5 ? 1 : 5) :
2623 (p[2] <= 0.5 ? 3 : 7)));
2643 const unsigned int child_index,
2653 return Point<1>(p*2.0-unit_cell_vertex(child_index));
2662 const unsigned int child_index,
2670 switch (refine_case)
2684 point-=unit_cell_vertex(child_index);
2699 const unsigned int child_index,
2712 switch (refine_case)
2732 if (child_index%2==1)
2734 if (child_index/2==1)
2744 if (child_index/2==1)
2746 if (child_index%2==1)
2752 if (child_index%2==1)
2754 if (child_index/2==1)
2759 point-=unit_cell_vertex(child_index);
2774 const unsigned int ,
2788 const unsigned int child_index,
2798 return (p+unit_cell_vertex(child_index))*0.5;
2807 const unsigned int child_index,
2820 switch (refine_case)
2838 if (child_index%2==1)
2840 if (child_index/2==1)
2850 if (child_index/2==1)
2852 if (child_index%2==1)
2858 if (child_index%2==1)
2860 if (child_index/2==1)
2866 point+=unit_cell_vertex(child_index);
2882 const unsigned int child_index,
2889 switch (refine_case)
2902 point+=unit_cell_vertex(child_index);
2918 const unsigned int ,
2941 return (p[0] >= 0.) && (p[0] <= 1.);
2951 return (p[0] >= 0.) && (p[0] <= 1.) &&
2952 (p[1] >= 0.) && (p[1] <= 1.);
2962 return (p[0] >= 0.) && (p[0] <= 1.) &&
2963 (p[1] >= 0.) && (p[1] <= 1.) &&
2964 (p[2] >= 0.) && (p[2] <= 1.);
2985 return (p[0] >= -eps) && (p[0] <= 1.+
eps);
2996 const double l = -
eps, u = 1+
eps;
2997 return (p[0] >= l) && (p[0] <= u) &&
2998 (p[1] >= l) && (p[1] <= u);
3009 const double l = -
eps, u = 1.0+
eps;
3010 return (p[0] >= l) && (p[0] <= u) &&
3011 (p[1] >= l) && (p[1] <= u) &&
3012 (p[2] >= l) && (p[2] <= u);
3021 const unsigned int vertex)
3035 const unsigned int vertex)
3037 constexpr
unsigned int cell_vertices[4][2] = {{0,2},{1,3},{0,1},{2,3}};
3038 return cell_vertices[line][vertex];
3047 const unsigned int vertex)
3053 vertices[lines_per_cell][2] = {{0, 2},
3066 return vertices[line][vertex];
3084 const bool face_orientation,
3085 const bool face_flip,
3086 const bool face_rotation)
3109 constexpr
unsigned int vertex_translation[4][2][2][2] =
3144 return vertex_translation[vertex][face_orientation][face_flip][face_rotation];
3169 {0, 2, 2, 4, 2, 4, 4, 8};
3171 return n_children[ref_case];
3210 {0, 2, 3, 3, 4, 2, 3, 3, 4, 4};
3211 return nsubs[subface_case];
3243 switch (subface_case)
3281 const unsigned int subface_no)
3284 switch (subface_case)
3368 const unsigned int face_no,
3373 const unsigned int dim=2;
3403 return ref_cases[cell_refinement_case][face_no/2];
3411 const unsigned int face_no,
3412 const bool face_orientation,
3414 const bool face_rotation)
3416 const unsigned int dim=3;
3474 const RefinementCase<dim-1> ref_case=ref_cases[cell_refinement_case][face_no/2];
3496 return (face_orientation==face_rotation) ? flip[ref_case] : ref_case;
3515 const unsigned int line_no)
3518 const unsigned int dim = 1;
3525 return cell_refinement_case;
3533 const unsigned int line_no)
3536 return face_refinement_case(cell_refinement_case, line_no);
3544 const unsigned int line_no)
3546 const unsigned int dim=3;
3568 const unsigned int direction[lines_per_cell]=
3569 {1,1,0,0,1,1,0,0,2,2,2,2};
3571 return ((cell_refinement_case & cut_one[direction[line_no]]) ?
3600 const unsigned int dim = 1;
3611 const unsigned int face_no,
3616 const unsigned int dim = 2;
3633 const unsigned int face_no,
3634 const bool face_orientation,
3636 const bool face_rotation)
3638 const unsigned int dim=3;
3665 const RefinementCase<dim-1> std_face_ref = (face_orientation==face_rotation) ? flip[face_refinement_case] : face_refinement_case;
3691 return face_to_cell[face_no/2][std_face_ref];
3723 const unsigned int dim = 2;
3737 const unsigned int dim=3;
3751 return ref_cases[line_no/2];
3760 const bool face_orientation,
3761 const bool face_flip,
3762 const bool face_rotation)
3785 const unsigned int vertex_translation[4][2][2][2] =
3820 return vertex_translation[vertex][face_orientation][face_flip][face_rotation];
3845 const bool face_orientation,
3846 const bool face_flip,
3847 const bool face_rotation)
3870 const unsigned int line_translation[4][2][2][2] =
3905 return line_translation[line][face_orientation][face_flip][face_rotation];
3928 const bool face_orientation,
3929 const bool face_flip,
3930 const bool face_rotation)
3953 const unsigned int line_translation[4][2][2][2] =
3988 return line_translation[line][face_orientation][face_flip][face_rotation];
4011 const unsigned int face,
4012 const unsigned int subface,
4013 const bool,
const bool,
const bool,
4018 Assert (subface<max_children_per_face,
4030 const unsigned int face,
4031 const unsigned int subface,
4033 const bool face_flip,
4038 Assert (subface<max_children_per_face,
4053 {{0,0},{1,1},{0,1},{0,1}},
4054 {{0,1},{0,1},{0,0},{1,1}},
4055 {{0,2},{1,3},{0,1},{2,3}}
4059 {{0,0},{1,1},{1,0},{1,0}},
4060 {{1,0},{1,0},{0,0},{1,1}},
4061 {{2,0},{3,1},{1,0},{3,2}}
4065 return subcells[face_flip][ref_case-1][face][subface];
4074 const unsigned int face,
4075 const unsigned int subface,
4076 const bool face_orientation,
4077 const bool face_flip,
4078 const bool face_rotation,
4081 const unsigned int dim = 3;
4121 const RefinementCase<dim-1> std_face_ref = (face_orientation==face_rotation) ? flip[face_ref_case] : face_ref_case;
4133 const unsigned int subface_exchange[4][2][2][2][4]=
4218 const unsigned int std_subface=subface_exchange
4305 if ((std_face_ref & face_refinement_case(ref_case, face))
4306 == face_refinement_case(ref_case, face))
4315 const unsigned int equivalent_iso_subface[4][4]=
4323 const unsigned int equ_std_subface
4324 =equivalent_iso_subface[std_face_ref][std_subface];
4327 return iso_children[ref_case-1][face][equ_std_subface];
4334 ExcMessage(
"The face RefineCase is too coarse " 4335 "for the given cell RefineCase."));
4349 const bool,
const bool,
const bool,
4362 const unsigned int line,
4363 const bool,
const bool,
const bool)
4381 const unsigned int line,
4382 const bool,
const bool,
const bool)
4398 const unsigned int line,
4399 const bool face_orientation,
4400 const bool face_flip,
4401 const bool face_rotation)
4407 lines[faces_per_cell][lines_per_face] = {{8,10, 0, 4},
4414 return lines[face][real_to_standard_face_line(line,
4427 const bool,
const bool,
const bool)
4439 const unsigned int vertex,
4440 const bool face_orientation,
4441 const bool face_flip,
4442 const bool face_rotation)
4445 face_orientation, face_flip, face_rotation);
4456 for (
unsigned int i=0; i<dim; i++)
4457 if (p[i] < 0.) p[i] = 0.;
4458 else if (p[i] > 1.) p[i] = 1.;
4470 double result = 0.0;
4472 for (
unsigned int i=0; i<dim; i++)
4473 if ((-p[i]) > result)
4475 else if ((p[i]-1.) > result)
4476 result = (p[i] - 1.);
4488 const unsigned int i)
4497 const double x = xi[0];
4510 const double x = xi[0];
4511 const double y = xi[1];
4528 const double x = xi[0];
4529 const double y = xi[1];
4530 const double z = xi[2];
4534 return (1-x)*(1-y)*(1-z);
4536 return x*(1-y)*(1-z);
4538 return (1-x)*y*(1-z);
4542 return (1-x)*(1-y)*z;
4566 const unsigned int i)
4589 const unsigned int i)
4594 const double x = xi[0];
4595 const double y = xi[1];
4617 const unsigned int i)
4622 const double x = xi[0];
4623 const double y = xi[1];
4624 const double z = xi[2];
4659 return Point<3> (-1e9, -1e9, -1e9);
4686 namespace GeometryInfoHelper
4694 wedge_product (
const Tensor<1,2> (&derivative)[1])
4697 result[0] = derivative[0][1];
4698 result[1] = -derivative[0][0];
4708 wedge_product (
const Tensor<1,3> (&derivative)[2])
4710 return cross_product_3d (derivative[0], derivative[1]);
4723 for (
unsigned int i=0; i<dim; ++i)
4724 jacobian[i] = derivative[i];
4733 template <
int spacedim>
4737 alternating_form_at_vertices
4738 #ifndef DEAL_II_CONSTEXPR_BUG 4775 for (
unsigned int i=0; i<vertices_per_cell; ++i)
4779 for (
unsigned int j=0; j<vertices_per_cell; ++j)
4782 = d_linear_shape_function_gradient (unit_cell_vertex(i),
4784 for (
unsigned int l=0;
l<dim; ++
l)
4785 derivatives[l] += vertices[j] * grad_phi_j[l];
4788 forms[i] = internal::GeometryInfoHelper::wedge_product (derivatives);
4793 DEAL_II_NAMESPACE_CLOSE
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 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 const unsigned int invalid_unsigned_int
static constexpr unsigned int vertices_per_face
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)
Number determinant(const SymmetricTensor< 2, dim, Number > &)
static unsigned int child_cell_from_point(const Point< dim > &p)
static constexpr std::array< unsigned int, vertices_per_cell > ucd_to_deal
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 RefinementCase< 1 > line_refinement_case(const RefinementCase< dim > &cell_refinement_case, const unsigned int line_no)
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 constexpr unsigned int max_children_per_face
static constexpr unsigned int max_children_per_cell
static bool is_inside_unit_cell(const Point< dim > &p)
GeometryPrimitive(const Object object)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Point< spacedim > point(const gp_Pnt &p, const double &tolerance=1e-10)
void serialize(Archive &ar, const unsigned int version)
static unsigned int line_to_cell_vertices(const unsigned int line, const unsigned int vertex)
static constexpr unsigned int quads_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 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 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 Point< dim > unit_cell_vertex(const unsigned int vertex)
static constexpr std::size_t memory_consumption()
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
static ::ExceptionBase & ExcInvalidSubfaceCase(int arg1)
static const std::array< unsigned int, vertices_per_cell > ucd_to_deal
static constexpr unsigned int vertices_per_cell
RefinementCase operator~() const
static constexpr std::array< unsigned int, vertices_per_cell > dx_to_deal
static Tensor< 1, dim > d_linear_shape_function_gradient(const Point< dim > &xi, const unsigned int i)
static double distance_to_unit_cell(const Point< dim > &p)
static ::ExceptionBase & ExcMessage(std::string arg1)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
static ::ExceptionBase & ExcInvalidSubface(int arg1, int arg2, int arg3)
RefinementCase operator|(const RefinementCase &r) const
static constexpr std::array< unsigned int, faces_per_cell > unit_normal_direction
#define DeclException1(Exception1, type1, outsequence)
static constexpr unsigned int lines_per_cell
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)
#define Assert(cond, exc)
static constexpr unsigned int faces_per_cell
static constexpr unsigned int hexes_per_cell
static ::ExceptionBase & ExcInvalidCoordinate(double arg1)
RefinementCase operator&(const RefinementCase &r) const
static std::size_t memory_consumption()
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 unsigned int n_children(const RefinementCase< dim > &refinement_case)
static void alternating_form_at_vertices(const Point< spacedim >(&vertices)[vertices_per_cell], Tensor< spacedim-dim, spacedim >(&forms)[vertices_per_cell])
static Point< dim > project_to_unit_cell(const Point< dim > &p)
SubfaceCase(const typename SubfacePossibilities< dim >::Possibilities subface_possibility)
static constexpr unsigned int quads_per_cell
static const std::array< unsigned int, vertices_per_cell > dx_to_deal
static constexpr std::array< int, faces_per_cell > unit_normal_orientation
static double d_linear_shape_function(const Point< dim > &xi, const unsigned int i)
static constexpr unsigned int lines_per_face
static unsigned int n_subfaces(const internal::SubfaceCase< dim > &subface_case)
static ::ExceptionBase & ExcNotImplemented()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
static constexpr std::array< unsigned int, faces_per_cell > opposite_face
static ::ExceptionBase & ExcInvalidRefinementCase(int arg1)
static double subface_ratio(const internal::SubfaceCase< dim > &subface_case, const unsigned int subface_no)
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 RefinementCase cut_axis(const unsigned int i)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
static constexpr std::array< std::array< unsigned int, dim >, vertices_per_cell > vertex_to_face
static ::ExceptionBase & ExcInternalError()