16#ifndef dealii_tria_reference_cell_h
17#define dealii_tria_reference_cell_h
28#include <boost/container/small_vector.hpp>
37template <
int dim,
int spacedim>
170 const unsigned int i)
const;
181 template <
int dim,
int spacedim = dim>
182 std::unique_ptr<Mapping<dim, spacedim>>
196 template <
int dim,
int spacedim = dim>
275 vertex(
const unsigned int v)
const;
356 static constexpr unsigned char
369 static constexpr unsigned char
415 const unsigned int subface,
416 const unsigned char face_orientation =
428 std::array<unsigned int, 2>
440 std::array<unsigned int, 2>
453 const unsigned int vertex)
const;
460 const unsigned int line,
461 const unsigned char face_orientation)
const;
468 const unsigned int vertex,
469 const unsigned char face_orientation)
const;
493 const unsigned int vertex)
const;
500 const unsigned int face,
501 const unsigned char face_orientation)
const;
508 const unsigned int face,
509 const unsigned char face_orientation)
const;
523 const unsigned char face_orientation,
524 const bool line_orientation)
const;
609 const unsigned int i)
const;
642 template <
typename T, std::
size_t N>
643 DEAL_II_DEPRECATED_EARLY
unsigned char
645 const std::array<T, N> &vertices_1)
const;
672 template <
typename T>
691 template <
typename T, std::
size_t N>
692 DEAL_II_DEPRECATED_EARLY std::array<T, N>
694 const unsigned int orientation)
const;
707 template <
typename T>
708 boost::container::small_vector<T, 8>
710 const unsigned char orientation)
const;
780 const std::array<unsigned, dim> &node_indices,
781 const std::array<unsigned, dim> &nodes_per_direction,
782 const bool legacy_format)
const;
815 constexpr operator std::uint8_t()
const;
834 template <
class Archive>
836 serialize(Archive &archive,
const unsigned int );
841 static constexpr std::size_t
866 {{{1, 0}}, {{0, 1}}}};
900 friend std::ostream &
903 friend std::istream &
935inline constexpr ReferenceCell::operator std::uint8_t()
const
963#ifndef DEAL_II_CXX14_CONSTEXPR_BUG
966 Assert((kind == std::numeric_limits<std::uint8_t>::max()) || (kind < 8),
1005 std::numeric_limits<std::uint8_t>::max());
1034template <
class Archive>
1043inline constexpr std::size_t
1064 {{{0, 2}}, {{0, 1}}, {{1, 2}}}};
1070 {{{0, 1, 2}}, {{0, 1, 3}}, {{0, 2, 3}}, {{1, 2, 3}}}};
1160 std::vector<double>({
volume()}));
1477inline constexpr unsigned char
1488inline constexpr unsigned char
1500 const unsigned int face,
1501 const unsigned int subface,
1502 const unsigned char combined_face_orientation)
const
1518 {{{0, 1}}, {{1, 2}}, {{2, 0}}}};
1520 return subcells[face][subface];
1524 const bool face_orientation =
1526 const bool face_flip =
1528 const bool face_rotation =
1548 const bool face_orientation =
1550 const bool face_flip =
1552 const bool face_rotation =
1572inline std::array<unsigned int, 2>
1574 const unsigned int vertex)
const
1590 {{{0, 0}}, {{0, 1}}, {{1, 1}}, {{X, X}}, {{X, X}}, {{X, X}}}};
1602 {{{0, 0}}, {{0, 1}}, {{0, 2}}, {{1, 2}}, {{X, X}}, {{X, X}}}};
1609 {{{0, 0}}, {{0, 1}}, {{0, 2}}, {{0, 3}}, {{1, 2}}, {{X, X}}}};
1616 {{{0, 1}}, {{0, 0}}, {{0, 2}}, {{1, 0}}, {{1, 1}}, {{1, 2}}}};
1634inline std::array<unsigned int, 2>
1636 const unsigned int line)
const
1652 static const std::array<unsigned int, 2> table[6] = {
1653 {{0, 0}}, {{0, 1}}, {{0, 2}}, {{1, 1}}, {{1, 2}}, {{2, 1}}};
1659 static const std::array<unsigned int, 2> table[8] = {{{0, 0}},
1672 static const std::array<unsigned int, 2> table[9] = {{{0, 0}},
1698 const unsigned int vertex)
const
1711 {{{0, 1}}, {{1, 2}}, {{2, 0}}}};
1712 return table[line][
vertex];
1717 {{{0, 2}}, {{1, 3}}, {{0, 1}}, {{2, 3}}}};
1718 return table[line][
vertex];
1723 {{{0, 1}}, {{1, 2}}, {{2, 0}}, {{0, 3}}, {{1, 3}}, {{2, 3}}}};
1724 return table[line][
vertex];
1736 return table[line][
vertex];
1749 return table[line][
vertex];
1767 return table[line][
vertex];
1780 const unsigned int line,
1781 const unsigned char face_orientation)
const
1820 {{{0, 1, 2}}, {{0, 3, 4}}, {{2, 5, 3}}, {{1, 4, 5}}}};
1823 line, face, face_orientation)];
1835 line, face, face_orientation)];
1847 line, face, face_orientation)];
1869 const unsigned int vertex,
1870 const unsigned char face_orientation)
const
1894 {{{0, 1}}, {{1, 2}}, {{2, 0}}}};
1896 return table[face][face_orientation != 0u ?
vertex : (1 -
vertex)];
1910 {{{0, 1, 2}}, {{1, 0, 3}}, {{0, 2, 3}}, {{2, 1, 3}}}};
1913 vertex, face, face_orientation)];
1926 vertex, face, face_orientation)];
1939 vertex, face, face_orientation)];
1962 const unsigned int vertex)
const
1989 return table[face][
vertex];
1999 return table[face][
vertex];
2017 return table[face][
vertex];
2024 static const std::array<std::vector<Point<dim>>, 5> table = {
2042 return table[face][
vertex];
2049 static const std::array<std::vector<Point<dim>>, 5> table = {
2069 return table[face][
vertex];
2154 return table[face][
vertex];
2167 const unsigned int vertex,
2168 const unsigned int face,
2169 const unsigned char face_orientation)
const
2211 const unsigned int line,
2212 const unsigned int face,
2213 const unsigned char face_orientation)
const
2235 return triangle_table[face_orientation][line];
2247 return triangle_table[face_orientation][line];
2259 return triangle_table[face_orientation][line];
2271 return table[face_orientation][line];
2361 ExcMessage(
"The combination of dim = " + std::to_string(dim) +
2362 " and n_vertices = " + std::to_string(
n_vertices) +
2363 " does not correspond to a known reference cell type."));
2372 const unsigned int i)
const
2389 return 1.0 - xi[
std::min(0, dim - 1)] -
2405 return 1.0 - xi[
std::min(0, dim - 1)] -
2420 const double Q14 = 0.25;
2422 const double r = xi[
std::min(0, dim - 1)];
2423 const double s = xi[
std::min(1, dim - 1)];
2424 const double t = xi[
std::min(2, dim - 1)];
2426 const double ratio =
2427 (std::fabs(t - 1.0) > 1.0e-14 ? (r * s * t) / (1.0 - t) : 0.0);
2430 return Q14 * ((1.0 - r) * (1.0 - s) - t + ratio);
2432 return Q14 * ((1.0 + r) * (1.0 - s) - t - ratio);
2434 return Q14 * ((1.0 - r) * (1.0 + s) - t - ratio);
2436 return Q14 * ((1.0 + r) * (1.0 + s) - t + ratio);
2461 const unsigned int i)
const
2540 return Point<dim>(1. / 4., 1. / 4., 1. / 4.);
2546 return Point<dim>(1. / 2., 1. / 2., 1. / 2.);
2565 constexpr unsigned int x_coordinate = 0;
2566 constexpr unsigned int y_coordinate = (dim >= 2 ? 1 : 0);
2567 constexpr unsigned int z_coordinate = (dim >= 3 ? 2 : 0);
2577 ExcMessage(
"Vertices are zero-dimensional objects and "
2578 "as a consequence have no coordinates. You "
2579 "cannot meaningfully ask whether a point is "
2580 "inside a vertex (within a certain tolerance) "
2581 "without coordinate values."));
2588 for (
unsigned int d = 0; d < dim; ++d)
2589 if ((p[d] < -tolerance) || (p[d] > 1 + tolerance))
2597 for (
unsigned int d = 0; d < dim; ++d)
2598 if (p[d] < -tolerance)
2610 for (
unsigned int d = 0; d < dim; ++d)
2612 return (sum <= 1 + tolerance *
std::sqrt(1. * dim));
2617 if (p[z_coordinate] < -tolerance)
2621 if (p[z_coordinate] > 1 + tolerance)
2628 const double distance_from_axis =
2629 std::max(std::fabs(p[x_coordinate]), std::fabs(p[y_coordinate]));
2633 return (distance_from_axis <= 1 + tolerance - p[z_coordinate]);
2642 if ((p[x_coordinate] < -tolerance) || (p[y_coordinate] < -tolerance))
2645 const double sum = p[x_coordinate] + p[y_coordinate];
2646 if (sum > 1 + tolerance *
std::sqrt(2.0))
2649 if (p[z_coordinate] < -tolerance)
2651 if (p[z_coordinate] > 1 + tolerance)
2668 const unsigned int i)
const
2684 static const std::array<Tensor<1, dim>, 3> table = {
2689 return table[face_no];
2703 +
std::pow(1.0 / 3.0, 1.0 / 4.0))}}}};
2705 return table[face_no][i];
2712 {{
Point<dim>(+1.0 / sqrt(2.0), 0, +1.0 / sqrt(2.0)),
2714 {{
Point<dim>(+1.0 / sqrt(2.0), 0, -1.0 / sqrt(2.0)),
2717 Point<dim>(0, +1.0 / sqrt(2.0), +1.0 / sqrt(2.0))}},
2719 Point<dim>(0, +1.0 / sqrt(2.0), -1.0 / sqrt(2.0))}}}};
2721 return table[face_no][i];
2734 return table[face_no][i];
2762 return cross_product_2d(unit_tangential_vectors<dim>(face_no, 0));
2766 return cross_product_3d(unit_tangential_vectors<dim>(face_no, 0),
2767 unit_tangential_vectors<dim>(face_no, 1));
2798 const unsigned int line,
2799 const unsigned char combined_face_orientation,
2800 const bool line_orientation)
const
2804 static constexpr ::ndarray<bool, 2, 8> bool_table{
2805 {{{
true,
true,
false,
true,
false,
false,
true,
false}},
2806 {{
true,
true,
true,
false,
false,
false,
false,
true}}}};
2808 return (line_orientation ==
2809 bool_table[line / 2][combined_face_orientation]);
2821 template <
typename T>
2854 for (
unsigned int i = 0; i < n_vertices; ++i)
2857 if (i + 1 != n_vertices)
2861 out <<
"] is not a valid permutation of [";
2863 for (
unsigned int i = 0; i < n_vertices; ++i)
2866 if (i + 1 != n_vertices)
2870 out <<
"]." << std::endl;
2892template <
typename T, std::
size_t N>
2895 const std::array<T, N> &vertices_1)
const
2898 ExcMessage(
"The number of array elements must be equal to or "
2899 "greater than the number of vertices of the cell "
2900 "referenced by this object."));
2913template <
typename T>
2920 ExcMessage(
"The number of array elements must be equal to "
2921 "the number of vertices of the cell "
2922 "referenced by this object."));
2924 ExcMessage(
"The number of array elements must be equal to "
2925 "the number of vertices of the cell "
2926 "referenced by this object."));
2928 const auto v0_equals = [&](
const std::initializer_list<const T> &list) {
2930 return std::equal(vertices_0.
begin(), vertices_0.
end(), std::begin(list));
2937 if (v0_equals({vertices_1[0], vertices_1[1]}))
2941 if (v0_equals({vertices_1[1], vertices_1[0]}))
2946 if (v0_equals({vertices_1[0], vertices_1[1], vertices_1[2]}))
2950 if (v0_equals({vertices_1[1], vertices_1[2], vertices_1[0]}))
2954 if (v0_equals({vertices_1[2], vertices_1[0], vertices_1[1]}))
2958 if (v0_equals({vertices_1[0], vertices_1[2], vertices_1[1]}))
2962 if (v0_equals({vertices_1[2], vertices_1[1], vertices_1[0]}))
2966 if (v0_equals({vertices_1[1], vertices_1[0], vertices_1[2]}))
2972 {vertices_1[0], vertices_1[1], vertices_1[2], vertices_1[3]}))
2977 {vertices_1[2], vertices_1[0], vertices_1[3], vertices_1[1]}))
2982 {vertices_1[3], vertices_1[2], vertices_1[1], vertices_1[0]}))
2987 {vertices_1[1], vertices_1[3], vertices_1[0], vertices_1[2]}))
2992 {vertices_1[0], vertices_1[2], vertices_1[1], vertices_1[3]}))
2997 {vertices_1[2], vertices_1[3], vertices_1[0], vertices_1[1]}))
3002 {vertices_1[3], vertices_1[1], vertices_1[2], vertices_1[0]}))
3007 {vertices_1[1], vertices_1[0], vertices_1[3], vertices_1[2]}))
3015 return std::numeric_limits<unsigned char>::max();
3020template <
typename T, std::
size_t N>
3021inline std::array<T, N>
3024 const unsigned int orientation)
const
3027 ExcMessage(
"The number of array elements must be equal to or "
3028 "greater than the number of vertices of the cell "
3029 "referenced by this object."));
3039 std::array<T, N> temp;
3040 std::copy(permutation.begin(), permutation.end(), temp.begin());
3047template <
typename T>
3048boost::container::small_vector<T, 8>
3051 const unsigned char orientation)
const
3054 ExcMessage(
"The number of array elements must be equal to "
3055 "the number of vertices of the cell "
3056 "referenced by this object."));
3061 switch (orientation)
3072 switch (orientation)
3091 switch (orientation)
3124ReferenceCell::vtk_lexicographic_to_node_index<0>(
3125 const std::array<unsigned, 0> &node_indices,
3126 const std::array<unsigned, 0> &nodes_per_direction,
3127 const bool legacy_format)
const;
3131ReferenceCell::vtk_lexicographic_to_node_index<1>(
3132 const std::array<unsigned, 1> &node_indices,
3133 const std::array<unsigned, 1> &nodes_per_direction,
3134 const bool legacy_format)
const;
3138ReferenceCell::vtk_lexicographic_to_node_index<2>(
3139 const std::array<unsigned, 2> &node_indices,
3140 const std::array<unsigned, 2> &nodes_per_direction,
3141 const bool legacy_format)
const;
3145ReferenceCell::vtk_lexicographic_to_node_index<3>(
3146 const std::array<unsigned, 3> &node_indices,
3147 const std::array<unsigned, 3> &nodes_per_direction,
3148 const bool legacy_format)
const;
ArrayView< typename std::remove_reference< typename std::iterator_traits< Iterator >::reference >::type, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
Abstract base class for mapping classes.
static Point< dim, Number > unit_vector(const unsigned int i)
ArrayView< const unsigned int > faces_for_given_vertex(const unsigned int vertex_index) const
unsigned int child_cell_on_face(const unsigned int face, const unsigned int subface, const unsigned char face_orientation=default_combined_face_orientation()) const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices() const
unsigned int n_vertices() const
boost::container::small_vector< T, 8 > permute_by_combined_orientation(const ArrayView< const T > &vertices, const unsigned char orientation) const
Quadrature< dim > get_gauss_type_quadrature(const unsigned n_points_1d) const
bool is_hyper_cube() const
unsigned int vtk_linear_type() const
void serialize(Archive &archive, const unsigned int)
unsigned int face_to_cell_vertices(const unsigned int face, const unsigned int vertex, const unsigned char face_orientation) const
static constexpr unsigned char default_combined_face_orientation()
unsigned char compute_orientation(const std::array< T, N > &vertices_0, const std::array< T, N > &vertices_1) const
std::array< unsigned int, 2 > standard_vertex_to_face_and_vertex_index(const unsigned int vertex) const
bool standard_vs_true_line_orientation(const unsigned int line, const unsigned char face_orientation, const bool line_orientation) const
Point< dim > vertex(const unsigned int v) const
unsigned int standard_to_real_face_vertex(const unsigned int vertex, const unsigned int face, const unsigned char face_orientation) const
const Quadrature< dim > & get_nodal_type_quadrature() const
Point< dim > face_vertex_location(const unsigned int face, const unsigned int vertex) const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > isotropic_child_indices() const
std::array< unsigned int, 2 > standard_line_to_face_and_line_index(const unsigned int line) const
double d_linear_shape_function(const Point< dim > &xi, const unsigned int i) const
Tensor< 1, dim > unit_tangential_vectors(const unsigned int face_no, const unsigned int i) const
static constexpr ndarray< unsigned int, 2, 2 > line_vertex_permutations
unsigned int vtk_lexicographic_to_node_index(const std::array< unsigned, dim > &node_indices, const std::array< unsigned, dim > &nodes_per_direction, const bool legacy_format) const
std::array< T, N > permute_according_orientation(const std::array< T, N > &vertices, const unsigned int orientation) const
bool contains_point(const Point< dim > &p, const double tolerance=0) const
unsigned int n_isotropic_children() const
unsigned int gmsh_element_type() const
unsigned int n_face_orientations(const unsigned int face_no) const
static constexpr ndarray< unsigned int, 8, 4 > quadrilateral_vertex_permutations
unsigned int n_faces() const
unsigned int line_to_cell_vertices(const unsigned int line, const unsigned int vertex) const
constexpr ReferenceCell()
unsigned int exodusii_vertex_to_deal_vertex(const unsigned int vertex_n) const
unsigned int unv_vertex_to_deal_vertex(const unsigned int vertex_n) const
unsigned int vtk_vertex_to_deal_vertex(const unsigned int vertex_index) const
std::unique_ptr< Mapping< dim, spacedim > > get_default_mapping(const unsigned int degree) const
Quadrature< dim > get_midpoint_quadrature() const
unsigned int vtk_quadratic_type() const
static constexpr unsigned char reversed_combined_line_orientation()
unsigned int n_lines() const
unsigned int vtk_lagrange_type() const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > line_indices() const
unsigned int get_dimension() const
ReferenceCell face_reference_cell(const unsigned int face_no) const
unsigned int exodusii_face_to_deal_face(const unsigned int face_n) const
static ReferenceCell n_vertices_to_type(const int dim, const unsigned int n_vertices)
unsigned int standard_to_real_face_line(const unsigned int line, const unsigned int face, const unsigned char face_orientation) const
static constexpr std::size_t memory_consumption()
friend std::istream & operator>>(std::istream &in, ReferenceCell &reference_cell)
const Mapping< dim, spacedim > & get_default_linear_mapping() const
std::string to_string() const
unsigned int face_to_cell_lines(const unsigned int face, const unsigned int line, const unsigned char face_orientation) const
constexpr bool operator!=(const ReferenceCell &type) const
unsigned char get_combined_orientation(const ArrayView< const T > &vertices_0, const ArrayView< const T > &vertices_1) const
constexpr bool operator==(const ReferenceCell &type) const
Point< dim > barycenter() const
Tensor< 1, dim > unit_normal_vectors(const unsigned int face_no) const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices() const
friend std::ostream & operator<<(std::ostream &out, const ReferenceCell &reference_cell)
Point< dim > closest_point(const Point< dim > &p) const
static constexpr ndarray< unsigned int, 6, 3 > triangle_vertex_permutations
Tensor< 1, dim > d_linear_shape_function_gradient(const Point< dim > &xi, const unsigned int i) const
virtual void print_info(std::ostream &out) const override
const ReferenceCell entity_type
virtual ~NoPermutation() noexcept override=default
const ArrayView< const T > vertices_0
const ArrayView< const T > vertices_1
NoPermutation(const ReferenceCell &entity_type, const ArrayView< const T > &vertices_0, const ArrayView< const T > &vertices_1)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
constexpr const ReferenceCell Tetrahedron
constexpr const ReferenceCell Quadrilateral
constexpr const ReferenceCell Wedge
constexpr const ReferenceCell Pyramid
constexpr const ReferenceCell Invalid
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Hexahedron
constexpr const ReferenceCell & get_hypercube()
constexpr const ReferenceCell Vertex
constexpr const ReferenceCell Line
constexpr const ReferenceCell & get_simplex()
bool get_bit(const unsigned char number, const unsigned int n)
constexpr ReferenceCell make_reference_cell_from_int(const std::uint8_t kind)
static const unsigned int invalid_unsigned_int
boost::integer_range< IncrementableType > iota_view
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
typename internal::ndarray::HelperArray< T, Ns... >::type ndarray
std::istream & operator>>(std::istream &in, ReferenceCell &reference_cell)
std::ostream & operator<<(std::ostream &out, const ReferenceCell &reference_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)
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, 2 > standard_hex_line_to_quad_line_index(const unsigned int line)
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::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 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 Tensor< 1, dim > d_linear_shape_function_gradient(const Point< dim > &xi, const unsigned int i)