]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Colorize hyper recangle with simplices
authorNils Much <nils.much@tum.de>
Mon, 4 Mar 2024 13:10:14 +0000 (14:10 +0100)
committerNils Much <nils.much@tum.de>
Wed, 6 Mar 2024 08:06:24 +0000 (09:06 +0100)
source/grid/grid_generator.cc

index cab46331126e6f8ff4bceb31af4bafb6b83a03ab..dbd0b28e4fdcde1467344c227209d316bd2b7108 100644 (file)
@@ -2634,7 +2634,7 @@ namespace GridGenerator
         // use a large epsilon to
         // compare numbers to avoid
         // roundoff problems.
-        double epsilon = 10;
+        double epsilon = std::numeric_limits<double>::max();
         for (unsigned int i = 0; i < dim; ++i)
           epsilon = std::min(epsilon, 0.01 * delta[i][i]);
         Assert(epsilon > 0,
@@ -8645,8 +8645,6 @@ namespace GridGenerator
   {
     AssertDimension(dim, spacedim);
 
-    AssertThrow(colorize == false, ExcNotImplemented());
-
     std::vector<Point<spacedim>> vertices;
     std::vector<CellData<dim>>   cells;
 
@@ -8782,11 +8780,34 @@ namespace GridGenerator
       }
     else
       {
-        AssertThrow(colorize == false, ExcNotImplemented());
+        AssertThrow(false, ExcNotImplemented());
       }
 
     // actually create triangulation
     tria.create_triangulation(vertices, cells, SubCellData());
+
+    if (colorize)
+      {
+        // to colorize, run through all
+        // faces of all cells and set
+        // boundary indicator to the
+        // correct value if it was 0.
+
+        // use a large epsilon to
+        // compare numbers to avoid
+        // roundoff problems.
+        double epsilon = std::numeric_limits<double>::max();
+        for (unsigned int i = 0; i < dim; ++i)
+          epsilon = std::min(epsilon,
+                             0.01 * (std::abs(p2[i] - p1[i]) / repetitions[i]));
+        Assert(epsilon > 0,
+               ExcMessage(
+                 "The distance between corner points must be positive."));
+
+        // actual code is external since
+        // 1-D is different from 2/3d.
+        colorize_subdivided_hyper_rectangle(tria, p1, p2, epsilon);
+      }
   }
 
 

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.