From: Timo Heister Date: Tue, 13 Oct 2015 18:02:07 +0000 (-0400) Subject: remove duplicate code X-Git-Tag: v8.4.0-rc2~313^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8362cd67a839c5e0b85950af51592a01645782c8;p=dealii.git remove duplicate code --- diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index 2173a50d25..cd984b565c 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -765,77 +765,20 @@ namespace GridGenerator -// Parallelepiped implementation in 1d, 2d, and 3d. @note The -// implementation in 1d is similar to hyper_rectangle(), and in 2d is -// similar to parallelogram(). -// -// The GridReordering::reorder_grid is made use of towards the end of -// this function. Thus the triangulation is explicitly constructed for -// all dim here since it is slightly different in that respect -// (cf. hyper_rectangle(), parallelogram()). template void parallelepiped (Triangulation &tria, const Point (&corners) [dim], const bool colorize) { - // Check that none of the user defined vertices overlap + unsigned int n_subdivisions [dim]; for (unsigned int i=0; i > vertices (GeometryInfo::vertices_per_cell); - - switch (dim) - { - // A line (1d parallelepiped) - case 1: - vertices[1] = corners[0]; - break; - - // A parallelogram (2d parallelepiped) - case 2: - // assign corners to vertices: - vertices[1] = corners[0]; - vertices[2] = corners[1]; - - // compose the remaining vertex: - vertices[3] = vertices[1] + vertices[2]; - break; - - // A parallelepiped (3d parallelepiped) - case 3: - // assign corners to vertices: - vertices[1] = corners[0]; - vertices[2] = corners[1]; - vertices[4] = corners[2]; - - // compose the remaining vertices: - vertices[3] = vertices[1] + vertices[2]; - vertices[5] = vertices[1] + vertices[4]; - vertices[6] = vertices[2] + vertices[4]; - vertices[7] = vertices[1] + vertices[2] + vertices[4]; - break; + n_subdivisions[i] = 1; - default: - Assert (false, ExcNotImplemented()); - } - - // Prepare cell data and wipe material identity - std::vector > cells (1); - for (unsigned int i=0; i::vertices_per_cell; ++i) - cells[0].vertices[i] = i; - cells[0].material_id = 0; - - // Check ordering of vertices and create triangulation - GridReordering::reorder_cells (cells); - tria.create_triangulation (vertices, cells, SubCellData()); - - // Finally assign boundary indicators according to hyper_rectangle - if (colorize) - colorize_hyper_rectangle (tria); + // and call the function below + subdivided_parallelepiped (tria, n_subdivisions, + corners, + colorize); } template @@ -857,6 +800,14 @@ namespace GridGenerator colorize); } + // Parallelepiped implementation in 1d, 2d, and 3d. @note The + // implementation in 1d is similar to hyper_rectangle(), and in 2d is + // similar to parallelogram(). + // + // The GridReordering::reorder_grid is made use of towards the end of + // this function. Thus the triangulation is explicitly constructed for + // all dim here since it is slightly different in that respect + // (cf. hyper_rectangle(), parallelogram()). template void subdivided_parallelepiped (Triangulation &tria,