15#ifndef dealii_cell_id_translator_h
16#define dealii_cell_id_translator_h
75 template <
typename Accessor>
83 template <
typename Accessor>
90 template <
typename Accessor>
131 : n_coarse_cells(n_coarse_cells)
132 , n_global_levels(n_global_levels)
141 std::uint64_t max_cell_index = 0;
152 max_cell_index <= std::numeric_limits<types::global_cell_index>::max(),
154 "You have exceeded the maximal number of possible indices this function "
155 "can handle. The current setup (n_coarse_cells=" +
157 ", n_global_levels=" + std::to_string(
n_global_levels) +
") requires " +
158 std::to_string(max_cell_index + 1) +
159 " indices but the current deal.II configuration only supports " +
160 std::to_string(std::numeric_limits<types::global_cell_index>::max()) +
161 " indices. You may want to consider to build deal.II with 64bit "
162 "indices (-D DEAL_II_WITH_64BIT_INDICES=\"ON\") to increase the limit "
170 Utilities::pow<types::global_cell_index>(
181 return n_coarse_cells *
182 (Utilities::pow<types::global_cell_index>(
190 template <
typename Accessor>
194 static_assert(dim == Accessor::dimension &&
195 dim == Accessor::structure_dimension,
196 "The information can only be queried for cells.");
198 return translate_level(cell) + tree_sizes[cell->level()];
204 template <
typename Accessor>
208 static_assert(dim == Accessor::dimension &&
209 dim == Accessor::structure_dimension,
210 "The information can only be queried for cells.");
212 return convert_cell_id_binary_type_to_level_coarse_cell_id(
215 .
template to_binary<dim>());
221 template <
typename Accessor>
226 static_assert(dim == Accessor::dimension &&
227 dim == Accessor::structure_dimension,
228 "The information can only be queried for cells.");
230 return (translate(cell) - tree_sizes[cell->level()]) *
232 i + tree_sizes[cell->level() + 1];
241 std::vector<std::uint8_t> child_indices;
248 if (
id < tree_sizes[
level])
252 id_temp -= tree_sizes[
level];
256 child_indices.push_back(id_temp %
261 std::reverse(child_indices.begin(), child_indices.end());
263 return {id_temp, child_indices};
277 const unsigned int coarse_cell_id = binary_representation[0];
278 const unsigned int n_child_indices = binary_representation[1] >> 2;
280 const unsigned int children_per_value =
281 sizeof(CellId::binary_type::value_type) * 8 / dim;
282 unsigned int child_level = 0;
283 unsigned int binary_entry = 2;
287 while (child_level < n_child_indices)
291 for (
unsigned int j = 0; j < children_per_value; ++j)
294 (((binary_representation[binary_entry] >> (j * dim))) &
296 level_coarse_cell_id =
300 if (child_level == n_child_indices)
306 return level_coarse_cell_id;
std::array< unsigned int, 4 > binary_type
const types::global_cell_index n_global_levels
types::global_cell_index translate(const TriaIterator< Accessor > &cell) const
static types::global_cell_index convert_cell_id_binary_type_to_level_coarse_cell_id(const typename CellId::binary_type &binary_representation)
CellIDTranslator(const types::global_cell_index n_coarse_cells, const types::global_cell_index n_global_levels)
std::vector< types::global_cell_index > tree_sizes
CellId to_cell_id(const types::global_cell_index id) const
static types::global_cell_index translate_level(const TriaIterator< Accessor > &cell)
const types::global_cell_index n_coarse_cells
types::global_cell_index size() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)