deal.II version 9.8.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
cell_id_translator.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2021 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_cell_id_translator_h
14#define dealii_cell_id_translator_h
15
19
22
23#include <cstdint>
24#include <limits>
25#include <vector>
26
28
29// Forward declarations
30#ifndef DOXYGEN
31template <int dim, int spacedim>
33class Triangulation;
34#endif
35
36namespace internal
37{
59 template <int dim>
61 {
62 public:
66 template <int spacedim>
68
74 size() const;
75
80 template <typename Accessor>
82 translate(const TriaIterator<Accessor> &cell) const;
83
88 template <typename Accessor>
90 translate_level(const TriaIterator<Accessor> &cell) const;
91
95 template <typename Accessor>
98 const types::global_cell_index i) const;
99
103 CellId
104 to_cell_id(const types::global_cell_index id) const;
105
106 private:
111 to_level_cell_index(const CellId &cell_id) const;
112
120 const bool has_pyramids;
121
130 const unsigned int max_children_per_cell;
131
136
141
145 std::vector<types::global_cell_index> tree_sizes;
146 };
147
148
149
150 template <int dim>
159
160
161
162 template <int dim>
163 template <typename Accessor>
166 {
167 static_assert(dim == Accessor::dimension &&
168 dim == Accessor::structure_dimension,
169 "The information can only be queried for cells.");
170
171 return translate_level(cell) + tree_sizes[cell->level()];
172 }
173
174
175
176 template <int dim>
177 template <typename Accessor>
180 const TriaIterator<Accessor> &cell) const
181 {
182 static_assert(dim == Accessor::dimension &&
183 dim == Accessor::structure_dimension,
184 "The information can only be queried for cells.");
185
186 return to_level_cell_index(
188 }
189
190
191
192 template <int dim>
193 template <typename Accessor>
196 const types::global_cell_index i) const
197 {
198 static_assert(dim == Accessor::dimension &&
199 dim == Accessor::structure_dimension,
200 "The information can only be queried for cells.");
201
202 return (translate(cell) - tree_sizes[cell->level()]) *
204 i + tree_sizes[cell->level() + 1];
205 }
206} // namespace internal
207
209
210#endif
CellId id() const
types::global_cell_index translate_level(const TriaIterator< Accessor > &cell) const
const types::global_cell_index n_global_levels
types::global_cell_index translate(const TriaIterator< Accessor > &cell) const
const unsigned int max_children_per_cell
CellIDTranslator(const Triangulation< dim, spacedim > &tria)
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
types::global_cell_index to_level_cell_index(const CellId &cell_id) const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:246
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
constexpr T pow(const T base, const int iexp)
Definition utilities.h:966
unsigned int global_cell_index
Definition types.h:136