Reference documentation for deal.II version 9.4.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
data_out_stack.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2021 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_data_out_stack_h
17 #define dealii_data_out_stack_h
18 
19 
20 #include <deal.II/base/config.h>
21 
24 
25 #include <deal.II/lac/vector.h>
26 
28 
29 #include <string>
30 #include <vector>
31 
33 
34 // Forward declaration
35 #ifndef DOXYGEN
36 template <int dim, int spacedim>
37 class DoFHandler;
38 #endif
39 
43 template <int dim, int spacedim = dim, typename DoFHandlerType = void>
45 
46 #ifndef DOXYGEN
47 // prevent doxygen from complaining about potential recursive class relations
48 template <int dim, int spacedim, typename DoFHandlerType>
49 class DataOutStack : public DataOutStack<dim, spacedim, void>
50 {
51 public:
53  DataOutStack()
54  : DataOutStack<dim, spacedim, void>()
55  {}
56 };
57 #endif // DOXYGEN
58 
133 template <int dim, int spacedim>
134 class DataOutStack<dim, spacedim, void>
135  : public DataOutInterface<dim + 1, spacedim + 1>
136 {
137  static_assert(dim < 3,
138  "Because this class stacks data into the (dim+1)st "
139  "dimension to create graphical output, it only works for "
140  "dim<3.");
141  static_assert(dim == spacedim,
142  "This class is not implemented for dim != spacedim.");
143 
144 public:
148  static constexpr int patch_dim = dim + 1;
149  static constexpr int patch_spacedim = spacedim + 1;
150 
156  {
164  dof_vector
165  };
166 
170  virtual ~DataOutStack() override = default;
171 
178  void
179  new_parameter_value(const double parameter_value,
180  const double parameter_step);
181 
189  void
190  attach_dof_handler(const DoFHandler<dim, spacedim> &dof_handler);
191 
200  void
201  declare_data_vector(const std::string &name, const VectorType vector_type);
202 
214  void
215  declare_data_vector(const std::vector<std::string> &name,
216  const VectorType vector_type);
217 
218 
238  template <typename number>
239  void
240  add_data_vector(const Vector<number> &vec, const std::string &name);
241 
260  template <typename number>
261  void
262  add_data_vector(const Vector<number> & vec,
263  const std::vector<std::string> &names);
264 
280  void
281  build_patches(const unsigned int n_subdivisions = 0);
282 
289  void
290  finish_parameter_value();
291 
296  std::size_t
297  memory_consumption() const;
298 
303  ExcVectorNotDeclared,
304  std::string,
305  << "The data vector for which the first component has the name " << arg1
306  << " has not been added before.");
310  DeclExceptionMsg(ExcDataNotCleared,
311  "You cannot start a new time/parameter step before calling "
312  "finish_parameter_value() on the previous step.");
317  ExcDataAlreadyAdded,
318  "You cannot declare additional vectors after already calling "
319  "build_patches(). All data vectors need to be declared "
320  "before you call this function the first time.");
324  DeclException1(ExcNameAlreadyUsed,
325  std::string,
326  << "You tried to declare a component of a data vector with "
327  << "the name <" << arg1
328  << ">, but that name is already used.");
329 
330 private:
334  double parameter;
335 
341 
349 
353  std::vector<::DataOutBase::Patch<patch_dim, patch_spacedim>> patches;
354 
359  struct DataVector
360  {
365 
369  std::vector<std::string> names;
370 
375  std::size_t
376  memory_consumption() const;
377  };
378 
382  std::vector<DataVector> dof_data;
383 
387  std::vector<DataVector> cell_data;
388 
394  virtual const std::vector<::DataOutBase::Patch<
397  get_patches() const override;
398 
399 
404  virtual std::vector<std::string>
405  get_dataset_names() const override;
406 };
407 
408 
410 
411 #endif
SmartPointer< const DoFHandler< dim, spacedim >, DataOutStack< dim, spacedim, void > > dof_handler
std::vector< DataVector > cell_data
std::vector< DataVector > dof_data
std::vector<::DataOutBase::Patch< patch_dim, patch_spacedim > > patches
virtual ~DataOutStack() override=default
Definition: vector.h:109
#define DEAL_II_DEPRECATED
Definition: config.h:164
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:487
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:509
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)