From 35280b4585ba1cb61713ed3727e747c098c1ea50 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 18 Feb 2021 12:05:05 -0700 Subject: [PATCH] Move the exodus conversion functions to RefereneCell. --- include/deal.II/grid/reference_cell.h | 23 ++++++- source/grid/grid_in.cc | 7 +- source/grid/reference_cell.cc | 98 +++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 7 deletions(-) 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 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 &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::read_exodusii( CellData 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 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 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 exodus_to_deal{{2, 1, 0, 5, 4, 3}}; + return exodus_to_deal[vertex_n]; + } + else if (*this == ReferenceCells::Pyramid) + { + constexpr std::array 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 exodus_to_deal{{2, 1, 3, 0}}; + return exodus_to_deal[face_n]; + } + else if (*this == ReferenceCells::Tetrahedron) + { + constexpr std::array exodus_to_deal{{1, 3, 2, 0}}; + return exodus_to_deal[face_n]; + } + else if (*this == ReferenceCells::Hexahedron) + { + constexpr std::array exodus_to_deal{{2, 1, 3, 0, 4, 5}}; + return exodus_to_deal[face_n]; + } + else if (*this == ReferenceCells::Wedge) + { + constexpr std::array exodus_to_deal{{3, 4, 2, 0, 1}}; + return exodus_to_deal[face_n]; + } + else if (*this == ReferenceCells::Pyramid) + { + constexpr std::array 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 -- 2.39.5