From 91b837562622ba100cad9a8870d520031780420d Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Wed, 28 Dec 2005 12:39:40 +0000 Subject: [PATCH] subdivided_hyper_cube added in 3D enclosed_hyper_cube in 3D adapted to new numbering scheme git-svn-id: https://svn.dealii.org/trunk@11931 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/grid/grid_generator.cc | 98 ++++++++++++------- 1 file changed, 62 insertions(+), 36 deletions(-) diff --git a/deal.II/deal.II/source/grid/grid_generator.cc b/deal.II/deal.II/source/grid/grid_generator.cc index 13d080b579..a976647ff0 100644 --- a/deal.II/deal.II/source/grid/grid_generator.cc +++ b/deal.II/deal.II/source/grid/grid_generator.cc @@ -215,31 +215,57 @@ GridGenerator::subdivided_hyper_cube (Triangulation &tria, // next create the cells // Prepare cell data std::vector > cells; + // Define these as abbreviations + // for the step sizes below. The + // number of points in a single + // direction is repetitions+1 + const unsigned int dy = repetitions+1; + const unsigned int dz = dy*dy; switch (dim) { case 1: - cells.resize (repetitions); - for (unsigned int x=0; x &tria, coords[3] = r+d; unsigned int k=0; - for (unsigned int i0=0;i0<4;++i0) - for (unsigned int i1=0;i1<4;++i1) - for (unsigned int i2=0;i2<4;++i2) - vertices[k++] = Point(coords[i2], coords[i1], coords[i0]); + for (unsigned int z=0;z<4;++z) + for (unsigned int y=0;y<4;++y) + for (unsigned int x=0;x<4;++x) + vertices[k++] = Point(coords[x], coords[y], coords[z]); const unsigned char materials[27] = { 21,20,22, @@ -1035,18 +1061,18 @@ void GridGenerator::enclosed_hyper_cube (Triangulation &tria, std::vector > cells(27); k = 0; - for (unsigned int i0=0;i0<3;++i0) - for (unsigned int i1=0;i1<3;++i1) - for (unsigned int i2=0;i2<3;++i2) + for (unsigned int z=0;z<3;++z) + for (unsigned int y=0;y<3;++y) + for (unsigned int x=0;x<3;++x) { - cells[k].vertices[0] = i2+4*i1+16*i0; - cells[k].vertices[1] = i2+4*i1+16*i0+1; - cells[k].vertices[2] = i2+4*i1+16*i0+16; - cells[k].vertices[3] = i2+4*i1+16*i0+17; - cells[k].vertices[4] = i2+4*i1+16*i0+4; - cells[k].vertices[5] = i2+4*i1+16*i0+5; - cells[k].vertices[6] = i2+4*i1+16*i0+20; - cells[k].vertices[7] = i2+4*i1+16*i0+21; + cells[k].vertices[0] = x+4*y+16*z; + cells[k].vertices[1] = x+4*y+16*z+1; + cells[k].vertices[2] = x+4*y+16*z+4; + cells[k].vertices[3] = x+4*y+16*z+5; + cells[k].vertices[4] = x+4*y+16*z+16; + cells[k].vertices[5] = x+4*y+16*z+17; + cells[k].vertices[6] = x+4*y+16*z+20; + cells[k].vertices[7] = x+4*y+16*z+21; if (colorize) cells[k].material_id = materials[k]; ++k; -- 2.39.5