From: David Wells Date: Tue, 27 Oct 2020 15:31:01 +0000 (-0400) Subject: Move n_vertices_to_type to reference_cell.h X-Git-Tag: v9.3.0-rc1~917^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f797df7b95b5c5760c7f90815161ff34683aa94c;p=dealii.git Move n_vertices_to_type to reference_cell.h --- diff --git a/include/deal.II/grid/connectivity.h b/include/deal.II/grid/connectivity.h index 747450b7c1..3dc34f4766 100644 --- a/include/deal.II/grid/connectivity.h +++ b/include/deal.II/grid/connectivity.h @@ -1572,30 +1572,6 @@ namespace internal ReferenceCell::Type::Hex)] .reset(new CellTypeHex()); - // jump table to pick the right entity type - static const ReferenceCell::Type X = ReferenceCell::Type::Invalid; - static const std::array, 4> - table = {{{{X, ReferenceCell::Type::Vertex, X, X, X, X, X, X, X}}, - {{X, X, ReferenceCell::Type::Line, X, X, X, X, X, X}}, - {{X, - X, - X, - ReferenceCell::Type::Tri, - ReferenceCell::Type::Quad, - X, - X, - X, - X}}, - {{X, - X, - X, - X, - ReferenceCell::Type::Tet, - ReferenceCell::Type::Pyramid, - ReferenceCell::Type::Wedge, - X, - ReferenceCell::Type::Hex}}}}; - // determine cell types and process vertices std::vector cell_vertices; cell_vertices.reserve( @@ -1616,9 +1592,8 @@ namespace internal // loop over cells and create CRS for (const auto &cell : cells) { - // determine cell type const ReferenceCell::Type cell_type = - table[dim][cell.vertices.size()]; + ReferenceCell::n_vertices_to_type(dim, cell.vertices.size()); Assert(cell_type != ReferenceCell::Type::Invalid, ExcNotImplemented()); diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 5dca4d22e7..017607e8f2 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -91,6 +91,29 @@ 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) + { + AssertIndexRange(dim, 4); + AssertIndexRange(n_vertices, 9); + const auto X = Type::Invalid; + + static constexpr std::array, 4> table = { + {// dim 0 + {{X, Type::Vertex, X, X, X, X, X, X, X}}, + // dim 1 + {{X, X, Type::Line, X, X, X, X, X, X}}, + // dim 2 + {{X, X, X, Type::Tri, Type::Quad, X, X, X, X}}, + // dim 3 + {{X, X, X, X, Type::Tet, Type::Pyramid, Type::Wedge, X, Type::Hex}}}}; + return table[dim][n_vertices]; + } + namespace internal { /**