From: Wolfgang Bangerth Date: Mon, 14 May 2001 20:42:52 +0000 (+0000) Subject: Fix a 1d problem. Clean up slightly. X-Git-Tag: v8.0.0~19188 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e44e83b61b0e9516a389059a73b5c187b19305c;p=dealii.git Fix a 1d problem. Clean up slightly. git-svn-id: https://svn.dealii.org/trunk@4603 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/grid_generator.h b/deal.II/deal.II/include/grid/grid_generator.h index 981cb1bf16..d64b3ddec1 100644 --- a/deal.II/deal.II/include/grid/grid_generator.h +++ b/deal.II/deal.II/include/grid/grid_generator.h @@ -140,7 +140,7 @@ class GridGenerator * for the surfaces in * @p{y}-direction are 2 and 3, * the ones for @p{z} are 4 and - * 6. + * 5. * * The triangulation needs to be * void upon calling this @@ -150,7 +150,7 @@ class GridGenerator static void hyper_rectangle (Triangulation &tria, const Point& p1, const Point& p2, - bool colorize = false); + const bool colorize = false); /** * Hypercube with a layer of @@ -307,6 +307,16 @@ class GridGenerator * Exception */ DeclException0 (ExcInvalidRadii); + + private: + /** + * Perform the action specified + * by the @p{colorize} flag of + * the @ref{hyper_rectangle} + * function of this class. + */ + template + static void colorize_hyper_rectangle (Triangulation &tria); }; diff --git a/deal.II/deal.II/source/grid/grid_generator.cc b/deal.II/deal.II/source/grid/grid_generator.cc index ff3ed65823..6c4ba8baa7 100644 --- a/deal.II/deal.II/source/grid/grid_generator.cc +++ b/deal.II/deal.II/source/grid/grid_generator.cc @@ -20,10 +20,11 @@ template -void GridGenerator::hyper_rectangle (Triangulation& tria, - const Point& p_1, - const Point& p_2, - bool colorize) +void +GridGenerator::hyper_rectangle (Triangulation &tria, + const Point &p_1, + const Point &p_2, + const bool colorize) { // First, normalize input such that // p1 is lower in all coordinate directions. @@ -93,35 +94,51 @@ void GridGenerator::hyper_rectangle (Triangulation& tria, tria.create_triangulation (vertices, cells, SubCellData()); - // Have to do this, since there are - // no faces in 1D -#if (deal_II_dimension>1) // Assign boundary indicators if (colorize) + colorize_hyper_rectangle (tria); +} + + + +template <> +void +GridGenerator::colorize_hyper_rectangle (Triangulation<1> &) +{ + // nothing to do in 1d +}; + + +#if deal_II_dimension != 1 + +template +void +GridGenerator::colorize_hyper_rectangle (Triangulation &tria) +{ + // there is only one cell, so + // simple task + const typename Triangulation::cell_iterator cell = tria.begin(); + switch(dim) { - typename Triangulation::cell_iterator cell = tria.begin(); - switch(dim) - { - case 2: + case 2: cell->face(0)->set_boundary_indicator (2); cell->face(1)->set_boundary_indicator (1); cell->face(2)->set_boundary_indicator (3); cell->face(3)->set_boundary_indicator (0); break; - case 3: + case 3: cell->face(0)->set_boundary_indicator (2); cell->face(1)->set_boundary_indicator (3); cell->face(2)->set_boundary_indicator (4); cell->face(3)->set_boundary_indicator (1); cell->face(4)->set_boundary_indicator (5); cell->face(5)->set_boundary_indicator (0); - default: + default: Assert(false, ExcNotImplemented()); - } - } -#endif -} + }; +}; +#endif template @@ -145,7 +162,8 @@ void GridGenerator::hyper_cube(Triangulation &tria, template <> void GridGenerator::hyper_cube_slit<> (Triangulation<1> &, const double, - const double) { + const double) +{ Assert (false, ExcInternalError()); }; @@ -154,7 +172,8 @@ void GridGenerator::hyper_cube_slit<> (Triangulation<1> &, template <> void GridGenerator::hyper_L<> (Triangulation<1> &, const double, - const double) { + const double) +{ Assert (false, ExcInternalError()); }; @@ -163,7 +182,8 @@ void GridGenerator::hyper_L<> (Triangulation<1> &, template <> void GridGenerator::hyper_ball<> (Triangulation<1> &, const Point<1> &, - const double) { + const double) +{ Assert (false, ExcInternalError()); }; @@ -229,9 +249,11 @@ void GridGenerator::enclosed_hyper_cube (Triangulation<2> &tria, template <> -void GridGenerator::hyper_cube_slit<> (Triangulation<2> &tria, - const double left, - const double right) { +void +GridGenerator::hyper_cube_slit<> (Triangulation<2> &tria, + const double left, + const double right) +{ const double rl2=(right+left)/2; const Point<2> vertices[10] = { Point<2>(left, left ), Point<2>(rl2, left ), @@ -262,9 +284,11 @@ void GridGenerator::hyper_cube_slit<> (Triangulation<2> &tria, template <> -void GridGenerator::hyper_L<> (Triangulation<2> &tria, - const double a, - const double b) { +void +GridGenerator::hyper_L<> (Triangulation<2> &tria, + const double a, + const double b) +{ const unsigned int dim=2; const Point vertices[8] = { Point (a,a), Point ((a+b)/2,a), @@ -295,12 +319,15 @@ void GridGenerator::hyper_L<> (Triangulation<2> &tria, template <> -void GridGenerator::hyper_ball<> (Triangulation<2> &tria, - const Point<2> &p, - const double radius) { - const double a = 1./(1+sqrt(2.0)); // equilibrate cell sizes at transition - // from the inner part to the radial - // cells +void +GridGenerator::hyper_ball<> (Triangulation<2> &tria, + const Point<2> &p, + const double radius) +{ + // equilibrate cell sizes at + // transition from the inner part + // to the radial cells + const double a = 1./(1+sqrt(2.0)); const Point<2> vertices[8] = { p+Point<2>(-1,-1)*(radius/sqrt(2.0)), p+Point<2>(+1,-1)*(radius/sqrt(2.0)), p+Point<2>(-1,-1)*(radius/sqrt(2.0)*a), @@ -395,11 +422,12 @@ void GridGenerator::hyper_shell<> (Triangulation<2> &tria, template <> -void GridGenerator::half_hyper_shell<> (Triangulation<2> &tria, - const Point<2> ¢er, - const double inner_radius, - const double outer_radius, - const unsigned int n_cells) +void +GridGenerator::half_hyper_shell<> (Triangulation<2> &tria, + const Point<2> ¢er, + const double inner_radius, + const double outer_radius, + const unsigned int n_cells) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), ExcInvalidRadii ()); @@ -531,18 +559,22 @@ void GridGenerator::enclosed_hyper_cube (Triangulation<3> &tria, cells, SubCellData()); // no boundary information } - + + + template <> -void GridGenerator::hyper_L<> (Triangulation<3> &tria, - const double a, - const double b) { +void +GridGenerator::hyper_L<> (Triangulation<3> &tria, + const double a, + const double b) +{ const unsigned int dim=3; // we slice out the top back right // part of the cube const Point vertices[26] = { // front face of the big cube - Point (a, a,a), + Point (a, a,a), Point ((a+b)/2,a,a), Point (b, a,a), Point (a, a,(a+b)/2), @@ -597,9 +629,10 @@ void GridGenerator::hyper_L<> (Triangulation<3> &tria, template <> -void GridGenerator::hyper_ball<> (Triangulation<3> &tria, - const Point<3> &p, - const double radius) +void +GridGenerator::hyper_ball<> (Triangulation<3> &tria, + const Point<3> &p, + const double radius) { // this function used to be // implemented by the code below, @@ -674,6 +707,7 @@ void GridGenerator::hyper_ball<> (Triangulation<3> &tria, }; + template <> void GridGenerator::hyper_shell<> (Triangulation<3> &, const Point<3> &, @@ -698,10 +732,3 @@ GridGenerator::hyper_cube (Triangulation &, const double, const double); -// template void GridGenerator::hyper_L (Triangulation &, -// const double, -// const double); -// template void GridGenerator::hyper_ball (Triangulation &, -// const Point &, -// const double); -