]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fixed colorization for GridGenerator::half_hyper_shell 900/head
authorDaniel Arndt <d.arndt@math.uni-goettingen.de>
Tue, 5 May 2015 08:30:07 +0000 (10:30 +0200)
committerDaniel Arndt <d.arndt@math.uni-goettingen.de>
Tue, 5 May 2015 12:44:29 +0000 (14:44 +0200)
doc/news/changes.h
include/deal.II/grid/grid_generator.h
source/grid/grid_generator.cc

index 822adabc748b270b4dc1594a2db10563747cf92d..e0a089473e18eddc98e3e873533682b5ba935664 100644 (file)
@@ -472,6 +472,11 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li> Fixed: GridGenerator::half_hyper_shell can now be colorized.
+  <br>
+  (Daniel Arndt, 2015/05/05)
+  </li>
+
   <li> New: The function VectorTools::point_gradient has been added to compute
   the gradient of a given FE function.
   <br>
index 3f51f26a31580d76a1be4700d8c036ce6803f235..0fbc8f959fdbc51736d81ac77fdfa571adcc8506 100644 (file)
@@ -506,9 +506,9 @@ namespace GridGenerator
    * computed adaptively such that the resulting elements have the least
    * aspect ratio.
    *
-   * If colorize is set to true, the inner, outer, left, and right boundary
-   * get indicator 0, 1, 2, and 3, respectively. Otherwise all indicators are
-   * set to 0.
+   * If colorize is set to true, the inner, outer, and the part of the boundary
+   * where $x=0$, get indicator 0, 1, and 2, respectively. Otherwise all
+   * indicators are set to 0.
    *
    * @note The triangulation needs to be void upon calling this function.
    */
index 4c2439ecde4fa368045acb1595df2772ccde97cb..7e7fa1641c795c462e6bb6738f9827e9ab27b63e 100644 (file)
@@ -3026,10 +3026,8 @@ namespace GridGenerator
                     const unsigned int n,
                     const bool colorize)
   {
-    (void)colorize;
     Assert ((inner_radius > 0) && (inner_radius < outer_radius),
             ExcInvalidRadii ());
-    Assert(colorize == false, ExcNotImplemented());
 
     if (n <= 5)
       {
@@ -3091,7 +3089,38 @@ namespace GridGenerator
       {
         Assert(false, ExcIndexRange(n, 0, 5));
       }
+    if (colorize)
+      {
+        // We want to use a standard boundary description where
+        // the boundary is not curved. Hence set boundary id 2 to
+        // to all faces in a first step.
+        typename Triangulation<3>::cell_iterator cell = tria.begin();
+        for (; cell!=tria.end(); ++cell)
+          for (unsigned int i=0; i<GeometryInfo<3>::faces_per_cell; ++i)
+            if (cell->at_boundary(i))
+              cell->face(i)->set_all_boundary_ids(2);
+
+        // Next look for the curved boundaries. If the first component is
+        // not near to zero, the boundary is curved. Then decide whether the center
+        // is nearer to the inner or outer boundary to set the correct boundary id.
+        for (cell=tria.begin(); cell!=tria.end(); ++cell)
+          for (unsigned int i=0; i<GeometryInfo<3>::faces_per_cell; ++i)
+            if (cell->at_boundary(i))
+              {
+                const typename Triangulation<3>::face_iterator face
+                  = cell->face(i);
 
+                const Point<3> face_center (face->center());
+                if (std::abs((face_center(0)-center(0)) > 1.e-3))
+                  {
+                    if (std::abs((face_center-center).norm()-inner_radius) <
+                        std::abs((face_center-center).norm()-outer_radius))
+                      face->set_all_boundary_ids(0);
+                    else
+                      face->set_all_boundary_ids(1);
+                  }
+              }
+      }
   }
 
 

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.