15#ifndef dealii_cell_id_translator_h
16#define dealii_cell_id_translator_h
75 template <
typename Accessor>
82 template <
typename Accessor>
123 : n_coarse_cells(n_coarse_cells)
124 , n_global_levels(n_global_levels)
133 std::uint64_t max_cell_index = 0;
144 max_cell_index <= std::numeric_limits<types::global_cell_index>::max(),
146 "You have exceeded the maximal number of possible indices this function "
147 "can handle. The current setup (n_coarse_cells=" +
149 ", n_global_levels=" + std::to_string(
n_global_levels) +
") requires " +
150 std::to_string(max_cell_index + 1) +
151 " indices but the current deal.II configuration only supports " +
152 std::to_string(std::numeric_limits<types::global_cell_index>::max()) +
153 " indices. You may want to consider to build deal.II with 64bit "
154 "indices (-D DEAL_II_WITH_64BIT_INDICES=\"ON\") to increase the limit "
173 return n_coarse_cells *
182 template <
typename Accessor>
186 static_assert(dim == Accessor::dimension &&
187 dim == Accessor::structure_dimension,
188 "The information can only be queried for cells.");
192 id += convert_cell_id_binary_type_to_level_coarse_cell_id(
195 .
template to_binary<dim>());
197 id += tree_sizes[cell->level()];
205 template <
typename Accessor>
210 static_assert(dim == Accessor::dimension &&
211 dim == Accessor::structure_dimension,
212 "The information can only be queried for cells.");
214 return (translate(cell) - tree_sizes[cell->level()]) *
216 i + tree_sizes[cell->level() + 1];
225 std::vector<std::uint8_t> child_indices;
232 if (
id < tree_sizes[
level])
236 id_temp -= tree_sizes[
level];
240 child_indices.push_back(id_temp %
245 std::reverse(child_indices.begin(), child_indices.end());
247 return {id_temp, child_indices};
261 const unsigned int coarse_cell_id = binary_representation[0];
262 const unsigned int n_child_indices = binary_representation[1] >> 2;
264 const unsigned int children_per_value =
265 sizeof(CellId::binary_type::value_type) * 8 / dim;
266 unsigned int child_level = 0;
267 unsigned int binary_entry = 2;
271 while (child_level < n_child_indices)
275 for (
unsigned int j = 0; j < children_per_value; ++j)
278 (((binary_representation[binary_entry] >> (j * dim))) &
280 level_coarse_cell_id =
284 if (child_level == n_child_indices)
290 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)
#define AssertThrow(cond, exc)
constexpr T pow(const T base, const int iexp)