deal.II version GIT relicensing-1972-g22a7b89abe 2024-10-11 21: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\}}\)
Loading...
Searching...
No Matches
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
23
25
26#include <iomanip>
27
29
30// Forward declarations
31#ifndef DOXYGEN
32template <int dim, int spacedim>
34class DoFHandler;
35#endif
36
37
94class BlockInfo : public Subscriptor
95{
96public:
110 template <int dim, int spacedim>
111 void
113 bool levels_only = false,
114 bool active_only = false);
115
120 template <int dim, int spacedim>
121 void
123
127 const BlockIndices &
128 global() const;
129
133 const BlockIndices &
134 local() const;
135
139 const BlockIndices &
140 level(unsigned int level) const;
141
152 renumber(const unsigned int i) const;
153
157 unsigned int
158 n_base_elements() const;
159
163 unsigned int
164 base_element(const unsigned int i) const;
165
169 template <class OS>
170 void
171 print(OS &stream) const;
172
177 std::size_t
178 memory_consumption() const;
179
185 template <class Archive>
186 void
187 serialize(Archive &ar, const unsigned int /*version*/);
188
189private:
197 std::vector<BlockIndices> levels;
198
203
207 std::vector<unsigned int> base_elements;
208
213 std::vector<types::global_dof_index> local_renumbering;
214};
215
216
217
218//----------------------------------------------------------------------//
219
220inline const BlockIndices &
222{
223 return bi_global;
224}
225
226
227inline const BlockIndices &
229{
230 return bi_local;
231}
232
233
234inline const BlockIndices &
235BlockInfo::level(const unsigned int l) const
236{
237 AssertIndexRange(l, levels.size());
238 return levels[l];
239}
240
241
243BlockInfo::renumber(const unsigned int i) const
244{
245 AssertIndexRange(i, static_cast<unsigned int>(local_renumbering.size()));
246 return local_renumbering[i];
247}
248
249
250inline unsigned int
251BlockInfo::base_element(const unsigned int i) const
252{
254
255 return base_elements[i];
256}
257
258
259inline unsigned int
261{
262 return base_elements.size();
263}
264
265
266
267template <class OS>
268inline void
269BlockInfo::print(OS &os) const
270{
271 os << "global dofs " << std::setw(5) << global().total_size() << " blocks";
272 for (unsigned int i = 0; i < global().size(); ++i)
273 os << ' ' << std::setw(5) << global().block_size(i);
274 os << std::endl;
275
276 if (local().size() == 0)
277 {
278 os << "local dofs not initialized" << std::endl;
279 }
280 else
281 {
282 os << "local dofs " << std::setw(5) << local().total_size()
283 << " blocks";
284 for (unsigned int i = 0; i < local().size(); ++i)
285 os << ' ' << std::setw(5) << local().block_size(i);
286 os << std::endl;
287 }
288
289 for (unsigned int l = 0; l < levels.size(); ++l)
290 {
291 os << "level " << std::setw(2) << l << " dofs " << std::setw(5)
292 << level(l).total_size() << " blocks";
293 for (unsigned int i = 0; i < level(l).size(); ++i)
294 os << ' ' << std::setw(5) << level(l).block_size(i);
295 os << std::endl;
296 }
297}
298
299
300inline std::size_t
308
309
310template <class Archive>
311void
312BlockInfo::serialize(Archive &ar, const unsigned int /*version*/)
313{
314 ar &bi_global;
315 ar &levels;
316 ar &bi_local;
317 ar &base_elements;
319}
320
321
323
324#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:95
unsigned int base_element(const unsigned int i) const
Definition block_info.h:251
std::vector< types::global_dof_index > local_renumbering
Definition block_info.h:213
std::vector< BlockIndices > levels
The multilevel block structure.
Definition block_info.h:197
unsigned int n_base_elements() const
Definition block_info.h:260
void serialize(Archive &ar, const unsigned int)
Definition block_info.h:312
BlockIndices bi_global
The block structure of the global system.
Definition block_info.h:193
std::size_t memory_consumption() const
Definition block_info.h:301
BlockIndices bi_local
The block structure of the cell systems.
Definition block_info.h:202
types::global_dof_index renumber(const unsigned int i) const
Definition block_info.h:243
std::vector< unsigned int > base_elements
Definition block_info.h:207
const BlockIndices & level(unsigned int level) const
Definition block_info.h:235
const BlockIndices & global() const
Definition block_info.h:221
const BlockIndices & local() const
Definition block_info.h:228
void print(OS &stream) const
Definition block_info.h:269
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:498
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:175
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
unsigned int level
Definition grid_out.cc:4626
#define AssertIndexRange(index, range)
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)