Reference documentation for deal.II version Git e512aac53a 2019-11-15 17:29:53 -0500
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
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.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_data_postprocessor_h
17 #define dealii_data_postprocessor_h
18 
19 
20 
21 #include <deal.II/base/point.h>
22 #include <deal.II/base/subscriptor.h>
23 #include <deal.II/base/tensor.h>
24 
25 #include <deal.II/fe/fe_update_flags.h>
26 
27 #include <deal.II/lac/vector.h>
28 
29 #include <deal.II/numerics/data_component_interpretation.h>
30 
31 #include <boost/any.hpp>
32 
33 #include <string>
34 #include <vector>
35 
36 DEAL_II_NAMESPACE_OPEN
37 
38 
44 {
150  template <int spacedim>
152  {
169  std::vector<Tensor<1, spacedim>> normals;
170 
183  std::vector<Point<spacedim>> evaluation_points;
184 
193  template <typename DoFHandlerType>
194  void
195  set_cell(const typename DoFHandlerType::cell_iterator &cell);
196 
202  template <typename DoFHandlerType>
203  typename DoFHandlerType::cell_iterator
204  get_cell() const;
205 
206  private:
214  boost::any cell;
215  };
216 
235  template <int spacedim>
236  struct Scalar : public CommonInputs<spacedim>
237  {
243  std::vector<double> solution_values;
244 
258  std::vector<Tensor<1, spacedim>> solution_gradients;
259 
273  std::vector<Tensor<2, spacedim>> solution_hessians;
274  };
275 
276 
277 
314  template <int spacedim>
315  struct Vector : public CommonInputs<spacedim>
316  {
326  std::vector<::Vector<double>> solution_values;
327 
345  std::vector<std::vector<Tensor<1, spacedim>>> solution_gradients;
346 
364  std::vector<std::vector<Tensor<2, spacedim>>> solution_hessians;
365  };
366 
367 } // namespace DataPostprocessorInputs
368 
369 
495 template <int dim>
497 {
498 public:
504  virtual ~DataPostprocessor() override = default;
505 
525  virtual void
526  evaluate_scalar_field(const DataPostprocessorInputs::Scalar<dim> &input_data,
527  std::vector<Vector<double>> &computed_quantities) const;
528 
539  virtual void
540  evaluate_vector_field(const DataPostprocessorInputs::Vector<dim> &input_data,
541  std::vector<Vector<double>> &computed_quantities) const;
542 
547  virtual std::vector<std::string>
548  get_names() const = 0;
549 
572  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
573  get_data_component_interpretation() const;
574 
585  virtual UpdateFlags
586  get_needed_update_flags() const = 0;
587 };
588 
589 
590 
614 template <int dim>
616 {
617 public:
633  DataPostprocessorScalar(const std::string &name,
634  const UpdateFlags update_flags);
635 
641  virtual std::vector<std::string>
642  get_names() const override;
643 
651  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
652  get_data_component_interpretation() const override;
653 
659  virtual UpdateFlags
660  get_needed_update_flags() const override;
661 
662 private:
666  const std::string name;
667  const UpdateFlags update_flags;
668 };
669 
670 
671 
857 template <int dim>
859 {
860 public:
876  DataPostprocessorVector(const std::string &name,
877  const UpdateFlags update_flags);
878 
884  virtual std::vector<std::string>
885  get_names() const override;
886 
894  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
895  get_data_component_interpretation() const override;
896 
902  virtual UpdateFlags
903  get_needed_update_flags() const override;
904 
905 private:
909  const std::string name;
910  const UpdateFlags update_flags;
911 };
912 
913 
914 
1106 template <int dim>
1108 {
1109 public:
1125  DataPostprocessorTensor(const std::string &name,
1126  const UpdateFlags update_flags);
1127 
1133  virtual std::vector<std::string>
1134  get_names() const override;
1135 
1143  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1144  get_data_component_interpretation() const override;
1145 
1151  virtual UpdateFlags
1152  get_needed_update_flags() const override;
1153 
1154 private:
1158  const std::string name;
1159  const UpdateFlags update_flags;
1160 };
1161 
1162 
1163 
1164 #ifndef DOXYGEN
1165 // -------------------- template functions ----------------------
1166 
1167 namespace DataPostprocessorInputs
1168 {
1169  template <int spacedim>
1170  template <typename DoFHandlerType>
1171  void
1173  const typename DoFHandlerType::cell_iterator &new_cell)
1174  {
1175  // see if we had previously already stored a cell that has the same
1176  // data type; if so, reuse the memory location and avoid calling 'new'
1177  // inside boost::any
1178  if (typename DoFHandlerType::cell_iterator *storage_location =
1179  boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell))
1180  *storage_location = new_cell;
1181  else
1182  // if we had nothing stored before, or if we had stored a different
1183  // data type, just let boost::any replace things
1184  cell = new_cell;
1185  }
1186 
1187 
1188 
1189  template <int spacedim>
1190  template <typename DoFHandlerType>
1191  typename DoFHandlerType::cell_iterator
1193  {
1194  Assert(cell.empty() == false,
1195  ExcMessage(
1196  "You are trying to access the cell associated with a "
1197  "DataPostprocessorInputs::Scalar object for which no cell has "
1198  "been set."));
1199  Assert(boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell) !=
1200  nullptr,
1201  ExcMessage(
1202  "You are trying to access the cell associated with a "
1203  "DataPostprocessorInputs::Scalar with a DoFHandler type that "
1204  "is different from the type with which it has been set. For "
1205  "example, if the cell for which output is currently being "
1206  "generated belongs to a hp::DoFHandler<2,3> object, then you can "
1207  "only call the current function with a template argument "
1208  "equal to hp::DoFHandler<2,3>, but not with any other class "
1209  "type or dimension template argument."));
1210  return boost::any_cast<typename DoFHandlerType::cell_iterator>(cell);
1211  }
1212 } // namespace DataPostprocessorInputs
1213 
1214 #endif
1215 
1216 DEAL_II_NAMESPACE_CLOSE
1217 
1218 #endif
std::vector< std::vector< Tensor< 2, spacedim > > > solution_hessians
std::vector< double > solution_values
DoFHandlerType::cell_iterator get_cell() const
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
Definition: exceptions.h:1411
UpdateFlags
std::vector< std::vector< Tensor< 1, spacedim > > > solution_gradients
void set_cell(const typename DoFHandlerType::cell_iterator &cell)
std::vector< Tensor< 2, spacedim > > solution_hessians
std::vector< Tensor< 1, spacedim > > solution_gradients
std::vector< Point< spacedim > > evaluation_points
std::vector< Tensor< 1, spacedim > > normals
std::vector<::Vector< double > > solution_values