deal.II version GIT relicensing-6809-ge913b9bb34 2026-09-25 17:20:01+00:00
\(\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
tria_levels.cc
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) 2006 - 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#include <deal.II/base/config.h>
14
18#include <deal.II/base/types.h>
19
24
25#include <Kokkos_Macros.hpp>
26
27#include <cstddef>
28#include <cstdint>
29#include <utility>
30#include <vector>
31
33
34
35namespace internal
36{
37 namespace TriangulationImplementation
38 {
39 template <int dim, int spacedim>
41 : children_per_object(numbers::invalid_unsigned_int)
42 , faces_per_object(numbers::invalid_unsigned_int)
43 , vertices_per_object(numbers::invalid_unsigned_int)
44 {}
45
46
47
48 template <int dim, int spacedim>
49 std::size_t
70
71
72
73 template <int dim, int spacedim>
74 void
76 const bool orientation_needed)
77 {
78 Assert(children_per_object == cells.children_per_object,
80 Assert(faces_per_object == cells.faces_per_object, ExcInternalError());
81 Assert(vertices_per_object != numbers::invalid_unsigned_int,
83 active_cell_indices.assign(n_cells, numbers::invalid_unsigned_int);
84 subdomain_ids.assign(n_cells, 0);
85 level_subdomain_ids.assign(n_cells, 0);
86
87 refine_flags.assign(n_cells, 0u);
88 refine_choice.assign(n_cells, 0u);
89 coarsen_flags.assign(n_cells, false);
90
91 parents.assign((n_cells + 1) / 2, -1);
92
93 if (dim == spacedim - 1)
94 direction_flags.assign(n_cells, true);
95
96 cells.allocate(n_cells);
97
98 face_orientations.reinit(orientation_needed ? n_cells : 0u,
99 faces_per_object);
100
101 neighbor_levels.assign(n_cells * faces_per_object, -1);
102 neighbor_indices.assign(n_cells * faces_per_object, -1);
103 cell_vertex_indices_cache.assign(n_cells * vertices_per_object,
105
106 reference_cell.assign(n_cells, ReferenceCells::Invalid<dim>);
107
108 global_active_cell_indices.assign(n_cells, numbers::invalid_dof_index);
109 global_level_cell_indices.assign(n_cells, numbers::invalid_dof_index);
110 }
111
112
113
114 template <int dim, int spacedim>
115 void
116 TriaLevel<dim, spacedim>::allocate_end(const std::size_t n_new_cells,
117 const bool orientation_needed,
118 const bool has_tetrahedra)
119 {
120 Assert(children_per_object == cells.children_per_object,
122 Assert(faces_per_object == cells.faces_per_object, ExcInternalError());
123 if (n_new_cells == 0)
124 return;
125 const auto total_cells = size() + n_new_cells;
126
127 // note that all arrays should have equal sizes (checked by
128 // @p{monitor_memory}
129 refine_flags.reserve(total_cells);
130 refine_flags.insert(refine_flags.end(),
131 total_cells - refine_flags.size(),
132 /*RefinementCase::no_refinement=*/0);
133
134 if (has_tetrahedra)
135 {
136 refine_choice.reserve(total_cells);
137 refine_choice.insert(
138 refine_choice.end(),
139 total_cells - refine_choice.size(),
140 static_cast<std::uint8_t>(
142 }
143
144 coarsen_flags.reserve(total_cells);
145 coarsen_flags.insert(coarsen_flags.end(),
146 total_cells - coarsen_flags.size(),
147 false);
148
149 active_cell_indices.reserve(total_cells);
150 active_cell_indices.insert(active_cell_indices.end(),
151 total_cells - active_cell_indices.size(),
153
154 subdomain_ids.reserve(total_cells);
155 subdomain_ids.insert(subdomain_ids.end(),
156 total_cells - subdomain_ids.size(),
157 0);
158
159 level_subdomain_ids.reserve(total_cells);
160 level_subdomain_ids.insert(level_subdomain_ids.end(),
161 total_cells - level_subdomain_ids.size(),
162 0);
163
164 global_active_cell_indices.reserve(total_cells);
165 global_active_cell_indices.insert(global_active_cell_indices.end(),
166 total_cells -
167 global_active_cell_indices.size(),
169
170 global_level_cell_indices.reserve(total_cells);
171 global_level_cell_indices.insert(global_level_cell_indices.end(),
172 total_cells -
173 global_level_cell_indices.size(),
175
176 if (dim == spacedim - 1)
177 {
178 direction_flags.reserve(total_cells);
179 direction_flags.insert(direction_flags.end(),
180 total_cells - direction_flags.size(),
181 true);
182 }
183 else
184 direction_flags.clear();
185
186 parents.reserve((total_cells + 1) / 2);
187 parents.insert(parents.end(), (total_cells + 1) / 2 - parents.size(), -1);
188
189 reference_cell.reserve(total_cells);
190 cell_vertex_indices_cache.insert(cell_vertex_indices_cache.end(),
191 vertices_per_object * total_cells -
192 cell_vertex_indices_cache.size(),
194
195 neighbor_levels.reserve(total_cells * faces_per_object);
196 neighbor_levels.insert(neighbor_levels.end(),
197 total_cells * faces_per_object -
198 neighbor_levels.size(),
199 -1);
200 neighbor_indices.reserve(total_cells * faces_per_object);
201 neighbor_indices.insert(neighbor_indices.end(),
202 total_cells * faces_per_object -
203 neighbor_indices.size(),
204 -1);
205
206 if (dim > 1)
207 {
208 face_orientations.resize(orientation_needed ? total_cells : 0);
209
210 reference_cell.reserve(total_cells);
211 reference_cell.insert(reference_cell.end(),
212 total_cells - reference_cell.size(),
213 ReferenceCells::get_hypercube<dim>());
214 }
215 }
216
217
218
219 // explicit instantiations; note: we need them all for all dimensions
220
221 template class TriaLevel<1, 1>;
222 template class TriaLevel<1, 2>;
223 template class TriaLevel<1, 3>;
224 template class TriaLevel<2, 2>;
225 template class TriaLevel<2, 3>;
226 template class TriaLevel<3, 3>;
227 } // namespace TriangulationImplementation
228} // namespace internal
229
void allocate(const std::size_t n_cells, const bool orientation_needed)
void allocate_end(const std::size_t n_new_cells, const bool orientation_needed, const bool has_tetrahedra)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
std::size_t size
Definition mpi.cc:733
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition tria.cc:15808
constexpr types::global_dof_index invalid_dof_index
Definition types.h:259
constexpr unsigned int invalid_unsigned_int
Definition types.h:228