From 6f547af8ed9002cd492b88b90c1d63b6d319bef8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 3 Feb 2021 09:14:31 -0700 Subject: [PATCH] Move n_vertices_to_type() into ReferenceCell::Type. --- include/deal.II/grid/connectivity.h | 13 ++++++------ include/deal.II/grid/reference_cell.h | 20 ++++++++++++------- .../deal.II/grid/tria_accessor.templates.h | 2 +- source/grid/grid_in.cc | 3 ++- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/deal.II/grid/connectivity.h b/include/deal.II/grid/connectivity.h index d049fa5f09..9cdc7d9e58 100644 --- a/include/deal.II/grid/connectivity.h +++ b/include/deal.II/grid/connectivity.h @@ -1490,19 +1490,20 @@ namespace internal // loop over cells and create CRS for (const auto &cell : cells) { - const ReferenceCell::Type cell_type = - ReferenceCell::n_vertices_to_type(dim, cell.vertices.size()); + const ReferenceCell::Type reference_cell_type = + ReferenceCell::Type::n_vertices_to_type(dim, cell.vertices.size()); - Assert(cell_type != ReferenceCell::Type::Invalid, + Assert(reference_cell_type != ReferenceCell::Type::Invalid, ExcNotImplemented()); - AssertIndexRange(static_cast(cell_type), + AssertIndexRange(static_cast( + reference_cell_type), cell_types_impl.size()); Assert(cell_types_impl[static_cast( - cell_type)] + reference_cell_type)] .get() != nullptr, ExcNotImplemented()); - cell_types_indices.push_back(cell_type); + cell_types_indices.push_back(reference_cell_type); // create CRS of vertices (to remove template argument dim) for (const auto &vertex : cell.vertices) diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 3950b01662..61360d906f 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -93,7 +93,6 @@ namespace ReferenceCell static constexpr const Type & get_simplex(); - /** * Return the correct hypercube reference cell type for the given dimension * `dim`. Depending on the template argument `dim`, this function returns a @@ -103,6 +102,15 @@ namespace ReferenceCell static constexpr const Type & get_hypercube(); + /** + * Return the correct ReferenceCell::Type for a given structural dimension + * and number of vertices. For example, if `dim==2` and `n_vertices==4`, + * this function will return `Quad`. But if `dim==3` and `n_vertices==4`, it + * will return `Tri`. + */ + static Type + n_vertices_to_type(const int dim, const unsigned int n_vertices); + /** * Default constructor. Initialize this object as an invalid object. */ @@ -482,17 +490,15 @@ namespace ReferenceCell } } - /** - * Retrieve the correct ReferenceCell::Type for a given structural dimension - * and number of vertices. - */ + + inline Type - n_vertices_to_type(const int dim, const unsigned int n_vertices) + Type::n_vertices_to_type(const int dim, const unsigned int n_vertices) { AssertIndexRange(dim, 4); AssertIndexRange(n_vertices, 9); - const auto X = Type::Invalid; + const auto X = Type::Invalid; static const std::array, 4> table = { diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index 9a4646649d..7e99c609fb 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -55,7 +55,7 @@ namespace internal vertices) { const ReferenceCell::Type reference_cell_type = - ReferenceCell::n_vertices_to_type(dim, vertices.size()); + ReferenceCell::Type::n_vertices_to_type(dim, vertices.size()); if (reference_cell_type == ReferenceCell::Type::Line) // Return the distance between the two vertices diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index 5da5ea53b8..4328f617ac 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -3193,7 +3193,8 @@ namespace const unsigned int local_face_n = face_id % max_faces_per_cell; const CellData &cell = cells[face_id / max_faces_per_cell]; const ReferenceCell::Type cell_type = - ReferenceCell::n_vertices_to_type(dim, cell.vertices.size()); + ReferenceCell::Type::n_vertices_to_type(dim, + cell.vertices.size()); const ReferenceCell::internal::Info::Base &info = ReferenceCell::internal::Info::get_cell(cell_type); const unsigned int deal_face_n = -- 2.39.5