From f165b10aae948b6235ef5380522fc613c5dc65e1 Mon Sep 17 00:00:00 2001 From: guido Date: Sun, 13 May 2001 16:13:55 +0000 Subject: [PATCH] boundary components for rectangle git-svn-id: https://svn.dealii.org/trunk@4596 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/grid_generator.h | 15 ++++++++- deal.II/deal.II/source/grid/grid_generator.cc | 33 ++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/deal.II/deal.II/include/grid/grid_generator.h b/deal.II/deal.II/include/grid/grid_generator.h index 9efb810973..981cb1bf16 100644 --- a/deal.II/deal.II/include/grid/grid_generator.h +++ b/deal.II/deal.II/include/grid/grid_generator.h @@ -130,6 +130,18 @@ class GridGenerator * diagonally opposite corner * points @p{p1} and @p{p2}. * + * If the @p{colorize} flag is + * set, the + * @p{boundary_indicator}s of the + * surfaces are assigned, such + * that the lower one in + * @p{x}-direction is 0, the + * upper one is 1. The indicators + * for the surfaces in + * @p{y}-direction are 2 and 3, + * the ones for @p{z} are 4 and + * 6. + * * The triangulation needs to be * void upon calling this * function. @@ -137,7 +149,8 @@ class GridGenerator template static void hyper_rectangle (Triangulation &tria, const Point& p1, - const Point& p2); + const Point& p2, + bool colorize = false); /** * Hypercube with a layer of diff --git a/deal.II/deal.II/source/grid/grid_generator.cc b/deal.II/deal.II/source/grid/grid_generator.cc index d7bf33148a..ff3ed65823 100644 --- a/deal.II/deal.II/source/grid/grid_generator.cc +++ b/deal.II/deal.II/source/grid/grid_generator.cc @@ -14,13 +14,16 @@ #include #include +#include +#include #include template void GridGenerator::hyper_rectangle (Triangulation& tria, const Point& p_1, - const Point& p_2) + const Point& p_2, + bool colorize) { // First, normalize input such that // p1 is lower in all coordinate directions. @@ -89,6 +92,34 @@ void GridGenerator::hyper_rectangle (Triangulation& tria, cells[0].material_id = 0; 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) + { + typename Triangulation::cell_iterator cell = tria.begin(); + switch(dim) + { + 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: + 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: + Assert(false, ExcNotImplemented()); + } + } +#endif } -- 2.39.5