]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move the function that generates a reference cell to GridGenerator.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Jan 2021 18:49:16 +0000 (11:49 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 29 Jan 2021 18:31:57 +0000 (11:31 -0700)
include/deal.II/fe/fe_tools.templates.h
include/deal.II/grid/grid_generator.h
include/deal.II/grid/reference_cell.h
source/grid/grid_generator.cc
source/grid/grid_generator.inst.in
source/grid/reference_cell.cc
source/grid/reference_cell.inst.in
tests/simplex/fe_p_bubbles_02.cc
tests/simplex/orientation_02.cc

index 4e3edf8a9274d875a8ccfa8f4807e0ac7f49c04f..b2142de6293a7e0594939afa176470fcb7523df3 100644 (file)
@@ -1605,7 +1605,7 @@ namespace FETools
 
     // First, create a local mass matrix for the unit cell
     Triangulation<dim, spacedim> tr;
-    ReferenceCell::make_triangulation(reference_cell_type, tr);
+    GridGenerator::reference_cell(reference_cell_type, tr);
 
     const auto &mapping =
       reference_cell_type.template get_default_linear_mapping<dim, spacedim>();
@@ -1814,7 +1814,7 @@ namespace FETools
         // Set up meshes, one with a single
         // reference cell and refine it once
         Triangulation<dim, spacedim> tria;
-        ReferenceCell::make_triangulation(reference_cell_type, tria);
+        GridGenerator::reference_cell(reference_cell_type, tria);
         tria.begin_active()->set_refine_flag(RefinementCase<dim>(ref_case));
         tria.execute_coarsening_and_refinement();
 
index 6dfaee23c63859d3fb2e59a6a9270c6562b356f9..75a94c6e88b22d6cfe24e18545113b1448d703f7 100644 (file)
@@ -128,6 +128,17 @@ namespace GridGenerator
   simplex(Triangulation<dim, dim> &      tria,
           const std::vector<Point<dim>> &vertices);
 
+  /*
+   * Create a (coarse) grid with a single cell of the shape of the provided
+   * reference cell. This is a generalization of the hyper_cube() and simplex()
+   * functions above.
+   */
+  template <int dim, int spacedim>
+  void
+  reference_cell(const ReferenceCell::Type &   reference_cell,
+                 Triangulation<dim, spacedim> &tria);
+
+
   /**
    * Same as hyper_cube(), but with the difference that not only one cell is
    * created but each coordinate direction is subdivided into @p repetitions
index d54ed6352dde65891587f4e4139079e29a289c7e..37c360d56b808d97bc58814d7cd05e27f44537b8 100644 (file)
@@ -712,15 +712,6 @@ namespace ReferenceCell
     return {};
   }
 
-  /*
-   * Create a (coarse) grid with a single cell of the shape of the provided
-   * reference cell.
-   */
-  template <int dim, int spacedim>
-  void
-  make_triangulation(const Type &                  reference_cell,
-                     Triangulation<dim, spacedim> &tria);
-
   /**
    * Return a default linear mapping that works for the given triangulation.
    * Internally, this function calls the function above for the reference
index b1d2070aaf44aec0692079a5964730380cb0356c..aca11b6270e28702de16cc67e3194b8401dc7c9d 100644 (file)
@@ -1580,6 +1580,7 @@ namespace GridGenerator
   }
 
 
+
   template <int dim, int spacedim>
   void
   hyper_cube(Triangulation<dim, spacedim> &tria,
@@ -1599,6 +1600,8 @@ namespace GridGenerator
     hyper_rectangle(tria, p1, p2, colorize);
   }
 
+
+
   template <int dim>
   void
   simplex(Triangulation<dim> &tria, const std::vector<Point<dim>> &vertices)
@@ -1711,6 +1714,82 @@ namespace GridGenerator
   }
 
 
+
+  template <int dim, int spacedim>
+  void
+  reference_cell(const ReferenceCell::Type &   reference_cell,
+                 Triangulation<dim, spacedim> &tria)
+  {
+    AssertDimension(dim, reference_cell.get_dimension());
+
+    if (reference_cell == ReferenceCell::Type::get_hypercube<dim>())
+      {
+        GridGenerator::hyper_cube(tria, 0, 1);
+      }
+    else if ((dim == 2) && (reference_cell == ReferenceCell::Type::Tri))
+      {
+        const std::vector<Point<spacedim>> vertices = {
+          Point<spacedim>(),               // the origin
+          Point<spacedim>::unit_vector(0), // unit point along x-axis
+          Point<spacedim>::unit_vector(1)  // unit point along y-axis
+        };
+
+        std::vector<CellData<dim>> cells(1);
+        cells[0].vertices = {0, 1, 2};
+
+        tria.create_triangulation(vertices, cells, {});
+      }
+    else if ((dim == 3) && (reference_cell == ReferenceCell::Type::Tet))
+      {
+        AssertDimension(spacedim, 3);
+
+        static const std::vector<Point<spacedim>> vertices = {
+          {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}};
+
+        std::vector<CellData<dim>> cells(1);
+        cells[0].vertices = {0, 1, 2, 3};
+
+        tria.create_triangulation(vertices, cells, {});
+      }
+    else if ((dim == 3) && (reference_cell == ReferenceCell::Type::Pyramid))
+      {
+        AssertDimension(spacedim, 3);
+
+        static const std::vector<Point<spacedim>> vertices = {
+          {{-1.0, -1.0, 0.0},
+           {+1.0, -1.0, 0.0},
+           {-1.0, +1.0, 0.0},
+           {+1.0, +1.0, 0.0},
+           {+0.0, +0.0, 1.0}}};
+
+        std::vector<CellData<dim>> cells(1);
+        cells[0].vertices = {0, 1, 2, 3, 4};
+
+        tria.create_triangulation(vertices, cells, {});
+      }
+    else if ((dim == 3) && (reference_cell == ReferenceCell::Type::Wedge))
+      {
+        AssertDimension(spacedim, 3);
+
+        static const std::vector<Point<spacedim>> vertices = {
+          {{1.0, 0.0, 0.0},
+           {0.0, 1.0, 0.0},
+           {0.0, 0.0, 0.0},
+           {1.0, 0.0, 1.0},
+           {0.0, 1.0, 1.0},
+           {0.0, 0.0, 1.0}}};
+
+        std::vector<CellData<dim>> cells(1);
+        cells[0].vertices = {0, 1, 2, 3, 4, 5};
+
+        tria.create_triangulation(vertices, cells, {});
+      }
+    else
+      {
+        Assert(false, ExcNotImplemented());
+      }
+  }
+
   void moebius(Triangulation<3> & tria,
                const unsigned int n_cells,
                const unsigned int n_rotations,
index c6c2bd6d681baa62a0ef09ad365eabc753294759..d7e1b25dd46fdca97647825fe7f8ef0c03287be5 100644 (file)
@@ -269,6 +269,11 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
     namespace GridGenerator
     \{
 #if deal_II_dimension <= deal_II_space_dimension
+      template void
+      reference_cell<deal_II_dimension, deal_II_space_dimension>(
+        const ReferenceCell::Type &,
+        Triangulation<deal_II_dimension, deal_II_space_dimension> &);
+
       template void
       convert_hypercube_to_simplex_mesh(
         const Triangulation<deal_II_dimension, deal_II_space_dimension> &,
index 85c33d5b3fbeb01dfc25c242b4001d1f6876c828..c187cdd4ea278bf752fab9f530d5e15e5b8b50a8 100644 (file)
@@ -92,83 +92,6 @@ namespace ReferenceCell
 
 
 
-  template <int dim, int spacedim>
-  void
-  make_triangulation(const Type &                  reference_cell,
-                     Triangulation<dim, spacedim> &tria)
-  {
-    AssertDimension(dim, reference_cell.get_dimension());
-
-    if (reference_cell == Type::get_hypercube<dim>())
-      {
-        GridGenerator::hyper_cube(tria, 0, 1);
-      }
-    else if ((dim == 2) && (reference_cell == Type::Tri))
-      {
-        const std::vector<Point<spacedim>> vertices = {
-          Point<spacedim>(),               // the origin
-          Point<spacedim>::unit_vector(0), // unit point along x-axis
-          Point<spacedim>::unit_vector(1)  // unit point along y-axis
-        };
-
-        std::vector<CellData<dim>> cells(1);
-        cells[0].vertices = {0, 1, 2};
-
-        tria.create_triangulation(vertices, cells, {});
-      }
-    else if ((dim == 3) && (reference_cell == Type::Tet))
-      {
-        AssertDimension(spacedim, 3);
-
-        static const std::vector<Point<spacedim>> vertices = {
-          {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}}};
-
-        std::vector<CellData<dim>> cells(1);
-        cells[0].vertices = {0, 1, 2, 3};
-
-        tria.create_triangulation(vertices, cells, {});
-      }
-    else if ((dim == 3) && (reference_cell == Type::Pyramid))
-      {
-        AssertDimension(spacedim, 3);
-
-        static const std::vector<Point<spacedim>> vertices = {
-          {{-1.0, -1.0, 0.0},
-           {+1.0, -1.0, 0.0},
-           {-1.0, +1.0, 0.0},
-           {+1.0, +1.0, 0.0},
-           {+0.0, +0.0, 1.0}}};
-
-        std::vector<CellData<dim>> cells(1);
-        cells[0].vertices = {0, 1, 2, 3, 4};
-
-        tria.create_triangulation(vertices, cells, {});
-      }
-    else if ((dim == 3) && (reference_cell == Type::Wedge))
-      {
-        AssertDimension(spacedim, 3);
-
-        static const std::vector<Point<spacedim>> vertices = {
-          {{1.0, 0.0, 0.0},
-           {0.0, 1.0, 0.0},
-           {0.0, 0.0, 0.0},
-           {1.0, 0.0, 1.0},
-           {0.0, 1.0, 1.0},
-           {0.0, 0.0, 1.0}}};
-
-        std::vector<CellData<dim>> cells(1);
-        cells[0].vertices = {0, 1, 2, 3, 4, 5};
-
-        tria.create_triangulation(vertices, cells, {});
-      }
-    else
-      {
-        Assert(false, ExcNotImplemented());
-      }
-  }
-
-
-
   template <int dim, int spacedim>
   std::unique_ptr<Mapping<dim, spacedim>>
   Type::get_default_mapping(const unsigned int degree) const
@@ -285,7 +208,7 @@ namespace ReferenceCell
 
     const auto create_quadrature = [](const Type &reference_cell) {
       Triangulation<dim> tria;
-      make_triangulation(reference_cell, tria);
+      GridGenerator::reference_cell(reference_cell, tria);
 
       return Quadrature<dim>(tria.get_vertices());
     };
index b232ba517a5a07cab6a37b3b6e50a421c55cf4e6..418844ce498402348a291e8da5cc5f7c47e52b23 100644 (file)
 for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
   {
 #if deal_II_dimension <= deal_II_space_dimension
-    template void make_triangulation(
-      const Type &                                               reference_cell,
-      Triangulation<deal_II_dimension, deal_II_space_dimension> &tria);
-
     template std::unique_ptr<
       Mapping<deal_II_dimension, deal_II_space_dimension>>
     Type::get_default_mapping(const unsigned int degree) const;
index 331a65e520c5dc775aa44592095b9bf67dfc3f7b..9a45e95ed85dca62ef032695dc5e21ac277d5ec8 100644 (file)
@@ -49,7 +49,7 @@ compute_nodal_quadrature(const FiniteElement<dim, spacedim> &fe)
   const Quadrature<dim> q_gauss =
     ReferenceCell::get_gauss_type_quadrature<dim>(type, fe.tensor_degree() + 1);
   Triangulation<dim, spacedim> tria;
-  ReferenceCell::make_triangulation(type, tria);
+  GridGenerator::reference_cell(type, tria);
   const Mapping<dim, spacedim> &mapping =
     ReferenceCell::get_default_linear_mapping<dim, spacedim>(type);
 
index c81eb0903f629e796ead306513da953e938f211a..8931b1da8fd3aa5330b9a5ec1eaef8023f250c18 100644 (file)
@@ -29,7 +29,7 @@ test(const unsigned int orientation)
 
 
   Triangulation<3> dummy, tria;
-  ReferenceCell::make_triangulation(ReferenceCell::Type::Tet, dummy);
+  GridGenerator::reference_cell(ReferenceCell::Type::Tet, dummy);
 
   auto vertices = dummy.get_vertices();
 

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.