From 66e260407df3e189850b4aab6839c95b143f4b48 Mon Sep 17 00:00:00 2001 From: David Wells Date: Mon, 9 May 2022 11:45:41 -0400 Subject: [PATCH] Don't save default data in GridTools::get_coarse_mesh_description(). Saving every line and face takes up a huge amount of memory and time when, in practice, this data is not that useful. --- .../incompatibilities/20220509DavidWells | 9 ++++++ source/grid/grid_tools.cc | 32 ++++++++++++------- 2 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 doc/news/changes/incompatibilities/20220509DavidWells diff --git a/doc/news/changes/incompatibilities/20220509DavidWells b/doc/news/changes/incompatibilities/20220509DavidWells new file mode 100644 index 0000000000..e959f33c18 --- /dev/null +++ b/doc/news/changes/incompatibilities/20220509DavidWells @@ -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). +
+(David Wells, 2022/05/09) diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 3dfb6e99c1..b6969e4dac 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -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); + } } } } -- 2.39.5