From e7e1e64541bbb132b1601da35983c3f043d8985a Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Tue, 15 Oct 2024 10:26:10 +0200 Subject: [PATCH] Introduce CellIDTranslator.translate_level() --- include/deal.II/grid/cell_id_translator.h | 30 +++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/include/deal.II/grid/cell_id_translator.h b/include/deal.II/grid/cell_id_translator.h index 6c348d8ae6..f66d8306e1 100644 --- a/include/deal.II/grid/cell_id_translator.h +++ b/include/deal.II/grid/cell_id_translator.h @@ -76,6 +76,14 @@ namespace internal types::global_cell_index translate(const TriaIterator &cell) const; + /** + * Convert a @p cell of type TriaAccessor, CellAccessor, DoFAccessor, or + * DoFCellAccessor to an index unique on a level. + */ + template + static types::global_cell_index + translate_level(const TriaIterator &cell); + /** * Convert the @p i-th child of @p to an index. */ @@ -187,16 +195,24 @@ namespace internal dim == Accessor::structure_dimension, "The information can only be queried for cells."); - types::global_cell_index id = 0; + return translate_level(cell) + tree_sizes[cell->level()]; + } + - id += convert_cell_id_binary_type_to_level_coarse_cell_id( + + template + template + types::global_cell_index + CellIDTranslator::translate_level(const TriaIterator &cell) + { + static_assert(dim == Accessor::dimension && + dim == Accessor::structure_dimension, + "The information can only be queried for cells."); + + return convert_cell_id_binary_type_to_level_coarse_cell_id( CellAccessor(*cell) .id() .template to_binary()); - - id += tree_sizes[cell->level()]; - - return id; } @@ -244,7 +260,7 @@ namespace internal std::reverse(child_indices.begin(), child_indices.end()); - return {id_temp, child_indices}; // TODO + return {id_temp, child_indices}; } -- 2.39.5