Reference documentation for deal.II version Git cf38156a17 2020-04-01 20:09:03 -0400
\(\newcommand{\vcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\vcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
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/config.h>
20 
21 #include <deal.II/base/memory_consumption.h>
22 #include <deal.II/base/subscriptor.h>
23 
24 #include <deal.II/lac/block_indices.h>
25 
26 #include <iomanip>
27 
28 DEAL_II_NAMESPACE_OPEN
29 
30 // Forward declarations
31 #ifndef DOXYGEN
32 template <int dim, int spacedim>
33 class DoFHandler;
34 namespace hp
35 {
36  template <int dim, int spacedim>
37  class DoFHandler;
38 }
39 #endif
40 
41 
99 class BlockInfo : public Subscriptor
100 {
101 public:
115  template <int dim, int spacedim>
116  void
117  initialize(const DoFHandler<dim, spacedim> &,
118  bool levels_only = false,
119  bool active_only = false);
120 
125  template <int dim, int spacedim>
126  void
127  initialize_local(const DoFHandler<dim, spacedim> &);
128 
132  const BlockIndices &
133  global() const;
134 
138  const BlockIndices &
139  local() const;
140 
144  const BlockIndices &
145  level(unsigned int level) const;
146 
157  renumber(const unsigned int i) const;
158 
162  unsigned int
163  n_base_elements() const;
164 
168  unsigned int
169  base_element(const unsigned int i) const;
170 
174  template <class OS>
175  void
176  print(OS &stream) const;
177 
182  std::size_t
183  memory_consumption() const;
184 
189  template <class Archive>
190  void
191  serialize(Archive &ar, const unsigned int /*version*/);
192 
193 private:
201  std::vector<BlockIndices> levels;
202 
207 
211  std::vector<unsigned int> base_elements;
212 
217  std::vector<types::global_dof_index> local_renumbering;
218 };
219 
220 
221 
222 //----------------------------------------------------------------------//
223 
224 inline const BlockIndices &
226 {
227  return bi_global;
228 }
229 
230 
231 inline const BlockIndices &
233 {
234  return bi_local;
235 }
236 
237 
238 inline const BlockIndices &
239 BlockInfo::level(const unsigned int l) const
240 {
241  AssertIndexRange(l, levels.size());
242  return levels[l];
243 }
244 
245 
247 BlockInfo::renumber(const unsigned int i) const
248 {
249  AssertIndexRange(i, static_cast<unsigned int>(local_renumbering.size()));
250  return local_renumbering[i];
251 }
252 
253 
254 inline unsigned int
255 BlockInfo::base_element(const unsigned int i) const
256 {
257  AssertIndexRange(i, base_elements.size());
258 
259  return base_elements[i];
260 }
261 
262 
263 inline unsigned int
265 {
266  return base_elements.size();
267 }
268 
269 
270 
271 template <class OS>
272 inline void
273 BlockInfo::print(OS &os) const
274 {
275  os << "global dofs " << std::setw(5) << global().total_size() << " blocks";
276  for (unsigned int i = 0; i < global().size(); ++i)
277  os << ' ' << std::setw(5) << global().block_size(i);
278  os << std::endl;
279 
280  if (local().size() == 0)
281  {
282  os << "local dofs not initialized" << std::endl;
283  }
284  else
285  {
286  os << "local dofs " << std::setw(5) << local().total_size()
287  << " blocks";
288  for (unsigned int i = 0; i < local().size(); ++i)
289  os << ' ' << std::setw(5) << local().block_size(i);
290  os << std::endl;
291  }
292 
293  for (unsigned int l = 0; l < levels.size(); ++l)
294  {
295  os << "level " << std::setw(2) << l << " dofs " << std::setw(5)
296  << level(l).total_size() << " blocks";
297  for (unsigned int i = 0; i < level(l).size(); ++i)
298  os << ' ' << std::setw(5) << level(l).block_size(i);
299  os << std::endl;
300  }
301 }
302 
303 
304 inline std::size_t
306 {
307  return (MemoryConsumption::memory_consumption(bi_global) +
311 }
312 
313 
314 template <class Archive>
315 void
316 BlockInfo::serialize(Archive &ar, const unsigned int /*version*/)
317 {
318  ar &bi_global;
319  ar &levels;
320  ar &bi_local;
321  ar &base_elements;
322  ar &local_renumbering;
323 }
324 
325 
326 DEAL_II_NAMESPACE_CLOSE
327 
328 #endif
const BlockIndices & local() const
Definition: block_info.h:232
std::vector< types::global_dof_index > local_renumbering
Definition: block_info.h:217
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
unsigned int base_element(const unsigned int i) const
Definition: block_info.h:255
const BlockIndices & level(unsigned int level) const
Definition: block_info.h:239
void print(OS &stream) const
Definition: block_info.h:273
std::size_t memory_consumption() const
Definition: block_info.h:305
unsigned int n_base_elements() const
Definition: block_info.h:264
Definition: hp.h:117
BlockIndices bi_global
The block structure of the global system.
Definition: block_info.h:197
void serialize(Archive &ar, const unsigned int)
Definition: block_info.h:316
unsigned int global_dof_index
Definition: types.h:77
std::vector< BlockIndices > levels
The multilevel block structure.
Definition: block_info.h:201
types::global_dof_index renumber(const unsigned int i) const
Definition: block_info.h:247
A small class collecting the different BlockIndices involved in global, multilevel and local computat...
Definition: block_info.h:99
BlockIndices bi_local
The block structure of the cell systems.
Definition: block_info.h:206
const BlockIndices & global() const
Definition: block_info.h:225
std::vector< unsigned int > base_elements
Definition: block_info.h:211
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)