From: Wolfgang Bangerth <bangerth@colostate.edu>
Date: Thu, 18 Feb 2021 19:05:05 +0000 (-0700)
Subject: Move the exodus conversion functions to RefereneCell.
X-Git-Tag: v9.3.0-rc1~436^2
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35280b4585ba1cb61713ed3727e747c098c1ea50;p=dealii.git

Move the exodus conversion functions to RefereneCell.
---

diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h
index 8e5cf89d87..979dc3545b 100644
--- a/include/deal.II/grid/reference_cell.h
+++ b/include/deal.II/grid/reference_cell.h
@@ -425,6 +425,27 @@ public:
   ArrayView<const unsigned int>
   faces_for_given_vertex(const unsigned int vertex_index) const;
 
+  /**
+   * @}
+   */
+
+  /**
+   * @name Translating between deal.II indexing and formats used by other programs
+   * @{
+   */
+
+  /**
+   * Map an ExodusII vertex number to a deal.II vertex number.
+   */
+  unsigned int
+  exodusii_vertex_to_deal_vertex(const unsigned int vertex_n) const;
+
+  /**
+   * Map an ExodusII face number to a deal.II face number.
+   */
+  unsigned int
+  exodusii_face_to_deal_face(const unsigned int face_n) const;
+
   /**
    * @}
    */
@@ -1910,7 +1931,6 @@ namespace internal
         return 0;
       }
 
-    public:
       /**
        * Map an ExodusII vertex number to a deal.II vertex number.
        */
@@ -1935,7 +1955,6 @@ namespace internal
         return 0;
       }
 
-    private:
       /**
        * Indices of child cells that are adjacent to a certain face of the
        * mother cell.
diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc
index 3f07fb6b3f..8d7acab9cc 100644
--- a/source/grid/grid_in.cc
+++ b/source/grid/grid_in.cc
@@ -3194,10 +3194,8 @@ namespace
             const CellData<dim> &cell = cells[face_id / max_faces_per_cell];
             const ReferenceCell  cell_type =
               ReferenceCell::n_vertices_to_type(dim, cell.vertices.size());
-            const internal::ReferenceCell::Base &info =
-              internal::ReferenceCell::get_cell(cell_type);
             const unsigned int deal_face_n =
-              info.exodusii_face_to_deal_face(local_face_n);
+              cell_type.exodusii_face_to_deal_face(local_face_n);
             const auto &face_info = cell_type.face_reference_cell(deal_face_n);
 
             // The orientation we pick doesn't matter here since when we create
@@ -3366,8 +3364,7 @@ GridIn<dim, spacedim>::read_exodusii(
           CellData<dim> cell(type.n_vertices());
           for (unsigned int i : type.vertex_indices())
             {
-              cell.vertices[internal::ReferenceCell::get_cell(type)
-                              .exodusii_vertex_to_deal_vertex(i)] =
+              cell.vertices[type.exodusii_vertex_to_deal_vertex(i)] =
                 connection[elem_n + i] - 1;
             }
           cell.material_id = element_block_id;
diff --git a/source/grid/reference_cell.cc b/source/grid/reference_cell.cc
index 93878b5a36..41b656fc6f 100644
--- a/source/grid/reference_cell.cc
+++ b/source/grid/reference_cell.cc
@@ -193,6 +193,104 @@ ReferenceCell::get_nodal_type_quadrature() const
   return dummy; // never reached
 }
 
+
+
+unsigned int
+ReferenceCell::exodusii_vertex_to_deal_vertex(const unsigned int vertex_n) const
+{
+  AssertIndexRange(vertex_n, n_vertices());
+
+  if (*this == ReferenceCells::Line)
+    {
+      return vertex_n;
+    }
+  else if (*this == ReferenceCells::Triangle)
+    {
+      return vertex_n;
+    }
+  else if (*this == ReferenceCells::Quadrilateral)
+    {
+      constexpr std::array<unsigned int, 4> exodus_to_deal{{0, 1, 3, 2}};
+      return exodus_to_deal[vertex_n];
+    }
+  else if (*this == ReferenceCells::Tetrahedron)
+    {
+      return vertex_n;
+    }
+  else if (*this == ReferenceCells::Hexahedron)
+    {
+      constexpr std::array<unsigned int, 8> exodus_to_deal{
+        {0, 1, 3, 2, 4, 5, 7, 6}};
+      return exodus_to_deal[vertex_n];
+    }
+  else if (*this == ReferenceCells::Wedge)
+    {
+      constexpr std::array<unsigned int, 6> exodus_to_deal{{2, 1, 0, 5, 4, 3}};
+      return exodus_to_deal[vertex_n];
+    }
+  else if (*this == ReferenceCells::Pyramid)
+    {
+      constexpr std::array<unsigned int, 5> exodus_to_deal{{0, 1, 3, 2, 4}};
+      return exodus_to_deal[vertex_n];
+    }
+
+  Assert(false, ExcNotImplemented());
+
+  return numbers::invalid_unsigned_int;
+}
+
+
+
+unsigned int
+ReferenceCell::exodusii_face_to_deal_face(const unsigned int face_n) const
+{
+  AssertIndexRange(face_n, n_faces());
+
+  if (*this == ReferenceCells::Vertex)
+    {
+      return 0;
+    }
+  if (*this == ReferenceCells::Line)
+    {
+      return face_n;
+    }
+  else if (*this == ReferenceCells::Triangle)
+    {
+      return face_n;
+    }
+  else if (*this == ReferenceCells::Quadrilateral)
+    {
+      constexpr std::array<unsigned int, 4> exodus_to_deal{{2, 1, 3, 0}};
+      return exodus_to_deal[face_n];
+    }
+  else if (*this == ReferenceCells::Tetrahedron)
+    {
+      constexpr std::array<unsigned int, 4> exodus_to_deal{{1, 3, 2, 0}};
+      return exodus_to_deal[face_n];
+    }
+  else if (*this == ReferenceCells::Hexahedron)
+    {
+      constexpr std::array<unsigned int, 6> exodus_to_deal{{2, 1, 3, 0, 4, 5}};
+      return exodus_to_deal[face_n];
+    }
+  else if (*this == ReferenceCells::Wedge)
+    {
+      constexpr std::array<unsigned int, 6> exodus_to_deal{{3, 4, 2, 0, 1}};
+      return exodus_to_deal[face_n];
+    }
+  else if (*this == ReferenceCells::Pyramid)
+    {
+      constexpr std::array<unsigned int, 5> exodus_to_deal{{3, 2, 4, 1, 0}};
+      return exodus_to_deal[face_n];
+    }
+
+  Assert(false, ExcNotImplemented());
+
+  return numbers::invalid_unsigned_int;
+}
+
+
+
 #include "reference_cell.inst"
 
 DEAL_II_NAMESPACE_CLOSE