Loading [MathJax]/extensions/TeX/AMSsymbols.js
 deal.II version GIT relicensing-3089-g5a471bd8cb 2025-04-21 08:20:00+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\}}\)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
block_info.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2009 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_block_info_h
16#define dealii_block_info_h
17
18#include <deal.II/base/config.h>
19
24#include <deal.II/base/types.h>
25
27
28#include <iomanip>
29
31
32// Forward declarations
33#ifndef DOXYGEN
34template <int dim, int spacedim>
36class DoFHandler;
37#endif
38
39
97{
98public:
112 template <int dim, int spacedim>
113 void
115 bool levels_only = false,
116 bool active_only = false);
117
122 template <int dim, int spacedim>
123 void
125
129 const BlockIndices &
130 global() const;
131
135 const BlockIndices &
136 local() const;
137
141 const BlockIndices &
142 level(unsigned int level) const;
143
154 renumber(const unsigned int i) const;
155
159 unsigned int
160 n_base_elements() const;
161
165 unsigned int
166 base_element(const unsigned int i) const;
167
171 template <class OS>
172 void
173 print(OS &stream) const;
174
179 std::size_t
180 memory_consumption() const;
181
187 template <class Archive>
188 void
189 serialize(Archive &ar, const unsigned int /*version*/);
190
191private:
199 std::vector<BlockIndices> levels;
200
205
209 std::vector<unsigned int> base_elements;
210
215 std::vector<types::global_dof_index> local_renumbering;
216};
217
218
219
220//----------------------------------------------------------------------//
221
222inline const BlockIndices &
224{
225 return bi_global;
226}
227
228
229inline const BlockIndices &
231{
232 return bi_local;
233}
234
235
236inline const BlockIndices &
237BlockInfo::level(const unsigned int l) const
238{
239 AssertIndexRange(l, levels.size());
240 return levels[l];
241}
242
243
245BlockInfo::renumber(const unsigned int i) const
246{
247 AssertIndexRange(i, static_cast<unsigned int>(local_renumbering.size()));
248 return local_renumbering[i];
249}
250
251
252inline unsigned int
253BlockInfo::base_element(const unsigned int i) const
254{
256
257 return base_elements[i];
258}
259
260
261inline unsigned int
263{
264 return base_elements.size();
265}
266
267
268
269template <class OS>
270inline void
271BlockInfo::print(OS &os) const
272{
273 os << "global dofs " << std::setw(5) << global().total_size() << " blocks";
274 for (unsigned int i = 0; i < global().size(); ++i)
275 os << ' ' << std::setw(5) << global().block_size(i);
276 os << std::endl;
277
278 if (local().size() == 0)
279 {
280 os << "local dofs not initialized" << std::endl;
281 }
282 else
283 {
284 os << "local dofs " << std::setw(5) << local().total_size()
285 << " blocks";
286 for (unsigned int i = 0; i < local().size(); ++i)
287 os << ' ' << std::setw(5) << local().block_size(i);
288 os << std::endl;
289 }
290
291 for (unsigned int l = 0; l < levels.size(); ++l)
292 {
293 os << "level " << std::setw(2) << l << " dofs " << std::setw(5)
294 << level(l).total_size() << " blocks";
295 for (unsigned int i = 0; i < level(l).size(); ++i)
296 os << ' ' << std::setw(5) << level(l).block_size(i);
297 os << std::endl;
298 }
299}
300
301
302inline std::size_t
310
311
312template <class Archive>
313void
314BlockInfo::serialize(Archive &ar, const unsigned int /*version*/)
315{
316 ar &bi_global;
317 ar &levels;
318 ar &bi_local;
319 ar &base_elements;
321}
322
323
325
326#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:97
unsigned int base_element(const unsigned int i) const
Definition block_info.h:253
std::vector< types::global_dof_index > local_renumbering
Definition block_info.h:215
std::vector< BlockIndices > levels
The multilevel block structure.
Definition block_info.h:199
unsigned int n_base_elements() const
Definition block_info.h:262
void serialize(Archive &ar, const unsigned int)
Definition block_info.h:314
BlockIndices bi_global
The block structure of the global system.
Definition block_info.h:195
std::size_t memory_consumption() const
Definition block_info.h:303
BlockIndices bi_local
The block structure of the cell systems.
Definition block_info.h:204
types::global_dof_index renumber(const unsigned int i) const
Definition block_info.h:245
std::vector< unsigned int > base_elements
Definition block_info.h:209
const BlockIndices & level(unsigned int level) const
Definition block_info.h:237
const BlockIndices & global() const
Definition block_info.h:223
const BlockIndices & local() const
Definition block_info.h:230
void print(OS &stream) const
Definition block_info.h:271
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:61
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:29
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:35
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:242
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:36
unsigned int level
Definition grid_out.cc:4635
#define AssertIndexRange(index, range)
std::size_t size
Definition mpi.cc:745
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)