From c237b4cc10280448736ba565229bcb99b253c640 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 6 Apr 2023 15:19:21 -0600 Subject: [PATCH] Don't overallocate memory. --- source/grid/grid_tools_cache.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/grid/grid_tools_cache.cc b/source/grid/grid_tools_cache.cc index 4caa9a671a..d6e873cad3 100644 --- a/source/grid/grid_tools_cache.cc +++ b/source/grid/grid_tools_cache.cc @@ -155,7 +155,12 @@ namespace GridTools BoundingBox, typename Triangulation::active_cell_iterator>> boxes; - boxes.reserve(tria->n_active_cells()); + if (const parallel::TriangulationBase *parallel_tria = + dynamic_cast *>( + &*tria)) + boxes.reserve(parallel_tria->n_locally_owned_active_cells()); + else + boxes.reserve(tria->n_active_cells()); for (const auto &cell : tria->active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) boxes.emplace_back(mapping->get_bounding_box(cell), cell); -- 2.39.5