]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce CellIDTranslator.translate_level() 17781/head
authorPeter Munch <peterrmuench@gmail.com>
Tue, 15 Oct 2024 08:26:10 +0000 (10:26 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Tue, 15 Oct 2024 21:17:06 +0000 (23:17 +0200)
include/deal.II/grid/cell_id_translator.h

index 6c348d8ae6568e23587744016bc9a29b2cd7f092..f66d8306e1b5a50750f3ac81d732374e72a9cdd0 100644 (file)
@@ -76,6 +76,14 @@ namespace internal
     types::global_cell_index
     translate(const TriaIterator<Accessor> &cell) const;
 
+    /**
+     * Convert a @p cell of type TriaAccessor, CellAccessor, DoFAccessor, or
+     * DoFCellAccessor to an index unique on a level.
+     */
+    template <typename Accessor>
+    static types::global_cell_index
+    translate_level(const TriaIterator<Accessor> &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 <int dim>
+  template <typename Accessor>
+  types::global_cell_index
+  CellIDTranslator<dim>::translate_level(const TriaIterator<Accessor> &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<Accessor::dimension, Accessor::space_dimension>(*cell)
         .id()
         .template to_binary<dim>());
-
-    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};
   }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.