Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
block_info.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2009 - 2018 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/memory_consumption.h>
20 #include <deal.II/base/subscriptor.h>
21 
22 #include <deal.II/lac/block_indices.h>
23 
24 #include <iomanip>
25 
26 DEAL_II_NAMESPACE_OPEN
27 
28 // Forward declarations
29 
30 template <int dim, int spacedim>
31 class DoFHandler;
32 namespace hp
33 {
34  template <int dim, int spacedim>
35  class DoFHandler;
36 }
37 
38 
96 class BlockInfo : public Subscriptor
97 {
98 public:
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 
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 
323 DEAL_II_NAMESPACE_CLOSE
324 
325 #endif
const BlockIndices & local() const
Definition: block_info.h:229
std::vector< types::global_dof_index > local_renumbering
Definition: block_info.h:214
#define AssertIndexRange(index, range)
Definition: exceptions.h:1637
size_type block_size(const unsigned int i) const
unsigned int base_element(const unsigned int i) const
Definition: block_info.h:252
size_type total_size() const
const BlockIndices & level(unsigned int level) const
Definition: block_info.h:236
void print(OS &stream) const
Definition: block_info.h:270
std::size_t memory_consumption() const
Definition: block_info.h:302
unsigned int n_base_elements() const
Definition: block_info.h:261
Definition: hp.h:117
BlockIndices bi_global
The block structure of the global system.
Definition: block_info.h:194
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:313
unsigned int global_dof_index
Definition: types.h:89
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
std::vector< BlockIndices > levels
The multilevel block structure.
Definition: block_info.h:198
types::global_dof_index renumber(const unsigned int i) const
Definition: block_info.h:244
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
Definition: block_info.h:96
unsigned int size() const
BlockIndices bi_local
The block structure of the cell systems.
Definition: block_info.h:203
const BlockIndices & global() const
Definition: block_info.h:222
std::vector< unsigned int > base_elements
Definition: block_info.h:208
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)