From: Guido Kanschat Date: Thu, 20 Apr 2000 14:40:27 +0000 (+0000) Subject: experimental new grid X-Git-Tag: v8.0.0~20640 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b42be0c2fd0bb98b31ca4048a1526f46c0d71b9;p=dealii.git experimental new grid git-svn-id: https://svn.dealii.org/trunk@2760 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 2766019c0b..9675c23bac 100644 --- a/deal.II/deal.II/include/grid/grid_generator.h +++ b/deal.II/deal.II/include/grid/grid_generator.h @@ -107,6 +107,33 @@ class GridGenerator const double left = 0., const double right= 1.); + /** + * Hypercube with a layer of + * hypercubes around it. The + * first two parameters give the + * lower and upper bound of the + * inner hypercube in all + * coordinate directions. @p + * thickness marks the size of + * the layer cells. + * + * If the flag colorize is set, + * the outer cells get material + * id's according tho the + * following scheme: extending + * over the inner cube in + * x-direction: 2. In y-direction + * 4, in z-direction 8. The cells + * at corners and edges (3d) get + * these values bitwise or'd. + */ + template + static void enclosed_hyper_cube (Triangulation &tria, + const double left = 0., + const double right= 1., + const double thickness = 1., + bool colorize = false); + /** * Initialize the given triangulation with a * hyperball, i.e. a circle or a ball. diff --git a/deal.II/deal.II/source/grid/grid_generator.cc b/deal.II/deal.II/source/grid/grid_generator.cc index bee3e8b1ee..e0cad384a8 100644 --- a/deal.II/deal.II/source/grid/grid_generator.cc +++ b/deal.II/deal.II/source/grid/grid_generator.cc @@ -76,7 +76,8 @@ void GridGenerator::hyper_shell<> (Triangulation<1> &, template <> void GridGenerator::hyper_cube<> (Triangulation<2> &tria, const double left, - const double right) { + const double right) +{ const Point<2> vertices[4] = { Point<2>(left,left), Point<2>(right,left), Point<2>(right,right), @@ -90,9 +91,52 @@ void GridGenerator::hyper_cube<> (Triangulation<2> &tria, tria.create_triangulation (vector >(&vertices[0], &vertices[4]), cells, SubCellData()); // no boundary information -}; +} + +template<> +void GridGenerator::enclosed_hyper_cube (Triangulation<2> &tria, + const double l, + const double r, + const double d, + bool colorize) +{ + vector > vertices(16); + double coords[4]; + coords[0] = l-d; + coords[1] = l; + coords[2] = r; + coords[3] = r+d; + + unsigned int k=0; + for (unsigned int i0=0;i0<4;++i0) + for (unsigned int i1=0;i1<4;++i1) + vertices[k++] = Point<2>(coords[i1], coords[i0]); + + const unsigned char materials[9] = { 6,4,6, + 2,0,2, + 6,4,6 + }; + + vector > cells(9); + k = 0; + for (unsigned int i0=0;i0<3;++i0) + for (unsigned int i1=0;i1<3;++i1) + { + cells[k].vertices[0] = i1+4*i0; + cells[k].vertices[1] = i1+4*i0+1; + cells[k].vertices[2] = i1+4*i0+5; + cells[k].vertices[3] = i1+4*i0+4; + if (colorize) + cells[k].material_id = materials[k]; + ++k; + } + tria.create_triangulation (vertices, + cells, + SubCellData()); // no boundary information +} + template <> void GridGenerator::hyper_cube_slit<> (Triangulation<2> &tria, const double left,