From: Martin Kronbichler Date: Tue, 8 Aug 2023 14:34:32 +0000 (+0200) Subject: Avoid memory allocation in CellIDTranslator X-Git-Tag: relicensing~608^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66064bc2279bbd6a9369a403955329322edbaadf;p=dealii.git Avoid memory allocation in CellIDTranslator --- diff --git a/include/deal.II/grid/cell_id_translator.h b/include/deal.II/grid/cell_id_translator.h index 8055535fd0..ee207c19c2 100644 --- a/include/deal.II/grid/cell_id_translator.h +++ b/include/deal.II/grid/cell_id_translator.h @@ -269,8 +269,8 @@ namespace internal unsigned int child_level = 0; unsigned int binary_entry = 2; - // path to the get to the cell - std::vector cell_indices; + // compute new coarse-grid id: c_{i+1} = c_{i}*2^dim + q on path to cell + types::global_cell_index level_coarse_cell_id = coarse_cell_id; while (child_level < n_child_indices) { Assert(binary_entry < binary_representation.size(), ExcInternalError()); @@ -280,7 +280,9 @@ namespace internal unsigned int cell_index = (((binary_representation[binary_entry] >> (j * dim))) & (GeometryInfo::max_children_per_cell - 1)); - cell_indices.push_back(cell_index); + level_coarse_cell_id = + level_coarse_cell_id * GeometryInfo::max_children_per_cell + + cell_index; ++child_level; if (child_level == n_child_indices) break; @@ -288,12 +290,6 @@ namespace internal ++binary_entry; } - // compute new coarse-grid id: c_{i+1} = c_{i}*2^dim + q; - types::global_cell_index level_coarse_cell_id = coarse_cell_id; - for (auto i : cell_indices) - level_coarse_cell_id = - level_coarse_cell_id * GeometryInfo::max_children_per_cell + i; - return level_coarse_cell_id; }