Reference documentation for deal.II version GIT d7aca55de5 2022-08-10 12:50:02+00:00
\(\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 
114 template <int dim, int spacedim = dim>
115 class DataOutStack : public DataOutInterface<dim + 1, spacedim + 1>
116 {
117  static_assert(dim < 3,
118  "Because this class stacks data into the (dim+1)st "
119  "dimension to create graphical output, it only works for "
120  "dim<3.");
121  static_assert(dim == spacedim,
122  "This class is not implemented for dim != spacedim.");
123 
124 public:
128  static constexpr int patch_dim = dim + 1;
129  static constexpr int patch_spacedim = spacedim + 1;
130 
136  {
144  dof_vector
145  };
146 
150  virtual ~DataOutStack() override = default;
151 
158  void
159  new_parameter_value(const double parameter_value,
160  const double parameter_step);
161 
169  void
171 
180  void
181  declare_data_vector(const std::string &name, const VectorType vector_type);
182 
194  void
195  declare_data_vector(const std::vector<std::string> &name,
196  const VectorType vector_type);
197 
198 
218  template <typename number>
219  void
220  add_data_vector(const Vector<number> &vec, const std::string &name);
221 
240  template <typename number>
241  void
242  add_data_vector(const Vector<number> & vec,
243  const std::vector<std::string> &names);
244 
260  void
261  build_patches(const unsigned int n_subdivisions = 0);
262 
269  void
271 
276  std::size_t
277  memory_consumption() const;
278 
284  std::string,
285  << "The data vector for which the first component has the name " << arg1
286  << " has not been added before.");
291  "You cannot start a new time/parameter step before calling "
292  "finish_parameter_value() on the previous step.");
298  "You cannot declare additional vectors after already calling "
299  "build_patches(). All data vectors need to be declared "
300  "before you call this function the first time.");
305  std::string,
306  << "You tried to declare a component of a data vector with "
307  << "the name <" << arg1
308  << ">, but that name is already used.");
309 
310 private:
314  double parameter;
315 
321 
328 
332  std::vector<::DataOutBase::Patch<patch_dim, patch_spacedim>> patches;
333 
338  struct DataVector
339  {
344 
348  std::vector<std::string> names;
349 
354  std::size_t
355  memory_consumption() const;
356  };
357 
361  std::vector<DataVector> dof_data;
362 
366  std::vector<DataVector> cell_data;
367 
373  virtual const std::vector<
376  get_patches() const override;
377 
378 
383  virtual std::vector<std::string>
384  get_dataset_names() const override;
385 };
386 
387 
389 
390 #endif
std::size_t memory_consumption() const
static constexpr int patch_dim
void declare_data_vector(const std::string &name, const VectorType vector_type)
virtual std::vector< std::string > get_dataset_names() const override
std::vector< DataVector > cell_data
virtual ~DataOutStack() override=default
void new_parameter_value(const double parameter_value, const double parameter_step)
std::vector< DataVector > dof_data
SmartPointer< const DoFHandler< dim, spacedim >, DataOutStack< dim, spacedim > > dof_handler
void finish_parameter_value()
void attach_dof_handler(const DoFHandler< dim, spacedim > &dof_handler)
double parameter_step
static constexpr int patch_spacedim
void build_patches(const unsigned int n_subdivisions=0)
std::vector<::DataOutBase::Patch< patch_dim, patch_spacedim > > patches
virtual const std::vector< ::DataOutBase::Patch< DataOutStack< dim, spacedim >::patch_dim, DataOutStack< dim, spacedim >::patch_spacedim > > & get_patches() const override
void add_data_vector(const Vector< number > &vec, const std::string &name)
Definition: vector.h:110
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
static ::ExceptionBase & ExcNameAlreadyUsed(std::string arg1)
static ::ExceptionBase & ExcVectorNotDeclared(std::string arg1)
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:487
static ::ExceptionBase & ExcDataAlreadyAdded()
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:509
static ::ExceptionBase & ExcDataNotCleared()
std::size_t memory_consumption() const
std::vector< std::string > names