Reference documentation for deal.II version Git 0096380e24 2020-08-06 21:03:09 -0400
\(\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 - 2020 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 
23 
25 
26 #include <iomanip>
27 
29 
30 // Forward declarations
31 #ifndef DOXYGEN
32 template <int dim, int spacedim>
33 class DoFHandler;
34 #endif
35 
36 
93 class BlockInfo : public Subscriptor
94 {
95 public:
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 
183  template <class Archive>
184  void
185  serialize(Archive &ar, const unsigned int /*version*/);
186 
187 private:
195  std::vector<BlockIndices> levels;
196 
201 
205  std::vector<unsigned int> base_elements;
206 
211  std::vector<types::global_dof_index> local_renumbering;
212 };
213 
214 
215 
216 //----------------------------------------------------------------------//
217 
218 inline const BlockIndices &
220 {
221  return bi_global;
222 }
223 
224 
225 inline const BlockIndices &
227 {
228  return bi_local;
229 }
230 
231 
232 inline const BlockIndices &
233 BlockInfo::level(const unsigned int l) const
234 {
235  AssertIndexRange(l, levels.size());
236  return levels[l];
237 }
238 
239 
241 BlockInfo::renumber(const unsigned int i) const
242 {
243  AssertIndexRange(i, static_cast<unsigned int>(local_renumbering.size()));
244  return local_renumbering[i];
245 }
246 
247 
248 inline unsigned int
249 BlockInfo::base_element(const unsigned int i) const
250 {
251  AssertIndexRange(i, base_elements.size());
252 
253  return base_elements[i];
254 }
255 
256 
257 inline unsigned int
259 {
260  return base_elements.size();
261 }
262 
263 
264 
265 template <class OS>
266 inline void
267 BlockInfo::print(OS &os) const
268 {
269  os << "global dofs " << std::setw(5) << global().total_size() << " blocks";
270  for (unsigned int i = 0; i < global().size(); ++i)
271  os << ' ' << std::setw(5) << global().block_size(i);
272  os << std::endl;
273 
274  if (local().size() == 0)
275  {
276  os << "local dofs not initialized" << std::endl;
277  }
278  else
279  {
280  os << "local dofs " << std::setw(5) << local().total_size()
281  << " blocks";
282  for (unsigned int i = 0; i < local().size(); ++i)
283  os << ' ' << std::setw(5) << local().block_size(i);
284  os << std::endl;
285  }
286 
287  for (unsigned int l = 0; l < levels.size(); ++l)
288  {
289  os << "level " << std::setw(2) << l << " dofs " << std::setw(5)
290  << level(l).total_size() << " blocks";
291  for (unsigned int i = 0; i < level(l).size(); ++i)
292  os << ' ' << std::setw(5) << level(l).block_size(i);
293  os << std::endl;
294  }
295 }
296 
297 
298 inline std::size_t
300 {
305 }
306 
307 
308 template <class Archive>
309 void
310 BlockInfo::serialize(Archive &ar, const unsigned int /*version*/)
311 {
312  ar &bi_global;
313  ar &levels;
314  ar &bi_local;
315  ar &base_elements;
316  ar &local_renumbering;
317 }
318 
319 
321 
322 #endif
const BlockIndices & local() const
Definition: block_info.h:226
std::vector< types::global_dof_index > local_renumbering
Definition: block_info.h:211
#define AssertIndexRange(index, range)
Definition: exceptions.h:1636
size_type block_size(const unsigned int i) const
unsigned int base_element(const unsigned int i) const
Definition: block_info.h:249
size_type total_size() const
const BlockIndices & level(unsigned int level) const
Definition: block_info.h:233
void print(OS &stream) const
Definition: block_info.h:267
std::size_t memory_consumption() const
Definition: block_info.h:299
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:363
unsigned int n_base_elements() const
Definition: block_info.h:258
BlockIndices bi_global
The block structure of the global system.
Definition: block_info.h:191
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
void serialize(Archive &ar, const unsigned int)
Definition: block_info.h:310
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
std::vector< BlockIndices > levels
The multilevel block structure.
Definition: block_info.h:195
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:362
types::global_dof_index renumber(const unsigned int i) const
Definition: block_info.h:241
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
Definition: block_info.h:93
unsigned int size() const
BlockIndices bi_local
The block structure of the cell systems.
Definition: block_info.h:200
const BlockIndices & global() const
Definition: block_info.h:219
std::vector< unsigned int > base_elements
Definition: block_info.h:205
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)