Reference documentation for deal.II version GIT c14369f203 2023-10-01 07:40:02+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\}}\)
block_info.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2009 - 2023 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_block_info_h
17 #define dealii_block_info_h
18 
19 #include <deal.II/base/config.h>
20 
24 
26 
27 #include <iomanip>
28 
30 
31 // Forward declarations
32 #ifndef DOXYGEN
33 template <int dim, int spacedim>
34 DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
35 class DoFHandler;
36 #endif
37 
38 
95 class BlockInfo : public Subscriptor
96 {
97 public:
111  template <int dim, int spacedim>
112  void
114  bool levels_only = false,
115  bool active_only = false);
116 
121  template <int dim, int spacedim>
122  void
124 
128  const BlockIndices &
129  global() const;
130 
134  const BlockIndices &
135  local() const;
136 
140  const BlockIndices &
141  level(unsigned int level) const;
142 
153  renumber(const unsigned int i) const;
154 
158  unsigned int
159  n_base_elements() const;
160 
164  unsigned int
165  base_element(const unsigned int i) const;
166 
170  template <class OS>
171  void
172  print(OS &stream) const;
173 
178  std::size_t
179  memory_consumption() const;
180 
186  template <class Archive>
187  void
188  serialize(Archive &ar, const unsigned int /*version*/);
189 
190 private:
198  std::vector<BlockIndices> levels;
199 
204 
208  std::vector<unsigned int> base_elements;
209 
214  std::vector<types::global_dof_index> local_renumbering;
215 };
216 
217 
218 
219 //----------------------------------------------------------------------//
220 
221 inline const BlockIndices &
223 {
224  return bi_global;
225 }
226 
227 
228 inline const BlockIndices &
230 {
231  return bi_local;
232 }
233 
234 
235 inline const BlockIndices &
236 BlockInfo::level(const unsigned int l) const
237 {
238  AssertIndexRange(l, levels.size());
239  return levels[l];
240 }
241 
242 
244 BlockInfo::renumber(const unsigned int i) const
245 {
246  AssertIndexRange(i, static_cast<unsigned int>(local_renumbering.size()));
247  return local_renumbering[i];
248 }
249 
250 
251 inline unsigned int
252 BlockInfo::base_element(const unsigned int i) const
253 {
254  AssertIndexRange(i, base_elements.size());
255 
256  return base_elements[i];
257 }
258 
259 
260 inline unsigned int
262 {
263  return base_elements.size();
264 }
265 
266 
267 
268 template <class OS>
269 inline void
270 BlockInfo::print(OS &os) const
271 {
272  os << "global dofs " << std::setw(5) << global().total_size() << " blocks";
273  for (unsigned int i = 0; i < global().size(); ++i)
274  os << ' ' << std::setw(5) << global().block_size(i);
275  os << std::endl;
276 
277  if (local().size() == 0)
278  {
279  os << "local dofs not initialized" << std::endl;
280  }
281  else
282  {
283  os << "local dofs " << std::setw(5) << local().total_size()
284  << " blocks";
285  for (unsigned int i = 0; i < local().size(); ++i)
286  os << ' ' << std::setw(5) << local().block_size(i);
287  os << std::endl;
288  }
289 
290  for (unsigned int l = 0; l < levels.size(); ++l)
291  {
292  os << "level " << std::setw(2) << l << " dofs " << std::setw(5)
293  << level(l).total_size() << " blocks";
294  for (unsigned int i = 0; i < level(l).size(); ++i)
295  os << ' ' << std::setw(5) << level(l).block_size(i);
296  os << std::endl;
297  }
298 }
299 
300 
301 inline std::size_t
303 {
308 }
309 
310 
311 template <class Archive>
312 void
313 BlockInfo::serialize(Archive &ar, const unsigned int /*version*/)
314 {
315  ar &bi_global;
316  ar &levels;
317  ar &bi_local;
318  ar &base_elements;
319  ar &local_renumbering;
320 }
321 
322 
324 
325 #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:96
unsigned int base_element(const unsigned int i) const
Definition: block_info.h:252
std::vector< types::global_dof_index > local_renumbering
Definition: block_info.h:214
std::vector< BlockIndices > levels
The multilevel block structure.
Definition: block_info.h:198
unsigned int n_base_elements() const
Definition: block_info.h:261
void serialize(Archive &ar, const unsigned int)
Definition: block_info.h:313
BlockIndices bi_global
The block structure of the global system.
Definition: block_info.h:194
std::size_t memory_consumption() const
Definition: block_info.h:302
BlockIndices bi_local
The block structure of the cell systems.
Definition: block_info.h:203
types::global_dof_index renumber(const unsigned int i) const
Definition: block_info.h:244
std::vector< unsigned int > base_elements
Definition: block_info.h:208
const BlockIndices & level(unsigned int level) const
Definition: block_info.h:236
const BlockIndices & global() const
Definition: block_info.h:222
const BlockIndices & local() const
Definition: block_info.h:229
void print(OS &stream) const
Definition: block_info.h:270
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:62
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:30
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_CXX20_REQUIRES(condition)
Definition: config.h:166
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
#define AssertIndexRange(index, range)
Definition: exceptions.h:1857
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
unsigned int global_dof_index
Definition: types.h:82