]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move n_vertices_to_type() into ReferenceCell::Type. 11673/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 3 Feb 2021 16:14:31 +0000 (09:14 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 3 Feb 2021 16:14:31 +0000 (09:14 -0700)
include/deal.II/grid/connectivity.h
include/deal.II/grid/reference_cell.h
include/deal.II/grid/tria_accessor.templates.h
source/grid/grid_in.cc

index d049fa5f0935a39fe72a9b30350eb6d740051aba..9cdc7d9e58f89019806d91bdf4142580d02ac422 100644 (file)
@@ -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<types::geometric_entity_type>(cell_type),
+          AssertIndexRange(static_cast<types::geometric_entity_type>(
+                             reference_cell_type),
                            cell_types_impl.size());
           Assert(cell_types_impl[static_cast<types::geometric_entity_type>(
-                                   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)
index 3950b01662527893190063306e52df82318bfde2..61360d906f01e10c8a92ea2adf7a18a93d14cfb5 100644 (file)
@@ -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<std::array<ReferenceCell::Type, 9>,
                             4>
       table = {
index 9a4646649dbff52051d7502b9f1c4acd3f1508d2..7e99c609fbb1f16d18fbeb1897016b2185768dc8 100644 (file)
@@ -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
index 5da5ea53b832061c405673d52c0af282644132ef..4328f617acd08a417bb7fe4ecb9b4d1379d16977 100644 (file)
@@ -3193,7 +3193,8 @@ namespace
             const unsigned int   local_face_n = face_id % max_faces_per_cell;
             const CellData<dim> &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 =

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.