// $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
* @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
{
* <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
const Point<dim> ¢er,
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,
// $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
const Point<dim> &,
const double,
const double,
- const unsigned int)
+ const unsigned int,
+ const bool)
{
Assert (false, ExcNotImplemented());
}
const Point<dim> ¢er,
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 ());
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);
+ }
}
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 ());
}
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);
+ }
}
#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> (
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