]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move the exodus conversion functions to RefereneCell. 11770/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 18 Feb 2021 19:05:05 +0000 (12:05 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 18 Feb 2021 19:31:44 +0000 (12:31 -0700)
include/deal.II/grid/reference_cell.h
source/grid/grid_in.cc
source/grid/reference_cell.cc

index 8e5cf89d8730983d9954b5d780bbd5aeb7e89cfa..979dc3545b881af9a04f34a278a1ad07c1ebbfc7 100644 (file)
@@ -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.
index 3f07fb6b3fe89bd9f2fff1d8874d3d1b6cc99c88..8d7acab9ccd4ba625289a3e8a1a01204577a40ee 100644 (file)
@@ -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;
index 93878b5a36a81b2a48eb494236e09300bf0ea76c..41b656fc6f854485fc0a19055c7eef4d927675f4 100644 (file)
@@ -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

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.