]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move n_vertices_to_type to reference_cell.h
authorDavid Wells <drwells@email.unc.edu>
Tue, 27 Oct 2020 15:31:01 +0000 (11:31 -0400)
committerDavid Wells <drwells@email.unc.edu>
Tue, 10 Nov 2020 14:55:30 +0000 (09:55 -0500)
include/deal.II/grid/connectivity.h
include/deal.II/grid/reference_cell.h

index 747450b7c16f1fb4fc28758333a74597868b677d..3dc34f47665168291e8331f13675fbe9ec7996e3 100644 (file)
@@ -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<const std::array<ReferenceCell::Type, 9>, 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<T> 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());
index 5dca4d22e795ebce16f17630f6e5513075cabdba..017607e8f2d69f9c29f4b4315804ee7943f2f626 100644 (file)
@@ -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<std::array<ReferenceCell::Type, 9>, 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
   {
     /**

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.