deal.II version GIT relicensing-6842-g793a97d2aa 2026-10-02 14:00: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
block_info.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) 2009 - 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_block_info_h
14#define dealii_block_info_h
15
16#include <deal.II/base/config.h>
17
21#include <deal.II/base/types.h>
22
24
25#include <iomanip>
26
28
29// Forward declarations
30#ifndef DOXYGEN
31template <int dim, int spacedim>
33class DoFHandler;
34#endif
35
36
94{
95public:
109 template <int dim, int spacedim>
110 void
112 bool levels_only = false,
113 bool active_only = false);
114
119 template <int dim, int spacedim>
120 void
122
126 const BlockIndices &
127 global() const;
128
132 const BlockIndices &
133 local() const;
134
138 const BlockIndices &
139 level(unsigned int level) const;
140
151 renumber(const unsigned int i) const;
152
156 unsigned int
157 n_base_elements() const;
158
162 unsigned int
163 base_element(const unsigned int i) const;
164
168 template <class OS>
169 void
170 print(OS &stream) const;
171
176 std::size_t
177 memory_consumption() const;
178
184 template <class Archive>
185 void
186 serialize(Archive &ar, const unsigned int /*version*/);
187
188private:
196 std::vector<BlockIndices> levels;
197
202
206 std::vector<unsigned int> base_elements;
207
212 std::vector<types::global_dof_index> local_renumbering;
213};
214
215
216
217//----------------------------------------------------------------------//
218
219inline const BlockIndices &
221{
222 return bi_global;
223}
224
225
226inline const BlockIndices &
228{
229 return bi_local;
230}
231
232
233inline const BlockIndices &
234BlockInfo::level(const unsigned int l) const
235{
236 AssertIndexRange(l, levels.size());
237 return levels[l];
238}
239
240
242BlockInfo::renumber(const unsigned int i) const
243{
244 AssertIndexRange(i, static_cast<unsigned int>(local_renumbering.size()));
245 return local_renumbering[i];
246}
247
248
249inline unsigned int
250BlockInfo::base_element(const unsigned int i) const
251{
253
254 return base_elements[i];
255}
256
257
258inline unsigned int
260{
261 return base_elements.size();
262}
263
264
265
266template <class OS>
267inline void
268BlockInfo::print(OS &os) const
269{
270 os << "global dofs " << std::setw(5) << global().total_size() << " blocks";
271 for (unsigned int i = 0; i < global().size(); ++i)
272 os << ' ' << std::setw(5) << global().block_size(i);
273 os << std::endl;
274
275 if (local().size() == 0)
276 {
277 os << "local dofs not initialized" << std::endl;
278 }
279 else
280 {
281 os << "local dofs " << std::setw(5) << local().total_size()
282 << " blocks";
283 for (unsigned int i = 0; i < local().size(); ++i)
284 os << ' ' << std::setw(5) << local().block_size(i);
285 os << std::endl;
286 }
287
288 for (unsigned int l = 0; l < levels.size(); ++l)
289 {
290 os << "level " << std::setw(2) << l << " dofs " << std::setw(5)
291 << level(l).total_size() << " blocks";
292 for (unsigned int i = 0; i < level(l).size(); ++i)
293 os << ' ' << std::setw(5) << level(l).block_size(i);
294 os << std::endl;
295 }
296}
297
298
299inline std::size_t
307
308
309template <class Archive>
310void
311BlockInfo::serialize(Archive &ar, const unsigned int /*version*/)
312{
313 ar &bi_global;
314 ar &levels;
315 ar &bi_local;
316 ar &base_elements;
318}
319
320
322
323#endif
size_type block_size(const unsigned int i) const
size_type total_size() const
unsigned int size() const
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
Definition block_info.h:94
unsigned int base_element(const unsigned int i) const
Definition block_info.h:250
std::vector< types::global_dof_index > local_renumbering
Definition block_info.h:212
std::vector< BlockIndices > levels
The multilevel block structure.
Definition block_info.h:196
unsigned int n_base_elements() const
Definition block_info.h:259
void serialize(Archive &ar, const unsigned int)
Definition block_info.h:311
BlockIndices bi_global
The block structure of the global system.
Definition block_info.h:192
std::size_t memory_consumption() const
Definition block_info.h:300
BlockIndices bi_local
The block structure of the cell systems.
Definition block_info.h:201
types::global_dof_index renumber(const unsigned int i) const
Definition block_info.h:242
std::vector< unsigned int > base_elements
Definition block_info.h:206
const BlockIndices & level(unsigned int level) const
Definition block_info.h:234
const BlockIndices & global() const
Definition block_info.h:220
const BlockIndices & local() const
Definition block_info.h:227
void print(OS &stream) const
Definition block_info.h:268
void initialize_local(const DoFHandler< dim, spacedim > &)
Initialize block structure on cells and compute renumbering between cell dofs and block cell dofs.
Definition block_info.cc:59
void initialize(const DoFHandler< dim, spacedim > &, bool levels_only=false, bool active_only=false)
Fill the object with values describing block structure of the DoFHandler.
Definition block_info.cc:27
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:249
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
unsigned int level
Definition grid_out.cc:4642
#define AssertIndexRange(index, range)
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)