Reference documentation for deal.II version 9.0.0
data_postprocessor.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2007 - 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_data_postprocessor_h
17 #define dealii_data_postprocessor_h
18 
19 
20 
21 #include <deal.II/base/subscriptor.h>
22 #include <deal.II/base/tensor.h>
23 #include <deal.II/base/point.h>
24 #include <deal.II/lac/vector.h>
25 #include <deal.II/fe/fe_update_flags.h>
26 #include <deal.II/numerics/data_component_interpretation.h>
27 
28 #include <boost/any.hpp>
29 
30 #include <vector>
31 #include <string>
32 
33 DEAL_II_NAMESPACE_OPEN
34 
35 
41 {
145  template <int spacedim>
147  {
164  std::vector<Tensor<1, spacedim> > normals;
165 
178  std::vector<Point<spacedim> > evaluation_points;
179 
188  template <typename DoFHandlerType>
189  void
190  set_cell (const typename DoFHandlerType::cell_iterator &cell);
191 
197  template <typename DoFHandlerType>
198  typename DoFHandlerType::cell_iterator
199  get_cell () const;
200 
201  private:
209  boost::any cell;
210  };
211 
225  template <int spacedim>
226  struct Scalar : public CommonInputs<spacedim>
227  {
233  std::vector<double> solution_values;
234 
248  std::vector<Tensor<1, spacedim> > solution_gradients;
249 
263  std::vector<Tensor<2, spacedim> > solution_hessians;
264  };
265 
266 
267 
281  template <int spacedim>
282  struct Vector : public CommonInputs<spacedim>
283  {
293  std::vector<::Vector<double> > solution_values;
294 
312  std::vector<std::vector<Tensor<1, spacedim> > > solution_gradients;
313 
331  std::vector<std::vector<Tensor<2, spacedim> > > solution_hessians;
332  };
333 
334 }
335 
336 
423 template <int dim>
425 {
426 public:
427 
433  virtual ~DataPostprocessor () = default;
434 
453  virtual
454  void
456  std::vector<Vector<double> > &computed_quantities) const;
457 
463  virtual
464  void
466  std::vector<Vector<double> > &computed_quantities) const;
467 
472  virtual std::vector<std::string> get_names () const = 0;
473 
496  virtual
497  std::vector<DataComponentInterpretation::DataComponentInterpretation>
499 
507  virtual UpdateFlags get_needed_update_flags () const = 0;
508 };
509 
510 
511 
534 template <int dim>
536 {
537 public:
550  DataPostprocessorScalar (const std::string &name,
551  const UpdateFlags update_flags);
552 
558  virtual std::vector<std::string> get_names () const;
559 
567  virtual
568  std::vector<DataComponentInterpretation::DataComponentInterpretation>
570 
576  virtual UpdateFlags get_needed_update_flags () const;
577 
578 private:
582  const std::string name;
583  const UpdateFlags update_flags;
584 };
585 
586 
587 
769 template <int dim>
771 {
772 public:
785  DataPostprocessorVector (const std::string &name,
786  const UpdateFlags update_flags);
787 
793  virtual std::vector<std::string> get_names () const;
794 
802  virtual
803  std::vector<DataComponentInterpretation::DataComponentInterpretation>
805 
811  virtual UpdateFlags get_needed_update_flags () const;
812 
813 private:
817  const std::string name;
818  const UpdateFlags update_flags;
819 };
820 
821 
822 
1008 template <int dim>
1010 {
1011 public:
1024  DataPostprocessorTensor (const std::string &name,
1025  const UpdateFlags update_flags);
1026 
1032  virtual std::vector<std::string> get_names () const;
1033 
1041  virtual
1042  std::vector<DataComponentInterpretation::DataComponentInterpretation>
1044 
1050  virtual UpdateFlags get_needed_update_flags () const;
1051 
1052 private:
1056  const std::string name;
1057  const UpdateFlags update_flags;
1058 };
1059 
1060 
1061 
1062 #ifndef DOXYGEN
1063 // -------------------- template functions ----------------------
1064 
1065 namespace DataPostprocessorInputs
1066 {
1067 
1068  template <int spacedim>
1069  template <typename DoFHandlerType>
1070  void
1071  CommonInputs<spacedim>::set_cell (const typename DoFHandlerType::cell_iterator &new_cell)
1072  {
1073  // see if we had previously already stored a cell that has the same
1074  // data type; if so, reuse the memory location and avoid calling 'new'
1075  // inside boost::any
1076  if (typename DoFHandlerType::cell_iterator * storage_location
1077  = boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell))
1078  *storage_location = new_cell;
1079  else
1080  // if we had nothing stored before, or if we had stored a different
1081  // data type, just let boost::any replace things
1082  cell = new_cell;
1083  }
1084 
1085 
1086 
1087  template <int spacedim>
1088  template <typename DoFHandlerType>
1089  typename DoFHandlerType::cell_iterator
1091  {
1092  Assert(cell.empty() == false,
1093  ExcMessage ("You are trying to access the cell associated with a "
1094  "DataPostprocessorInputs::Scalar object for which no cell has "
1095  "been set."));
1096  Assert(boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell) != nullptr,
1097  ExcMessage ("You are trying to access the cell associated with a "
1098  "DataPostprocessorInputs::Scalar with a DoFHandler type that "
1099  "is different from the type with which it has been set. For "
1100  "example, if the cell for which output is currently being "
1101  "generated belongs to a hp::DoFHandler<2,3> object, then you can "
1102  "only call the current function with a template argument "
1103  "equal to hp::DoFHandler<2,3>, but not with any other class "
1104  "type or dimension template argument."));
1105  return boost::any_cast<typename DoFHandlerType::cell_iterator>(cell);
1106  }
1107 }
1108 
1109 #endif
1110 
1111 DEAL_II_NAMESPACE_CLOSE
1112 
1113 #endif
DataPostprocessorTensor(const std::string &name, const UpdateFlags update_flags)
virtual void evaluate_vector_field(const DataPostprocessorInputs::Vector< dim > &input_data, std::vector< Vector< double > > &computed_quantities) const
std::vector< std::vector< Tensor< 2, spacedim > > > solution_hessians
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &input_data, std::vector< Vector< double > > &computed_quantities) const
std::vector< double > solution_values
DoFHandlerType::cell_iterator get_cell() const
virtual std::vector< std::string > get_names() const
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const
DataPostprocessorScalar(const std::string &name, const UpdateFlags update_flags)
virtual UpdateFlags get_needed_update_flags() const
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
Definition: exceptions.h:1142
UpdateFlags
std::vector< std::vector< Tensor< 1, spacedim > > > solution_gradients
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const
void set_cell(const typename DoFHandlerType::cell_iterator &cell)
std::vector< Tensor< 2, spacedim > > solution_hessians
virtual std::vector< std::string > get_names() const
std::vector< Tensor< 1, spacedim > > solution_gradients
virtual std::vector< std::string > get_names() const
virtual UpdateFlags get_needed_update_flags() const
std::vector< Point< spacedim > > evaluation_points
DataPostprocessorVector(const std::string &name, const UpdateFlags update_flags)
virtual UpdateFlags get_needed_update_flags() const
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const
std::vector< Tensor< 1, spacedim > > normals
virtual std::vector< std::string > get_names() const =0
std::vector<::Vector< double > > solution_values
virtual ~DataPostprocessor()=default
virtual UpdateFlags get_needed_update_flags() const =0