From 8deac75b293f10ad0233ce5d2d9424c15b554886 Mon Sep 17 00:00:00 2001 From: kanschat Date: Fri, 15 Feb 2008 00:33:15 +0000 Subject: [PATCH] colorize shells git-svn-id: https://svn.dealii.org/trunk@15741 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/grid_generator.h | 14 ++- deal.II/deal.II/source/grid/grid_generator.cc | 106 +++++++++++------- 2 files changed, 79 insertions(+), 41 deletions(-) diff --git a/deal.II/deal.II/include/grid/grid_generator.h b/deal.II/deal.II/include/grid/grid_generator.h index 3f80fd465f..27a78155bc 100644 --- a/deal.II/deal.II/include/grid/grid_generator.h +++ b/deal.II/deal.II/include/grid/grid_generator.h @@ -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 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 * inner_radius and * outer_radius. * + * 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 * n_cells of elements * for this initial triangulation @@ -526,7 +533,8 @@ class GridGenerator const Point ¢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, diff --git a/deal.II/deal.II/source/grid/grid_generator.cc b/deal.II/deal.II/source/grid/grid_generator.cc index 2fa852a476..f365c61c9d 100644 --- a/deal.II/deal.II/source/grid/grid_generator.cc +++ b/deal.II/deal.II/source/grid/grid_generator.cc @@ -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 &, const Point &, const double, const double, - const unsigned int) + const unsigned int, + const bool) { Assert (false, ExcNotImplemented()); } @@ -1394,7 +1395,8 @@ void GridGenerator::hyper_shell (Triangulation &tria, const Point ¢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 ()); @@ -1447,6 +1449,29 @@ void GridGenerator::hyper_shell (Triangulation &tria, tria.create_triangulation ( vertices, cells, SubCellData()); + + if (colorize) + colorize_hyper_shell(tria, center, inner_radius, outer_radius); +} + + +template +void +GridGenerator::colorize_hyper_shell ( + Triangulation& tria, + const Point&, 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::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& tria, const Point& 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& 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 +void +GridGenerator::colorize_hyper_shell ( + Triangulation& tria, + const Point&, 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::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::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 &triangu #endif -#if deal_II_dimension != 1 - -// Empty implementation for 1d is above -template -void -GridGenerator::colorize_hyper_shell( - Triangulation& tria, - const Point& center, - const double inner_radius, - const double outer_radius) -{ - double divide = .5*(inner_radius+outer_radius); - divide *= divide; - - for (typename Triangulation::cell_iterator it = tria.begin(); - it != tria.end(); ++it) - for (unsigned int f=0;f::faces_per_cell;++f) - if (it->at_boundary(f)) - { - // Take first vertex of - // boundary face - Point 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 ( @@ -2708,7 +2738,7 @@ GridGenerator::hyper_cube_slit ( template void GridGenerator::hyper_shell ( Triangulation&, - const Point&, double, double, unsigned int); + const Point&, double, double, unsigned int, bool); template void -- 2.39.5