]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Don't save default data in GridTools::get_coarse_mesh_description().
authorDavid Wells <drwells@email.unc.edu>
Mon, 9 May 2022 15:45:41 +0000 (11:45 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 9 May 2022 21:08:25 +0000 (17:08 -0400)
Saving every line and face takes up a huge amount of memory and time when, in
practice, this data is not that useful.

doc/news/changes/incompatibilities/20220509DavidWells [new file with mode: 0644]
source/grid/grid_tools.cc

diff --git a/doc/news/changes/incompatibilities/20220509DavidWells b/doc/news/changes/incompatibilities/20220509DavidWells
new file mode 100644 (file)
index 0000000..e959f33
--- /dev/null
@@ -0,0 +1,9 @@
+Improved: GridTools::get_coarse_mesh_description() no longer returns subcell data
+corresponding to default values (i.e., when the manifold_id is
+numbers::flat_manifold_id and when the boundary_id is
+numbers::internal_face_boundary_id). By skipping this data, which is not required by
+Triangulation::create_triangulation(), the total amount of data returned by this
+function is significantly lowered (and, therefore, so is the cost of creating a new
+Triangulation from the output).
+<br>
+(David Wells, 2022/05/09)
index 3dfb6e99c1bf0d9c153507cfc6d888fb2dc2194c..b6969e4dacf839ad132c436703e328de61437352 100644 (file)
@@ -571,23 +571,33 @@ namespace GridTools
         if (dim > 1)
           {
             for (const unsigned int face_n : cell->face_indices())
-              face_data.insert_face_data(cell->face(face_n));
+              // We don't need to insert anything if we have default values
+              {
+                const auto face = cell->face(face_n);
+                if (face->boundary_id() != numbers::internal_face_boundary_id ||
+                    face->manifold_id() != numbers::flat_manifold_id)
+                  face_data.insert_face_data(face);
+              }
           }
         // Save line data
         if (dim == 3)
           {
             for (unsigned int line_n = 0; line_n < cell->n_lines(); ++line_n)
               {
-                const auto  line = cell->line(line_n);
-                CellData<1> line_cell_data;
-                for (unsigned int vertex_n = 0; vertex_n < line->n_vertices();
-                     ++vertex_n)
-                  line_cell_data.vertices[vertex_n] =
-                    line->vertex_index(vertex_n);
-                line_cell_data.boundary_id = line->boundary_id();
-                line_cell_data.manifold_id = line->manifold_id();
-
-                line_data.insert(line_cell_data);
+                const auto line = cell->line(line_n);
+                // We don't need to insert anything if we have default values
+                if (line->boundary_id() != numbers::internal_face_boundary_id ||
+                    line->manifold_id() != numbers::flat_manifold_id)
+                  {
+                    CellData<1> line_cell_data(line->n_vertices());
+                    for (unsigned int vertex_n : line->vertex_indices())
+                      line_cell_data.vertices[vertex_n] =
+                        line->vertex_index(vertex_n);
+
+                    line_cell_data.boundary_id = line->boundary_id();
+                    line_cell_data.manifold_id = line->manifold_id();
+                    line_data.insert(line_cell_data);
+                  }
               }
           }
       }

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.