Skip to content

Commit

Permalink
Merge pull request #15857 from kronbichler/improve_cell_id_translator
Browse files Browse the repository at this point in the history
Avoid memory allocation in CellIDTranslator
  • Loading branch information
peterrum committed Aug 8, 2023
2 parents 97cf662 + 66064bc commit 0bdac18
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions include/deal.II/grid/cell_id_translator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned int> 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());
Expand All @@ -280,20 +280,16 @@ namespace internal
unsigned int cell_index =
(((binary_representation[binary_entry] >> (j * dim))) &
(GeometryInfo<dim>::max_children_per_cell - 1));
cell_indices.push_back(cell_index);
level_coarse_cell_id =
level_coarse_cell_id * GeometryInfo<dim>::max_children_per_cell +
cell_index;
++child_level;
if (child_level == n_child_indices)
break;
}
++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<dim>::max_children_per_cell + i;

return level_coarse_cell_id;
}

Expand Down

0 comments on commit 0bdac18

Please sign in to comment.