]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
colorize shells
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 15 Feb 2008 00:33:15 +0000 (00:33 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 15 Feb 2008 00:33:15 +0000 (00:33 +0000)
git-svn-id: https://svn.dealii.org/trunk@15741 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/grid_generator.h
deal.II/deal.II/source/grid/grid_generator.cc

index 3f80fd465fafa3185ca9faec11c0a4b34f5f5783..27a78155bc2dfe75df2eaf700af61a353f3f2d35 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -46,7 +46,7 @@ template <typename number> class SparseMatrix;
  * @ingroup grid
  * @author Wolfgang Bangerth, Ralf Hartmann, Guido Kanschat, Stefan
  * Nauber, Joerg Weimar, Yaqi Wang, Luca Heltai, 1998, 1999, 2000, 2001, 2002,
- * 2003, 2006, 2007.
+ * 2003, 2006, 2007, 2008.
  */
 class GridGenerator
 {
@@ -491,6 +491,13 @@ class GridGenerator
                                      * <tt>inner_radius</tt> and
                                      * <tt>outer_radius</tt>.
                                      *
+                                     * If the flag @p colorize is @p
+                                     * true, then the outer boundary
+                                     * will have the id 1, while the
+                                     * inner boundary has id zero. If
+                                     * the flag is @p false, both
+                                     * have id zero.
+                                     *
                                      * In 2D, the number
                                      * <tt>n_cells</tt> of elements
                                      * for this initial triangulation
@@ -526,7 +533,8 @@ class GridGenerator
                             const Point<dim>     &center,
                             const double        inner_radius,
                             const double        outer_radius,
-                            const unsigned int  n_cells = 0);
+                            const unsigned int  n_cells = 0,
+                            bool colorize = false);
     
                                     /**
                                      * Produce a half hyper-shell,
index 2fa852a476abd69ec573a5713497fd278198ab03..f365c61c9d060f600662fd8f9481b932e101135f 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -1161,7 +1161,8 @@ void GridGenerator::hyper_shell (Triangulation<dim> &,
                                 const Point<dim> &,
                                 const double,
                                 const double,
-                                const unsigned int)
+                                const unsigned int,
+                                const bool)
 {
   Assert (false, ExcNotImplemented());
 }
@@ -1394,7 +1395,8 @@ void GridGenerator::hyper_shell (Triangulation<dim>   &tria,
                                 const Point<dim>     &center,
                                 const double        inner_radius,
                                 const double        outer_radius,
-                                const unsigned int  n_cells)
+                                const unsigned int  n_cells,
+                                const bool colorize)
 {
   Assert ((inner_radius > 0) && (inner_radius < outer_radius),
          ExcInvalidRadii ());
@@ -1447,6 +1449,29 @@ void GridGenerator::hyper_shell (Triangulation<dim>   &tria,
   
   tria.create_triangulation (
     vertices, cells, SubCellData());
+
+  if (colorize)
+    colorize_hyper_shell(tria, center, inner_radius, outer_radius);
+}
+
+
+template<int dim>
+void
+GridGenerator::colorize_hyper_shell (
+  Triangulation<dim>& tria,
+  const Point<dim>&, const double, const double)
+{
+                                  // Inspite of receiving geometrical
+                                  // data, we do this only based on
+                                  // topology.
+
+                                  // For the mesh based on  cube,
+                                  // this is highly irregular
+  for (typename Triangulation<dim>::cell_iterator cell = tria.begin();
+       cell != tria.end(); ++cell)
+    {
+      cell->face(2)->set_boundary_indicator(1);
+    }
 }
 
 
@@ -2100,7 +2125,8 @@ void GridGenerator::hyper_shell (Triangulation<dim>& tria,
                                 const Point<dim>& p,
                                 const double inner_radius,
                                 const double outer_radius,
-                                const unsigned int n)
+                                const unsigned int n,
+                                const bool colorize)
 {
   Assert ((inner_radius > 0) && (inner_radius < outer_radius),
          ExcInvalidRadii ());
@@ -2184,7 +2210,43 @@ void GridGenerator::hyper_shell (Triangulation<dim>& tria,
     }
   
   tria.create_triangulation (vertices, cells,
-                            SubCellData());       // no boundary information
+                            SubCellData());       // no boundary
+                                                  // information
+  
+  if (colorize)
+    colorize_hyper_shell(tria, p, inner_radius, outer_radius);
+}
+
+
+template<int dim>
+void
+GridGenerator::colorize_hyper_shell (
+  Triangulation<dim>& tria,
+  const Point<dim>&, const double, const double)
+{
+                                  // Inspite of receiving geometrical
+                                  // data, we do this only based on
+                                  // topology.
+
+                                  // For the mesh based on  cube,
+                                  // this is highly irregular
+  if (tria.n_cells() == 6)
+    {
+      typename Triangulation<dim>::cell_iterator cell = tria.begin();
+      cell->face(4)->set_boundary_indicator(1);
+      (++cell)->face(2)->set_boundary_indicator(1);
+      (++cell)->face(2)->set_boundary_indicator(1);
+      (++cell)->face(0)->set_boundary_indicator(1);
+      (++cell)->face(2)->set_boundary_indicator(1);
+      (++cell)->face(0)->set_boundary_indicator(1);      
+    }
+  else
+                                    // For higher polyhedra, this is regular.
+    {
+      for (typename Triangulation<dim>::cell_iterator cell = tria.begin();
+          cell != tria.end(); ++cell)
+       cell->face(5)->set_boundary_indicator(1);
+    }
 }
 
 
@@ -2615,38 +2677,6 @@ void GridGenerator::hyper_cube_with_cylindrical_hole(Triangulation<dim> &triangu
 #endif
 
 
-#if deal_II_dimension != 1
-
-// Empty implementation for 1d is above
-template <int dim>
-void
-GridGenerator::colorize_hyper_shell(
-  Triangulation<dim>& tria,
-  const Point<dim>& center,
-  const double inner_radius,
-  const double outer_radius)
-{
-  double divide = .5*(inner_radius+outer_radius);
-  divide *= divide;
-  
-  for (typename Triangulation<dim>::cell_iterator it = tria.begin();
-       it != tria.end(); ++it)
-    for (unsigned int f=0;f<GeometryInfo<dim>::faces_per_cell;++f)
-      if (it->at_boundary(f))
-       {
-                                          // Take first vertex of
-                                          // boundary face
-         Point<dim> p = it->face(f)->vertex(0);
-         p -= center;
-         if (p.square() > divide)
-           it->face(f)->set_boundary_indicator(1);
-       }
-}
-
-
-#endif
-
-
 // explicit instantiations
 template void
 GridGenerator::hyper_cube<deal_II_dimension> (
@@ -2708,7 +2738,7 @@ GridGenerator::hyper_cube_slit (
 template void
 GridGenerator::hyper_shell (
   Triangulation<deal_II_dimension>&,
-  const Point<deal_II_dimension>&, double, double, unsigned int);
+  const Point<deal_II_dimension>&, double, double, unsigned int, bool);
 
 
 template void

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.