Reference documentation for deal.II version Git 7f58f27 2017-09-20 15:35:49 -0600
block_info.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2009 - 2016 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_block_info_h
17 #define dealii_block_info_h
18 
19 #include <deal.II/base/subscriptor.h>
20 #include <deal.II/base/memory_consumption.h>
21 #include <deal.II/lac/block_indices.h>
22 
23 #include <iomanip>
24 
25 DEAL_II_NAMESPACE_OPEN
26 
27 // Forward declarations
28 
29 template <int dim, int spacedim> class DoFHandler;
30 namespace hp
31 {
32  template <int dim, int spacedim> class DoFHandler;
33 }
34 
35 
93 class BlockInfo : public Subscriptor
94 {
95 public:
109  template <int dim, int spacedim>
110  void initialize(const DoFHandler<dim, spacedim> &, bool levels_only = false, bool active_only = false);
111 
116  template <int dim, int spacedim>
118 
122  const BlockIndices &global() const;
123 
127  const BlockIndices &local() const;
128 
132  const BlockIndices &level(unsigned int level) const;
133 
143  types::global_dof_index renumber (const unsigned int i) const;
144 
148  unsigned int n_base_elements() const;
149 
153  unsigned int base_element (const unsigned int i) const;
154 
158  template <class OS>
159  void
160  print(OS &stream) const;
161 
166  std::size_t memory_consumption () const;
167 
172  template <class Archive>
173  void serialize (Archive &ar,
174  const unsigned int /*version*/);
175 
176 private:
184  std::vector<BlockIndices> levels;
185 
190 
194  std::vector<unsigned int> base_elements;
195 
200  std::vector<types::global_dof_index> local_renumbering;
201 };
202 
203 
204 
205 //----------------------------------------------------------------------//
206 
207 inline
208 const BlockIndices &
210 {
211  return bi_global;
212 }
213 
214 
215 inline
216 const BlockIndices &
218 {
219  return bi_local;
220 }
221 
222 
223 inline
224 const BlockIndices &
225 BlockInfo::level (const unsigned int l) const
226 {
227  AssertIndexRange(l, levels.size());
228  return levels[l];
229 }
230 
231 
232 inline
233 types::global_dof_index BlockInfo::renumber (const unsigned int i) const
234 {
235  AssertIndexRange(i, static_cast<unsigned int>(local_renumbering.size()));
236  return local_renumbering[i];
237 }
238 
239 
240 inline
241 unsigned int
242 BlockInfo::base_element (const unsigned int i) const
243 {
244  AssertIndexRange(i, base_elements.size());
245 
246  return base_elements[i];
247 }
248 
249 
250 inline
251 unsigned int
253 {
254  return base_elements.size();
255 }
256 
257 
258 
259 template <class OS>
260 inline
261 void
262 BlockInfo::print (OS &os) const
263 {
264  os << "global dofs " << std::setw(5) << global().total_size() << " blocks";
265  for (unsigned int i=0; i<global().size(); ++i)
266  os << ' ' << std::setw(5) << global().block_size(i);
267  os << std::endl;
268 
269  if (local().size() == 0)
270  {
271  os << "local dofs not initialized" << std::endl;
272  }
273  else
274  {
275  os << "local dofs " << std::setw(5) << local().total_size() << " blocks";
276  for (unsigned int i=0; i<local().size(); ++i)
277  os << ' ' << std::setw(5) << local().block_size(i);
278  os << std::endl;
279  }
280 
281  for (unsigned int l=0; l<levels.size(); ++l)
282  {
283  os << "level " << std::setw(2) << l << " dofs " << std::setw(5) << level(l).total_size() << " blocks";
284  for (unsigned int i=0; i<level(l).size(); ++i)
285  os << ' ' << std::setw(5) << level(l).block_size(i);
286  os << std::endl;
287  }
288 }
289 
290 
291 inline
292 std::size_t
294 {
299 }
300 
301 
302 template <class Archive>
303 void BlockInfo::serialize (Archive &ar,
304  const unsigned int /*version*/)
305 {
306  ar &bi_global;
307  ar &levels;
308  ar &bi_local;
309  ar &base_elements;
310  ar &local_renumbering;
311 }
312 
313 
314 DEAL_II_NAMESPACE_CLOSE
315 
316 #endif
std::vector< types::global_dof_index > local_renumbering
Definition: block_info.h:200
std::size_t memory_consumption() const
Definition: block_info.h:293
#define AssertIndexRange(index, range)
Definition: exceptions.h:1199
unsigned int global_dof_index
Definition: types.h:88
unsigned int base_element(const unsigned int i) const
Definition: block_info.h:242
size_type total_size() const
types::global_dof_index renumber(const unsigned int i) const
Definition: block_info.h:233
Definition: hp.h:102
size_type block_size(const unsigned int i) const
BlockIndices bi_global
The block structure of the global system.
Definition: block_info.h:180
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:28
void serialize(Archive &ar, const unsigned int)
Definition: block_info.h:303
unsigned int n_base_elements() const
Definition: block_info.h:252
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:56
std::vector< BlockIndices > levels
The multilevel block structure.
Definition: block_info.h:184
const BlockIndices & level(unsigned int level) const
Definition: block_info.h:225
const BlockIndices & local() const
Definition: block_info.h:217
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:209
void print(OS &stream) const
Definition: block_info.h:262
BlockIndices bi_local
The block structure of the cell systems.
Definition: block_info.h:189
std::vector< unsigned int > base_elements
Definition: block_info.h:194
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)