Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
block_info.h
1 // ---------------------------------------------------------------------
2 // @f$Id: block_info.h 30036 2013-07-18 16:55:32Z maier @f$
3 //
4 // Copyright (C) 2009 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__block_info_h
18 #define __deal2__block_info_h
19 
20 #include <deal.II/base/subscriptor.h>
21 #include <deal.II/base/memory_consumption.h>
22 #include <deal.II/lac/block_indices.h>
23 
24 #include <iomanip>
25 
27 
28 // Forward declarations
29 
30 template <int dim, int spacedim> class DoFHandler;
31 namespace hp
32 {
33  template <int dim, int spacedim> class DoFHandler;
34 }
35 
36 
93 class BlockInfo : public Subscriptor
94 {
95 public:
118  template <int dim, int spacedim>
119  void initialize(const DoFHandler<dim, spacedim> &, bool levels_only = false, bool active_only = false);
120 
127  template <int dim, int spacedim>
129 
135  const BlockIndices &global() const;
136 
141  const BlockIndices &local() const;
142 
148  const BlockIndices &level(unsigned int level) const;
149 
166  types::global_dof_index renumber (const unsigned int i) const;
167 
171  unsigned int n_base_elements() const;
172 
177  unsigned int base_element (const unsigned int i) const;
178 
183  template <class OS>
184  void
185  print(OS &stream) const;
186 
192  std::size_t memory_consumption () const;
193 
198  template <class Archive>
199  void serialize (Archive &ar,
200  const unsigned int version);
201 
202 private:
211  std::vector<BlockIndices> levels;
212 
218 
223  std::vector<unsigned int> base_elements;
224 
234  std::vector<types::global_dof_index> local_renumbering;
235 };
236 
237 
238 
239 //----------------------------------------------------------------------//
240 
241 inline
242 const BlockIndices &
244 {
245  return bi_global;
246 }
247 
248 
249 inline
250 const BlockIndices &
252 {
253  return bi_local;
254 }
255 
256 
257 inline
258 const BlockIndices &
259 BlockInfo::level (const unsigned int l) const
260 {
261  AssertIndexRange(l, levels.size());
262  return levels[l];
263 }
264 
265 
266 inline
267 types::global_dof_index BlockInfo::renumber (const unsigned int i) const
268 {
269  AssertIndexRange(i, static_cast<unsigned int>(local_renumbering.size()));
270  return local_renumbering[i];
271 }
272 
273 
274 inline
275 unsigned int
276 BlockInfo::base_element (const unsigned int i) const
277 {
278  AssertIndexRange(i, base_elements.size());
279 
280  return base_elements[i];
281 }
282 
283 
284 inline
285 unsigned int
287 {
288  return base_elements.size();
289 }
290 
291 
292 
293 template <class OS>
294 inline
295 void
296 BlockInfo::print (OS &os) const
297 {
298  os << "global dofs " << std::setw(5) << global().total_size() << " blocks";
299  for (unsigned int i=0; i<global().size(); ++i)
300  os << ' ' << std::setw(5) << global().block_size(i);
301  os << std::endl;
302 
303  if (local().size() == 0)
304  {
305  os << "local dofs not initialized" << std::endl;
306  }
307  else
308  {
309  os << "local dofs " << std::setw(5) << local().total_size() << " blocks";
310  for (unsigned int i=0; i<local().size(); ++i)
311  os << ' ' << std::setw(5) << local().block_size(i);
312  os << std::endl;
313  }
314 
315  for (unsigned int l=0; l<levels.size(); ++l)
316  {
317  os << "level " << std::setw(2) << l << " dofs " << std::setw(5) << level(l).total_size() << " blocks";
318  for (unsigned int i=0; i<level(l).size(); ++i)
319  os << ' ' << std::setw(5) << level(l).block_size(i);
320  os << std::endl;
321  }
322 }
323 
324 
325 inline
326 std::size_t
328 {
333 }
334 
335 
336 template <class Archive>
337 void BlockInfo::serialize (Archive &ar,
338  const unsigned int version)
339 {
340  ar &bi_global;
341  ar &levels;
342  ar &bi_local;
343  ar &base_elements;
344  ar &local_renumbering;
345 }
346 
347 
348 DEAL_II_NAMESPACE_CLOSE
349 
350 #endif
std::vector< types::global_dof_index > local_renumbering
Definition: block_info.h:234
std::size_t memory_consumption() const
Definition: block_info.h:327
#define AssertIndexRange(index, range)
Definition: exceptions.h:888
Auxiliary class aiding in the handling of block structures like in BlockVector or FESystem...
Definition: block_indices.h:55
void serialize(Archive &ar, const unsigned int version)
Definition: block_info.h:337
unsigned int global_dof_index
Definition: types.h:100
unsigned int base_element(const unsigned int i) const
Definition: block_info.h:276
std::size_t memory_consumption(const T &t)
size_type total_size() const
types::global_dof_index renumber(const unsigned int i) const
Definition: block_info.h:267
Definition: hp.h:103
size_type block_size(const unsigned int i) const
BlockIndices bi_global
The block structure of the global system.
Definition: block_info.h:207
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.
unsigned int n_base_elements() const
Definition: block_info.h:286
void initialize_local(const DoFHandler< dim, spacedim > &)
Initialize block structure on cells and compute renumbering between cell dofs and block cell dofs...
std::vector< BlockIndices > levels
The multilevel block structure.
Definition: block_info.h:211
const BlockIndices & level(unsigned int level) const
Definition: block_info.h:259
const BlockIndices & local() const
Definition: block_info.h:251
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
Definition: block_info.h:93
unsigned int size() const
const BlockIndices & global() const
Definition: block_info.h:243
void print(OS &stream) const
Definition: block_info.h:296
BlockIndices bi_local
The block structure of the cell systems.
Definition: block_info.h:217
std::vector< unsigned int > base_elements
Definition: block_info.h:223