Reference documentation for deal.II version Git 180c135554 2021-06-23 17:42:41 -0400
\(\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 - 2020 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 == spacedim, "Not implemented for dim != spacedim.");
138 
139 public:
143  static constexpr int patch_dim = dim + 1;
144  static constexpr int patch_spacedim = spacedim + 1;
145 
151  {
159  dof_vector
160  };
161 
165  virtual ~DataOutStack() override = default;
166 
173  void
174  new_parameter_value(const double parameter_value,
175  const double parameter_step);
176 
184  void
185  attach_dof_handler(const DoFHandler<dim, spacedim> &dof_handler);
186 
195  void
196  declare_data_vector(const std::string &name, const VectorType vector_type);
197 
209  void
210  declare_data_vector(const std::vector<std::string> &name,
211  const VectorType vector_type);
212 
213 
233  template <typename number>
234  void
235  add_data_vector(const Vector<number> &vec, const std::string &name);
236 
255  template <typename number>
256  void
257  add_data_vector(const Vector<number> & vec,
258  const std::vector<std::string> &names);
259 
275  void
276  build_patches(const unsigned int n_subdivisions = 0);
277 
284  void
285  finish_parameter_value();
286 
291  std::size_t
292  memory_consumption() const;
293 
298  ExcVectorNotDeclared,
299  std::string,
300  << "The data vector for which the first component has the name " << arg1
301  << " has not been added before.");
305  DeclExceptionMsg(ExcDataNotCleared,
306  "You cannot start a new time/parameter step before calling "
307  "finish_parameter_value() on the previous step.");
312  ExcDataAlreadyAdded,
313  "You cannot declare additional vectors after already calling "
314  "build_patches(). All data vectors need to be declared "
315  "before you call this function the first time.");
319  DeclException1(ExcNameAlreadyUsed,
320  std::string,
321  << "You tried to declare a component of a data vector with "
322  << "the name <" << arg1
323  << ">, but that name is already used.");
324 
325 private:
329  double parameter;
330 
336 
344 
348  std::vector<::DataOutBase::Patch<patch_dim, patch_spacedim>> patches;
349 
354  struct DataVector
355  {
359  Vector<double> data;
360 
364  std::vector<std::string> names;
365 
370  std::size_t
371  memory_consumption() const;
372  };
373 
377  std::vector<DataVector> dof_data;
378 
382  std::vector<DataVector> cell_data;
383 
389  virtual const std::vector<::DataOutBase::Patch<
392  get_patches() const override;
393 
394 
399  virtual std::vector<std::string>
400  get_dataset_names() const override;
401 };
402 
403 
405 
406 #endif
std::vector<::DataOutBase::Patch< patch_dim, patch_spacedim > > patches
std::vector< DataVector > cell_data
SmartPointer< const DoFHandler< dim, spacedim >, DataOutStack< dim, spacedim, void > > dof_handler
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:515
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:493
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:399
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:398
#define DEAL_II_DEPRECATED
Definition: config.h:158
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
std::vector< DataVector > dof_data