16#ifndef dealii_cell_id_translator_h
17#define dealii_cell_id_translator_h
76 template <
typename Accessor>
83 template <
typename Accessor>
124 : n_coarse_cells(n_coarse_cells)
125 , n_global_levels(n_global_levels)
135 std::uint64_t max_cell_index = 0;
146 max_cell_index <= std::numeric_limits<types::global_cell_index>::max(),
148 "You have exceeded the maximal number of possible indices this function "
149 "can handle. The current setup (n_coarse_cells=" +
151 ", n_global_levels=" + std::to_string(
n_global_levels) +
") requires " +
152 std::to_string(max_cell_index + 1) +
153 " indices but the current deal.II configuration only supports " +
154 std::to_string(std::numeric_limits<types::global_cell_index>::max()) +
155 " indices. You may want to consider to build deal.II with 64bit "
156 "indices (-D DEAL_II_WITH_64BIT_INDICES=\"ON\") to increase the limit "
165 Utilities::pow<types::global_cell_index>(
176 return n_coarse_cells *
177 (Utilities::pow<types::global_cell_index>(
185 template <
typename Accessor>
189 static_assert(dim == Accessor::dimension &&
190 dim == Accessor::structure_dimension,
191 "The information can only be queried for cells.");
195 id += convert_cell_id_binary_type_to_level_coarse_cell_id(
198 .
template to_binary<dim>());
200 id += tree_sizes[cell->level()];
208 template <
typename Accessor>
213 static_assert(dim == Accessor::dimension &&
214 dim == Accessor::structure_dimension,
215 "The information can only be queried for cells.");
217 return (translate(cell) - tree_sizes[cell->level()]) *
219 i + tree_sizes[cell->level() + 1];
228 std::vector<std::uint8_t> child_indices;
235 if (
id < tree_sizes[
level])
239 id_temp -= tree_sizes[
level];
243 child_indices.push_back(id_temp %
248 std::reverse(child_indices.begin(), child_indices.end());
250 return {id_temp, child_indices};
264 const unsigned int coarse_cell_id = binary_representation[0];
265 const unsigned int n_child_indices = binary_representation[1] >> 2;
267 const unsigned int children_per_value =
268 sizeof(CellId::binary_type::value_type) * 8 / dim;
269 unsigned int child_level = 0;
270 unsigned int binary_entry = 2;
273 std::vector<unsigned int> cell_indices;
274 while (child_level < n_child_indices)
278 for (
unsigned int j = 0; j < children_per_value; ++j)
281 (((binary_representation[binary_entry] >> (j * dim))) &
285 if (child_level == n_child_indices)
293 for (
auto i : cell_indices)
294 level_coarse_cell_id =
297 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
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)