From 9462e0495c90e77d89e4344327ac6b77e52845d0 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Wed, 8 Jul 2020 21:25:21 +0200 Subject: [PATCH] Use ReferenceCell::Type to get Info Add additional ReferenceCell::internal::Infos --- include/deal.II/grid/reference_cell.h | 415 +++++++++++++++++++++++++- 1 file changed, 410 insertions(+), 5 deletions(-) diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 6834c065ec..8832704e63 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -301,6 +301,68 @@ namespace ReferenceCell + /** + * Triangle. + */ + struct Tri : public Base + { + unsigned int + n_vertices() const override + { + return 3; + } + + unsigned int + n_lines() const override + { + return 3; + } + + unsigned int + n_faces() const override + { + return this->n_lines(); + } + + std::array + standard_vertex_to_face_and_vertex_index( + const unsigned int vertex) const override + { + AssertIndexRange(vertex, 3); + + static const std::array, 3> table = { + {{0, 0}, {0, 1}, {1, 1}}}; + + return table[vertex]; + } + + unsigned int + standard_to_real_face_vertex( + const unsigned int vertex, + const unsigned int face, + const unsigned char line_orientation) const override + { + (void)face; + + static const std::array, 2> table = { + {{1, 0}, {0, 1}}}; + + return table[line_orientation][vertex]; + } + + ReferenceCell::Type + face_reference_cell_type(const unsigned int face_no) const override + { + (void)face_no; + + AssertIndexRange(face_no, n_faces()); + + return ReferenceCell::Type::Line; + } + }; + + + /** * Quad. */ @@ -336,6 +398,337 @@ namespace ReferenceCell + /** + * Tet. + */ + struct Tet : public TensorProductBase<3> + { + unsigned int + n_vertices() const override + { + return 4; + } + + unsigned int + n_lines() const override + { + return 6; + } + + unsigned int + n_faces() const override + { + return 4; + } + + std::array + standard_line_to_face_and_line_index( + const unsigned int line) const override + { + static const std::array table[6] = { + {0, 0}, {0, 1}, {0, 2}, {1, 1}, {1, 2}, {2, 1}}; + + return table[line]; + } + + unsigned int + standard_to_real_face_line( + const unsigned int line, + const unsigned int face, + const unsigned char face_orientation) const override + { + (void)face; + + static const std::array, 6> table = { + {{2, 1, 0}, {0, 1, 2}, {1, 2, 0}, {0, 2, 1}, {1, 0, 2}, {2, 0, 1}}}; + + return table[face_orientation][line]; + } + + bool + combine_face_and_line_orientation( + const unsigned int line, + const unsigned char face_orientation_raw, + const unsigned char line_orientation) const override + { + (void)line; + (void)face_orientation_raw; + + return line_orientation; + } + + std::array + standard_vertex_to_face_and_vertex_index( + const unsigned int vertex) const override + { + AssertIndexRange(vertex, 4); + + static const std::array table[4] = {{0, 0}, + {0, 1}, + {0, 2}, + {1, 2}}; + + return table[vertex]; + } + + unsigned int + standard_to_real_face_vertex( + const unsigned int vertex, + const unsigned int face, + const unsigned char face_orientation) const override + { + AssertIndexRange(face_orientation, 6); + (void)face; + + static const std::array, 6> table = { + {{0, 2, 1}, {0, 1, 2}, {1, 2, 0}, {1, 0, 2}, {2, 1, 0}, {2, 0, 1}}}; + + return table[face_orientation][vertex]; + } + + ReferenceCell::Type + face_reference_cell_type(const unsigned int face_no) const override + { + (void)face_no; + + AssertIndexRange(face_no, n_faces()); + + return ReferenceCell::Type::Tri; + } + }; + + + + /** + * Pyramid. + */ + struct Pyramid : public TensorProductBase<3> + { + unsigned int + n_vertices() const override + { + return 5; + } + + unsigned int + n_lines() const override + { + return 8; + } + + unsigned int + n_faces() const override + { + return 5; + } + + std::array + standard_line_to_face_and_line_index( + const unsigned int line) const override + { + Assert(false, ExcNotImplemented()); + + static const std::array table[6] = { + {0, 0}, {0, 1}, {0, 2}, {1, 1}, {1, 2}, {2, 1}}; + + return table[line]; + } + + unsigned int + standard_to_real_face_line( + const unsigned int line, + const unsigned int face, + const unsigned char face_orientation) const override + { + Assert(false, ExcNotImplemented()); + + (void)face; + + static const std::array, 6> table = { + {{2, 1, 0}, {0, 1, 2}, {1, 2, 0}, {0, 2, 1}, {1, 0, 2}, {2, 0, 1}}}; + + return table[face_orientation][line]; + } + + bool + combine_face_and_line_orientation( + const unsigned int line, + const unsigned char face_orientation_raw, + const unsigned char line_orientation) const override + { + (void)line; + (void)face_orientation_raw; + + return line_orientation; + } + + std::array + standard_vertex_to_face_and_vertex_index( + const unsigned int vertex) const override + { + static const std::array table[5] = { + {0, 0}, {0, 1}, {0, 2}, {0, 3}, {1, 2}}; + + return table[vertex]; + } + + unsigned int + standard_to_real_face_vertex( + const unsigned int vertex, + const unsigned int face, + const unsigned char face_orientation) const override + { + if (face == 0) // Quad + { + return GeometryInfo<3>::standard_to_real_face_vertex( + vertex, + get_bit(face_orientation, 0), + get_bit(face_orientation, 2), + get_bit(face_orientation, 1)); + } + else // Tri + { + static const std::array, 6> table = { + {{0, 2, 1}, + {0, 1, 2}, + {1, 2, 0}, + {1, 0, 2}, + {2, 1, 0}, + {2, 0, 1}}}; + + return table[face_orientation][vertex]; + } + } + + ReferenceCell::Type + face_reference_cell_type(const unsigned int face_no) const override + { + AssertIndexRange(face_no, n_faces()); + + if (face_no == 1) + return ReferenceCell::Type::Quad; + else + return ReferenceCell::Type::Tri; + } + }; + + + + /** + * Wedge. + */ + struct Wedge : public TensorProductBase<3> + { + unsigned int + n_vertices() const override + { + return 6; + } + + unsigned int + n_lines() const override + { + return 9; + } + + unsigned int + n_faces() const override + { + return 6; + } + + std::array + standard_line_to_face_and_line_index( + const unsigned int line) const override + { + Assert(false, ExcNotImplemented()); + + static const std::array table[6] = { + {0, 0}, {0, 1}, {0, 2}, {1, 1}, {1, 2}, {2, 1}}; + + return table[line]; + } + + unsigned int + standard_to_real_face_line( + const unsigned int line, + const unsigned int face, + const unsigned char face_orientation) const override + { + Assert(false, ExcNotImplemented()); + + (void)face; + + static const std::array, 6> table = { + {{2, 1, 0}, {0, 1, 2}, {1, 2, 0}, {0, 2, 1}, {1, 0, 2}, {2, 0, 1}}}; + + return table[face_orientation][line]; + } + + bool + combine_face_and_line_orientation( + const unsigned int line, + const unsigned char face_orientation_raw, + const unsigned char line_orientation) const override + { + (void)line; + (void)face_orientation_raw; + + return line_orientation; + } + + std::array + standard_vertex_to_face_and_vertex_index( + const unsigned int vertex) const override + { + static const std::array, 6> table = { + {{0, 1}, {0, 0}, {0, 2}, {1, 0}, {1, 1}, {1, 2}}}; + + return table[vertex]; + } + + unsigned int + standard_to_real_face_vertex( + const unsigned int vertex, + const unsigned int face, + const unsigned char face_orientation) const override + { + if (face > 1) // QUAD + { + return GeometryInfo<3>::standard_to_real_face_vertex( + vertex, + get_bit(face_orientation, 0), + get_bit(face_orientation, 2), + get_bit(face_orientation, 1)); + } + else // TRI + { + static const std::array, 6> table = { + {{0, 2, 1}, + {0, 1, 2}, + {1, 2, 0}, + {1, 0, 2}, + {2, 1, 0}, + {2, 0, 1}}}; + + return table[face_orientation][vertex]; + } + } + + ReferenceCell::Type + face_reference_cell_type(const unsigned int face_no) const override + { + AssertIndexRange(face_no, n_faces()); + + if (face_no > 1) + return ReferenceCell::Type::Quad; + else + return ReferenceCell::Type::Tri; + } + }; + + + /** * Hex. */ @@ -429,11 +822,15 @@ namespace ReferenceCell inline const ReferenceCell::internal::Info::Base & get_cell(const ReferenceCell::Type &type) { - static ReferenceCell::internal::Info::Base gei_invalid; - static ReferenceCell::internal::Info::Vertex gei_vertex; - static ReferenceCell::internal::Info::Line gei_line; - static ReferenceCell::internal::Info::Quad gei_quad; - static ReferenceCell::internal::Info::Hex gei_hex; + static ReferenceCell::internal::Info::Base gei_invalid; + static ReferenceCell::internal::Info::Vertex gei_vertex; + static ReferenceCell::internal::Info::Line gei_line; + static ReferenceCell::internal::Info::Tri gei_tri; + static ReferenceCell::internal::Info::Quad gei_quad; + static ReferenceCell::internal::Info::Tet gei_tet; + static ReferenceCell::internal::Info::Pyramid gei_pyramid; + static ReferenceCell::internal::Info::Wedge gei_wedge; + static ReferenceCell::internal::Info::Hex gei_hex; switch (type) { @@ -441,8 +838,16 @@ namespace ReferenceCell return gei_vertex; case ReferenceCell::Type::Line: return gei_line; + case ReferenceCell::Type::Tri: + return gei_tri; case ReferenceCell::Type::Quad: return gei_quad; + case ReferenceCell::Type::Tet: + return gei_tet; + case ReferenceCell::Type::Pyramid: + return gei_pyramid; + case ReferenceCell::Type::Wedge: + return gei_wedge; case ReferenceCell::Type::Hex: return gei_hex; default: -- 2.39.5