]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move two conversion functions from internal::ReferenceCell::Base to ReferenceCell. 11718/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 9 Feb 2021 14:20:28 +0000 (07:20 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 10 Feb 2021 21:40:25 +0000 (14:40 -0700)
include/deal.II/grid/reference_cell.h
include/deal.II/grid/tria_accessor.templates.h

index 7af95cb45e3a0d4846a2b77c887740fcd6fd011c..ef703d929ec4ad2de2a2a2892cddc7526e4fef92 100644 (file)
@@ -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<unsigned int, 2>
+  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<unsigned int, 2>
+  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<unsigned int, 2>
+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<std::array<unsigned int, 2>, 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<unsigned int, 2> table[4] = {{{0, 0}},
+                                                           {{0, 1}},
+                                                           {{0, 2}},
+                                                           {{1, 2}}};
+
+      return table[vertex];
+    }
+  else if (*this == ReferenceCells::Pyramid)
+    {
+      static const std::array<unsigned int, 2> table[5] = {
+        {{0, 0}}, {{0, 1}}, {{0, 2}}, {{0, 3}}, {{1, 2}}};
+
+      return table[vertex];
+    }
+  else if (*this == ReferenceCells::Wedge)
+    {
+      static const std::array<std::array<unsigned int, 2>, 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<unsigned int, 2>
+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<unsigned int, 2> 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<unsigned int, 2> 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<unsigned int, 2> 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 <int dim>
@@ -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.
        */
index a59999e0b0b42e6e7bfcb0db78bd44ab4c7d8fd6..8d2d26fc2d858362f7663fdb907f74fecf4b199a 100644 (file)
@@ -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(

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.