16#ifndef dealii_cell_id_translator_h
17#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)
126 std::uint64_t max_cell_index = 0;
137 max_cell_index <= std::numeric_limits<types::global_cell_index>::max(),
139 "You have exceeded the maximal number of possible indices this function "
140 "can handle. The current setup (n_coarse_cells=" +
142 ", n_global_levels=" + std::to_string(
n_global_levels) +
") requires " +
143 std::to_string(max_cell_index + 1) +
144 " indices but the current deal.II configuration only supports " +
145 std::to_string(std::numeric_limits<types::global_cell_index>::max()) +
146 " indices. You may want to consider to build deal.II with 64bit "
147 "indices (-D DEAL_II_WITH_64BIT_INDICES=\"ON\") to increase the limit "
153 Utilities::pow<types::global_cell_index>(
164 return n_coarse_cells *
165 (Utilities::pow<types::global_cell_index>(
173 template <
typename Accessor>
177 static_assert(dim == Accessor::dimension &&
178 dim == Accessor::structure_dimension,
179 "The information can only be queried for cells.");
183 id += convert_cell_id_binary_type_to_level_coarse_cell_id(
186 .
template to_binary<dim>());
188 id += tree_sizes[cell->level()];
196 template <
typename Accessor>
201 static_assert(dim == Accessor::dimension &&
202 dim == Accessor::structure_dimension,
203 "The information can only be queried for cells.");
205 return (translate(cell) - tree_sizes[cell->level()]) *
207 i + tree_sizes[cell->level() + 1];
216 std::vector<std::uint8_t> child_indices;
223 if (
id < tree_sizes[
level])
227 id_temp -= tree_sizes[
level];
231 child_indices.push_back(id_temp %
236 std::reverse(child_indices.begin(), child_indices.end());
238 return {id_temp, child_indices};
252 const unsigned int coarse_cell_id = binary_representation[0];
253 const unsigned int n_child_indices = binary_representation[1] >> 2;
255 const unsigned int children_per_value =
256 sizeof(CellId::binary_type::value_type) * 8 / dim;
257 unsigned int child_level = 0;
258 unsigned int binary_entry = 2;
261 std::vector<unsigned int> cell_indices;
262 while (child_level < n_child_indices)
266 for (
unsigned int j = 0; j < children_per_value; ++j)
269 (((binary_representation[binary_entry] >> (j * dim))) &
273 if (child_level == n_child_indices)
281 for (
auto i : cell_indices)
282 level_coarse_cell_id =
285 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)