Reference documentation for deal.II version Git a5ed68a04a 2019-09-22 06:50:58 -0600
\(\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 #ifndef DOXYGEN
30 template <int dim, int spacedim>
31 class DoFHandler;
32 namespace hp
33 {
34  template <int dim, int spacedim>
35  class DoFHandler;
36 }
37 #endif
38 
39 
97 class BlockInfo : public Subscriptor
98 {
99 public:
113  template <int dim, int spacedim>
114  void
115  initialize(const DoFHandler<dim, spacedim> &,
116  bool levels_only = false,
117  bool active_only = false);
118 
123  template <int dim, int spacedim>
124  void
125  initialize_local(const DoFHandler<dim, spacedim> &);
126 
130  const BlockIndices &
131  global() const;
132 
136  const BlockIndices &
137  local() const;
138 
142  const BlockIndices &
143  level(unsigned int level) const;
144 
155  renumber(const unsigned int i) const;
156 
160  unsigned int
161  n_base_elements() const;
162 
166  unsigned int
167  base_element(const unsigned int i) const;
168 
172  template <class OS>
173  void
174  print(OS &stream) const;
175 
180  std::size_t
181  memory_consumption() const;
182 
187  template <class Archive>
188  void
189  serialize(Archive &ar, const unsigned int /*version*/);
190 
191 private:
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 
222 inline const BlockIndices &
224 {
225  return bi_global;
226 }
227 
228 
229 inline const BlockIndices &
231 {
232  return bi_local;
233 }
234 
235 
236 inline const BlockIndices &
237 BlockInfo::level(const unsigned int l) const
238 {
239  AssertIndexRange(l, levels.size());
240  return levels[l];
241 }
242 
243 
245 BlockInfo::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 
252 inline unsigned int
253 BlockInfo::base_element(const unsigned int i) const
254 {
255  AssertIndexRange(i, base_elements.size());
256 
257  return base_elements[i];
258 }
259 
260 
261 inline unsigned int
263 {
264  return base_elements.size();
265 }
266 
267 
268 
269 template <class OS>
270 inline void
271 BlockInfo::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 
302 inline std::size_t
304 {
305  return (MemoryConsumption::memory_consumption(bi_global) +
309 }
310 
311 
312 template <class Archive>
313 void
314 BlockInfo::serialize(Archive &ar, const unsigned int /*version*/)
315 {
316  ar &bi_global;
317  ar &levels;
318  ar &bi_local;
319  ar &base_elements;
320  ar &local_renumbering;
321 }
322 
323 
324 DEAL_II_NAMESPACE_CLOSE
325 
326 #endif
const BlockIndices & local() const
Definition: block_info.h:230
std::vector< types::global_dof_index > local_renumbering
Definition: block_info.h:215
#define AssertIndexRange(index, range)
Definition: exceptions.h:1637
unsigned int base_element(const unsigned int i) const
Definition: block_info.h:253
const BlockIndices & level(unsigned int level) const
Definition: block_info.h:237
void print(OS &stream) const
Definition: block_info.h:271
std::size_t memory_consumption() const
Definition: block_info.h:303
unsigned int n_base_elements() const
Definition: block_info.h:262
Definition: hp.h:117
BlockIndices bi_global
The block structure of the global system.
Definition: block_info.h:195
void serialize(Archive &ar, const unsigned int)
Definition: block_info.h:314
unsigned int global_dof_index
Definition: types.h:89
std::vector< BlockIndices > levels
The multilevel block structure.
Definition: block_info.h:199
types::global_dof_index renumber(const unsigned int i) const
Definition: block_info.h:245
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
Definition: block_info.h:97
BlockIndices bi_local
The block structure of the cell systems.
Definition: block_info.h:204
const BlockIndices & global() const
Definition: block_info.h:223
std::vector< unsigned int > base_elements
Definition: block_info.h:209
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)