From: Wolfgang Bangerth Date: Tue, 9 Feb 2021 14:20:28 +0000 (-0700) Subject: Move two conversion functions from internal::ReferenceCell::Base to ReferenceCell. X-Git-Tag: v9.3.0-rc1~464^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09ebed8b7793ad998ce75ca8a51d0973ed396d41;p=dealii.git Move two conversion functions from internal::ReferenceCell::Base to ReferenceCell. --- diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 7af95cb45e..ef703d929e 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -272,12 +272,46 @@ public: ReferenceCell face_reference_cell(const unsigned int face_no) const; + /** + * @} + */ + + /** + * @name Relationships between objects in the cell and on faces + * @{ + */ + + /** + * For a given vertex in a cell, return a pair of a face index and a + * vertex index within this face. + * + * @note In practice, a vertex is of course generally part of more than one + * face, and one could return different faces and the corresponding + * index within. Which face this function chooses is often not of + * importance (and not exposed by this function on purpose). + */ + std::array + standard_vertex_to_face_and_vertex_index(const unsigned int vertex) const; + + /** + * For a given line in a cell, return a pair of a face index and a + * line index within this face. + * + * @note In practice, a line is of course generally part of more than one + * face, and one could return different faces and the corresponding + * index within. Which face this function chooses is often not of + * importance (and not exposed by this function on purpose). + */ + std::array + standard_line_to_face_and_line_index(const unsigned int line) const; + /** * @} */ /** * @name Geometric properties of reference cells + * @name Querying the number of building blocks of a reference cell * @{ */ @@ -759,6 +793,132 @@ ReferenceCell::face_reference_cell(const unsigned int face_no) const +inline std::array +ReferenceCell::standard_vertex_to_face_and_vertex_index( + const unsigned int vertex) const +{ + AssertIndexRange(vertex, n_vertices()); + + if (*this == ReferenceCells::Vertex) + { + Assert(false, ExcNotImplemented()); + } + else if (*this == ReferenceCells::Line) + { + Assert(false, ExcNotImplemented()); + } + else if (*this == ReferenceCells::Triangle) + { + static const std::array, 3> table = { + {{{0, 0}}, {{0, 1}}, {{1, 1}}}}; + + return table[vertex]; + } + else if (*this == ReferenceCells::Quadrilateral) + { + return GeometryInfo<2>::standard_quad_vertex_to_line_vertex_index(vertex); + } + else if (*this == ReferenceCells::Tetrahedron) + { + static const std::array table[4] = {{{0, 0}}, + {{0, 1}}, + {{0, 2}}, + {{1, 2}}}; + + return table[vertex]; + } + else if (*this == ReferenceCells::Pyramid) + { + static const std::array table[5] = { + {{0, 0}}, {{0, 1}}, {{0, 2}}, {{0, 3}}, {{1, 2}}}; + + return table[vertex]; + } + else if (*this == ReferenceCells::Wedge) + { + static const std::array, 6> table = { + {{{0, 1}}, {{0, 0}}, {{0, 2}}, {{1, 0}}, {{1, 1}}, {{1, 2}}}}; + + return table[vertex]; + } + else if (*this == ReferenceCells::Hexahedron) + { + return GeometryInfo<3>::standard_hex_vertex_to_quad_vertex_index(vertex); + } + + Assert(false, ExcNotImplemented()); + return {}; +} + + + +inline std::array +ReferenceCell::standard_line_to_face_and_line_index( + const unsigned int line) const +{ + AssertIndexRange(line, n_lines()); + + if (*this == ReferenceCells::Vertex) + { + Assert(false, ExcNotImplemented()); + } + else if (*this == ReferenceCells::Line) + { + Assert(false, ExcNotImplemented()); + } + else if (*this == ReferenceCells::Triangle) + { + Assert(false, ExcNotImplemented()); + } + else if (*this == ReferenceCells::Quadrilateral) + { + Assert(false, ExcNotImplemented()); + } + else if (*this == ReferenceCells::Tetrahedron) + { + static const std::array table[6] = { + {{0, 0}}, {{0, 1}}, {{0, 2}}, {{1, 1}}, {{1, 2}}, {{2, 1}}}; + + return table[line]; + } + else if (*this == ReferenceCells::Pyramid) + { + static const std::array table[8] = {{{0, 0}}, + {{0, 1}}, + {{0, 2}}, + {{0, 3}}, + {{1, 2}}, + {{2, 1}}, + {{1, 1}}, + {{2, 2}}}; + + return table[line]; + } + else if (*this == ReferenceCells::Wedge) + { + static const std::array table[9] = {{{0, 0}}, + {{0, 2}}, + {{0, 1}}, + {{1, 0}}, + {{1, 1}}, + {{1, 2}}, + {{2, 0}}, + {{2, 1}}, + {{3, 1}}}; + + return table[line]; + } + else if (*this == ReferenceCells::Hexahedron) + { + return GeometryInfo<3>::standard_hex_line_to_quad_line_index(line); + } + + Assert(false, ExcNotImplemented()); + return {}; +} + + + namespace ReferenceCells { template @@ -1158,7 +1318,6 @@ namespace internal return {0U, n_faces()}; } - public: /** * Standard decomposition of vertex index into face and face-vertex * index. @@ -1186,6 +1345,7 @@ namespace internal return {{0, 0}}; } + public: /** * Correct vertex index depending on face orientation. */ diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index a59999e0b0..8d2d26fc2d 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -621,8 +621,7 @@ namespace internal line_index(const TriaAccessor<3, 3, 3> &accessor, const unsigned int i) { const auto pair = - accessor.reference_cell_info().standard_line_to_face_and_line_index( - i); + accessor.reference_cell().standard_line_to_face_and_line_index(i); const auto quad_index = pair[0]; const auto line_index = accessor.reference_cell_info().standard_to_real_face_line( @@ -834,8 +833,7 @@ namespace internal AssertIndexRange(line, accessor.n_lines()); const auto pair = - accessor.reference_cell_info().standard_line_to_face_and_line_index( - line); + accessor.reference_cell().standard_line_to_face_and_line_index(line); const auto quad_index = pair[0]; const auto line_index = accessor.reference_cell_info().standard_to_real_face_line( @@ -1019,8 +1017,9 @@ namespace internal vertex_index(const TriaAccessor<2, dim, spacedim> &accessor, const unsigned int corner) { - const auto pair = accessor.reference_cell_info() - .standard_vertex_to_face_and_vertex_index(corner); + const auto pair = + accessor.reference_cell().standard_vertex_to_face_and_vertex_index( + corner); const auto line_index = pair[0]; const auto vertex_index = accessor.reference_cell_info().standard_to_real_face_vertex( @@ -1035,8 +1034,9 @@ namespace internal vertex_index(const TriaAccessor<3, 3, 3> &accessor, const unsigned int corner) { - const auto pair = accessor.reference_cell_info() - .standard_vertex_to_face_and_vertex_index(corner); + const auto pair = + accessor.reference_cell().standard_vertex_to_face_and_vertex_index( + corner); const auto face_index = pair[0]; const auto vertex_index = accessor.reference_cell_info().standard_to_real_face_vertex(