Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
data_out_stack.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 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_data_out_stack_h
17 #define dealii_data_out_stack_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/data_out_base.h>
23 #include <deal.II/base/smartpointer.h>
24 
25 #include <deal.II/lac/vector.h>
26 
27 #include <deal.II/numerics/data_out_dof_data.h>
28 
29 #include <string>
30 #include <vector>
31 
32 DEAL_II_NAMESPACE_OPEN
33 
34 template <int dim, int spacedim>
35 class DoFHandler;
36 
112 template <int dim,
113  int spacedim = dim,
114  typename DoFHandlerType = DoFHandler<dim, spacedim>>
115 class DataOutStack : public DataOutInterface<dim + 1>
116 {
117 public:
123  {
132  };
133 
137  virtual ~DataOutStack() override = default;
138 
145  void
146  new_parameter_value(const double parameter_value,
147  const double parameter_step);
148 
156  void
157  attach_dof_handler(const DoFHandlerType &dof_handler);
158 
167  void
168  declare_data_vector(const std::string &name, const VectorType vector_type);
169 
181  void
182  declare_data_vector(const std::vector<std::string> &name,
183  const VectorType vector_type);
184 
185 
205  template <typename number>
206  void
207  add_data_vector(const Vector<number> &vec, const std::string &name);
208 
227  template <typename number>
228  void
229  add_data_vector(const Vector<number> & vec,
230  const std::vector<std::string> &names);
231 
247  void
248  build_patches(const unsigned int n_subdivisions = 0);
249 
256  void
258 
263  std::size_t
264  memory_consumption() const;
265 
271  std::string,
272  << "The data vector for which the first component has the name " << arg1
273  << " has not been added before.");
278  "You cannot start a new time/parameter step before calling "
279  "finish_parameter_value() on the previous step.");
285  "You cannot declare additional vectors after already calling "
286  "build_patches(). All data vectors need to be declared "
287  "before you call this function the first time.");
292  std::string,
293  << "You tried to declare a component of a data vector with "
294  << "the name <" << arg1
295  << ">, but that name is already used.");
296 
297 private:
301  double parameter;
302 
308 
313  SmartPointer<const DoFHandlerType,
316 
320  std::vector<::DataOutBase::Patch<dim + 1, dim + 1>> patches;
321 
326  struct DataVector
327  {
332 
336  std::vector<std::string> names;
337 
342  std::size_t
343  memory_consumption() const;
344  };
345 
349  std::vector<DataVector> dof_data;
350 
354  std::vector<DataVector> cell_data;
355 
361  virtual const std::vector<::DataOutBase::Patch<dim + 1, dim + 1>> &
362  get_patches() const override;
363 
364 
369  virtual std::vector<std::string>
370  get_dataset_names() const override;
371 };
372 
373 
374 DEAL_II_NAMESPACE_CLOSE
375 
376 #endif
static ::ExceptionBase & ExcNameAlreadyUsed(std::string arg1)
std::size_t memory_consumption() const
std::vector< DataVector > cell_data
static ::ExceptionBase & ExcDataAlreadyAdded()
void attach_dof_handler(const DoFHandlerType &dof_handler)
std::vector< DataVector > dof_data
virtual std::vector< std::string > get_dataset_names() const override
static ::ExceptionBase & ExcDataNotCleared()
SmartPointer< const DoFHandlerType, DataOutStack< dim, spacedim, DoFHandlerType > > dof_handler
std::size_t memory_consumption() const
double parameter_step
std::vector< std::string > names
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
void declare_data_vector(const std::string &name, const VectorType vector_type)
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:496
virtual const std::vector<::DataOutBase::Patch< dim+1, dim+1 > > & get_patches() const override
virtual ~DataOutStack() override=default
static ::ExceptionBase & ExcVectorNotDeclared(std::string arg1)
void build_patches(const unsigned int n_subdivisions=0)
std::vector<::DataOutBase::Patch< dim+1, dim+1 > > patches
void finish_parameter_value()
void new_parameter_value(const double parameter_value, const double parameter_step)
void add_data_vector(const Vector< number > &vec, const std::string &name)