]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add functions to support dim-independent programming 9739/head
authorNiklas Fehn <fehn@lnm.mw.tum.de>
Thu, 26 Mar 2020 13:10:52 +0000 (14:10 +0100)
committerNiklas Fehn <fehn@lnm.mw.tum.de>
Sat, 4 Apr 2020 07:38:57 +0000 (09:38 +0200)
include/deal.II/grid/grid_generator.h
include/deal.II/grid/grid_tools.h
source/grid/grid_generator.cc
source/grid/grid_tools.cc

index a9cf8ac42ca9eab0f49df6a93724d65d0da70850..7f12c87cb8fc5cf82d19d4b36859828b602a37a1 100644 (file)
@@ -1755,6 +1755,22 @@ namespace GridGenerator
     const bool                             copy_manifold_ids   = false,
     const std::vector<types::manifold_id> &manifold_priorities = {});
 
+  /**
+   * Overload of extrude_triangulation() to allow dimension independent
+   * code to compile. This function throws an error when called, as
+   * extrude_triangulation() is only implemented to extrude a dim=2 to a dim=3
+   * Triangulation.
+   */
+  void
+  extrude_triangulation(
+    const Triangulation<2, 2> &            input,
+    const unsigned int                     n_slices,
+    const double                           height,
+    Triangulation<2, 2> &                  result,
+    const bool                             copy_manifold_ids   = false,
+    const std::vector<types::manifold_id> &manifold_priorities = {});
+
+
   /**
    * Overload of the previous function. Take a 2d Triangulation that is being
    * extruded. Differing from the previous function taking height and number of
@@ -1783,6 +1799,21 @@ namespace GridGenerator
     const bool                             copy_manifold_ids   = false,
     const std::vector<types::manifold_id> &manifold_priorities = {});
 
+  /**
+   * Overload of extrude_triangulation() to allow dimension independent
+   * code to compile. This function throws an error when called, as
+   * extrude_triangulation() is only implemented to extrude a dim=2 to a dim=3
+   * Triangulation.
+   */
+  void
+  extrude_triangulation(
+    const Triangulation<2, 2> &            input,
+    const std::vector<double> &            slice_coordinates,
+    Triangulation<2, 2> &                  result,
+    const bool                             copy_manifold_ids   = false,
+    const std::vector<types::manifold_id> &manifold_priorities = {});
+
+
 
   /**
    * Given an input triangulation @p in_tria, this function makes a new flat
index 4369210a6090856923e7afc03913d4c76a60070b..77a1b5e2ebac8c9cd37b78b19dad20a8871c52a2 100644 (file)
@@ -453,9 +453,12 @@ namespace GridTools
    * given angle (given in radians, rather than degrees). This function uses
    * the transform() function above, so the requirements on the triangulation
    * stated there hold for this function as well.
+   *
+   * @note This function is only supported for dim=2.
    */
+  template <int dim>
   void
-  rotate(const double angle, Triangulation<2> &triangulation);
+  rotate(const double angle, Triangulation<dim> &triangulation);
 
   /**
    * Rotate all vertices of the given @p triangulation in counter-clockwise
index ca7eaed28591d2d43637d1b49e86f8ed0091adc9..323a698c1191f9e1c480782587c21aa69d5b4a28 100644 (file)
@@ -6196,6 +6196,30 @@ namespace GridGenerator
 
 
 
+  void
+  extrude_triangulation(
+    const Triangulation<2, 2> &            input,
+    const unsigned int                     n_slices,
+    const double                           height,
+    Triangulation<2, 2> &                  result,
+    const bool                             copy_manifold_ids,
+    const std::vector<types::manifold_id> &manifold_priorities)
+  {
+    (void)input;
+    (void)n_slices;
+    (void)height;
+    (void)result;
+    (void)copy_manifold_ids;
+    (void)manifold_priorities;
+
+    AssertThrow(false,
+                ExcMessage(
+                  "GridTools::extrude_triangulation() is only available "
+                  "for Triangulation<3, 3> as output triangulation."));
+  }
+
+
+
   void
   extrude_triangulation(
     const Triangulation<2, 2> &            input,
@@ -6425,6 +6449,29 @@ namespace GridGenerator
   }
 
 
+
+  void
+  extrude_triangulation(
+    const Triangulation<2, 2> &            input,
+    const std::vector<double> &            slice_coordinates,
+    Triangulation<2, 2> &                  result,
+    const bool                             copy_manifold_ids,
+    const std::vector<types::manifold_id> &manifold_priorities)
+  {
+    (void)input;
+    (void)slice_coordinates;
+    (void)result;
+    (void)copy_manifold_ids;
+    (void)manifold_priorities;
+
+    AssertThrow(false,
+                ExcMessage(
+                  "GridTools::extrude_triangulation() is only available "
+                  "for Triangulation<3, 3> as output triangulation."));
+  }
+
+
+
   template <>
   void hyper_cube_with_cylindrical_hole(Triangulation<1> &,
                                         const double,
index 4a4cee06befefb9d40b007b12a059e15780629d0..f237ec2928f98321ed81dc74819d370ddc8e7eb8 100644 (file)
@@ -1068,13 +1068,25 @@ namespace GridTools
   }
 
 
-
+  template <>
   void
   rotate(const double angle, Triangulation<2> &triangulation)
   {
     transform(Rotate2d(angle), triangulation);
   }
 
+  template <>
+  void
+  rotate(const double angle, Triangulation<3> &triangulation)
+  {
+    (void)angle;
+    (void)triangulation;
+
+    AssertThrow(
+      false, ExcMessage("GridTools::rotate() is not available for dim = 3."));
+  }
+
+
   template <int dim>
   void
   rotate(const double           angle,

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.