]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix GridGenerator::merge_triangulations docu and use switch
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 9 Jul 2018 23:34:10 +0000 (01:34 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 11 Jul 2018 08:38:11 +0000 (10:38 +0200)
include/deal.II/grid/grid_generator.h
source/grid/grid_generator.cc

index b801236da0f465df02f1ae7fbc11ffdb1a297310..44eaaecbaa23fe773bde6c8901eb0bad94b34f55 100644 (file)
@@ -985,10 +985,10 @@ namespace GridGenerator
    *
    * @note The function copies the material ids of the cells of the two input
    * triangulations into the output triangulation. If @p copy_manifold_ids is
-   * activated, manifold ids will be copied. Currently, boundary_ids are never
+   * set to @p true, manifold ids will be copied. Boundary indicators are never
    * copied. In other words, if the two coarse meshes have anything but the
-   * default boundary indicators, then you will currently have to set boundary
-   * indicators again by hand in the output triangulation.
+   * default boundary indicators, then you will have to set boundary indicators
+   * again by hand in the output triangulation.
    *
    * @note Unlike most GridGenerator functions, this function does not attach
    * any manifolds to @p result, nor does it set any manifold ids.
index f994bf8ecd8d99d8d4cecaafdc04761fce98d5d8..efae7cc64aee2fa2d56662d3836dc6f8b7271910 100644 (file)
@@ -3839,89 +3839,101 @@ namespace GridGenerator
     SubCellData subcell_data;
     if (copy_manifold_ids)
       {
-        if (dim == 2)
+        switch (dim)
           {
-            subcell_data.boundary_lines.reserve(triangulation_1.n_lines() +
-                                                triangulation_2.n_lines());
-
-            auto copy_line_manifold_ids =
-              [&](const Triangulation<dim, spacedim> &tria,
-                  const unsigned int                  offset) {
-                for (typename Triangulation<dim, spacedim>::line_iterator line =
-                       tria.begin_face();
-                     line != tria.end_face();
-                     ++line)
-                  if (line->manifold_id() != numbers::flat_manifold_id)
-                    {
-                      CellData<1> boundary_line;
-                      boundary_line.vertices[0] =
-                        line->vertex_index(0) + offset;
-                      boundary_line.vertices[1] =
-                        line->vertex_index(1) + offset;
-                      boundary_line.manifold_id = line->manifold_id();
-                      subcell_data.boundary_lines.push_back(
-                        std::move(boundary_line));
-                    }
-              };
+            case 1:
+              break;
 
-            copy_line_manifold_ids(triangulation_1, 0);
-            copy_line_manifold_ids(triangulation_2,
-                                   triangulation_1.n_vertices());
-          }
+            case 2:
+              {
+                subcell_data.boundary_lines.reserve(triangulation_1.n_lines() +
+                                                    triangulation_2.n_lines());
+
+                auto copy_line_manifold_ids =
+                  [&](const Triangulation<dim, spacedim> &tria,
+                      const unsigned int                  offset) {
+                    for (typename Triangulation<dim, spacedim>::line_iterator
+                           line = tria.begin_face();
+                         line != tria.end_face();
+                         ++line)
+                      if (line->manifold_id() != numbers::flat_manifold_id)
+                        {
+                          CellData<1> boundary_line;
+                          boundary_line.vertices[0] =
+                            line->vertex_index(0) + offset;
+                          boundary_line.vertices[1] =
+                            line->vertex_index(1) + offset;
+                          boundary_line.manifold_id = line->manifold_id();
+                          subcell_data.boundary_lines.push_back(
+                            std::move(boundary_line));
+                        }
+                  };
 
-        if (dim == 3)
-          {
-            subcell_data.boundary_quads.reserve(triangulation_1.n_quads() +
-                                                triangulation_2.n_quads());
-            // we can't do better here than to loop over all the lines bounding
-            // a face. For regular meshes an (interior) line in 3D is part of
-            // four cells. So this should be an appropriate guess.
-            subcell_data.boundary_lines.reserve(triangulation_1.n_cells() * 4 +
-                                                triangulation_2.n_cells() * 4);
-
-            auto copy_face_and_line_manifold_ids =
-              [&](const Triangulation<dim, spacedim> &tria,
-                  const unsigned int                  offset) {
-                for (typename Triangulation<dim, spacedim>::face_iterator face =
-                       tria.begin_face();
-                     face != tria.end_face();
-                     ++face)
-                  if (face->manifold_id() != numbers::flat_manifold_id)
-                    {
-                      CellData<2> boundary_quad;
-                      boundary_quad.vertices[0] =
-                        face->vertex_index(0) + offset;
-                      boundary_quad.vertices[1] =
-                        face->vertex_index(1) + offset;
-                      boundary_quad.vertices[2] =
-                        face->vertex_index(2) + offset;
-                      boundary_quad.vertices[3] =
-                        face->vertex_index(3) + offset;
-
-                      boundary_quad.manifold_id = face->manifold_id();
-                      subcell_data.boundary_quads.push_back(
-                        std::move(boundary_quad));
-                    }
-                for (const auto &cell : tria.cell_iterators())
-                  for (unsigned int l = 0; l < 12; ++l)
-                    if (cell->line(l)->manifold_id() !=
-                        numbers::flat_manifold_id)
-                      {
-                        CellData<1> boundary_line;
-                        boundary_line.vertices[0] =
-                          cell->line(l)->vertex_index(0) + offset;
-                        boundary_line.vertices[1] =
-                          cell->line(l)->vertex_index(1) + offset;
-                        boundary_line.manifold_id =
-                          cell->line(l)->manifold_id();
-                        subcell_data.boundary_lines.push_back(
-                          std::move(boundary_line));
-                      }
-              };
+                copy_line_manifold_ids(triangulation_1, 0);
+                copy_line_manifold_ids(triangulation_2,
+                                       triangulation_1.n_vertices());
+                break;
+              }
+
+            case 3:
+              {
+                subcell_data.boundary_quads.reserve(triangulation_1.n_quads() +
+                                                    triangulation_2.n_quads());
+                // we can't do better here than to loop over all the lines
+                // bounding a face. For regular meshes an (interior) line in 3D
+                // is part of four cells. So this should be an appropriate
+                // guess.
+                subcell_data.boundary_lines.reserve(
+                  triangulation_1.n_cells() * 4 +
+                  triangulation_2.n_cells() * 4);
+
+                auto copy_face_and_line_manifold_ids =
+                  [&](const Triangulation<dim, spacedim> &tria,
+                      const unsigned int                  offset) {
+                    for (typename Triangulation<dim, spacedim>::face_iterator
+                           face = tria.begin_face();
+                         face != tria.end_face();
+                         ++face)
+                      if (face->manifold_id() != numbers::flat_manifold_id)
+                        {
+                          CellData<2> boundary_quad;
+                          boundary_quad.vertices[0] =
+                            face->vertex_index(0) + offset;
+                          boundary_quad.vertices[1] =
+                            face->vertex_index(1) + offset;
+                          boundary_quad.vertices[2] =
+                            face->vertex_index(2) + offset;
+                          boundary_quad.vertices[3] =
+                            face->vertex_index(3) + offset;
+
+                          boundary_quad.manifold_id = face->manifold_id();
+                          subcell_data.boundary_quads.push_back(
+                            std::move(boundary_quad));
+                        }
+                    for (const auto &cell : tria.cell_iterators())
+                      for (unsigned int l = 0; l < 12; ++l)
+                        if (cell->line(l)->manifold_id() !=
+                            numbers::flat_manifold_id)
+                          {
+                            CellData<1> boundary_line;
+                            boundary_line.vertices[0] =
+                              cell->line(l)->vertex_index(0) + offset;
+                            boundary_line.vertices[1] =
+                              cell->line(l)->vertex_index(1) + offset;
+                            boundary_line.manifold_id =
+                              cell->line(l)->manifold_id();
+                            subcell_data.boundary_lines.push_back(
+                              std::move(boundary_line));
+                          }
+                  };
 
-            copy_face_and_line_manifold_ids(triangulation_1, 0);
-            copy_face_and_line_manifold_ids(triangulation_2,
-                                            triangulation_1.n_vertices());
+                copy_face_and_line_manifold_ids(triangulation_1, 0);
+                copy_face_and_line_manifold_ids(triangulation_2,
+                                                triangulation_1.n_vertices());
+                break;
+              }
+            default:
+              Assert(false, ExcNotImplemented());
           }
       }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.