Reference documentation for deal.II version Git cb0bd54b52 2019-09-21 16:31:22 -0400
\(\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 
230  template <int spacedim>
231  struct Scalar : public CommonInputs<spacedim>
232  {
238  std::vector<double> solution_values;
239 
253  std::vector<Tensor<1, spacedim>> solution_gradients;
254 
268  std::vector<Tensor<2, spacedim>> solution_hessians;
269  };
270 
271 
272 
286  template <int spacedim>
287  struct Vector : public CommonInputs<spacedim>
288  {
298  std::vector<::Vector<double>> solution_values;
299 
317  std::vector<std::vector<Tensor<1, spacedim>>> solution_gradients;
318 
336  std::vector<std::vector<Tensor<2, spacedim>>> solution_hessians;
337  };
338 
339 } // namespace DataPostprocessorInputs
340 
341 
428 template <int dim>
430 {
431 public:
437  virtual ~DataPostprocessor() override = default;
438 
458  virtual void
459  evaluate_scalar_field(const DataPostprocessorInputs::Scalar<dim> &input_data,
460  std::vector<Vector<double>> &computed_quantities) const;
461 
467  virtual void
468  evaluate_vector_field(const DataPostprocessorInputs::Vector<dim> &input_data,
469  std::vector<Vector<double>> &computed_quantities) const;
470 
475  virtual std::vector<std::string>
476  get_names() const = 0;
477 
500  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
501  get_data_component_interpretation() const;
502 
513  virtual UpdateFlags
514  get_needed_update_flags() const = 0;
515 };
516 
517 
518 
541 template <int dim>
543 {
544 public:
560  DataPostprocessorScalar(const std::string &name,
561  const UpdateFlags update_flags);
562 
568  virtual std::vector<std::string>
569  get_names() const override;
570 
578  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
579  get_data_component_interpretation() const override;
580 
586  virtual UpdateFlags
587  get_needed_update_flags() const override;
588 
589 private:
593  const std::string name;
594  const UpdateFlags update_flags;
595 };
596 
597 
598 
783 template <int dim>
785 {
786 public:
802  DataPostprocessorVector(const std::string &name,
803  const UpdateFlags update_flags);
804 
810  virtual std::vector<std::string>
811  get_names() const override;
812 
820  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
821  get_data_component_interpretation() const override;
822 
828  virtual UpdateFlags
829  get_needed_update_flags() const override;
830 
831 private:
835  const std::string name;
836  const UpdateFlags update_flags;
837 };
838 
839 
840 
1031 template <int dim>
1033 {
1034 public:
1050  DataPostprocessorTensor(const std::string &name,
1051  const UpdateFlags update_flags);
1052 
1058  virtual std::vector<std::string>
1059  get_names() const override;
1060 
1068  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1069  get_data_component_interpretation() const override;
1070 
1076  virtual UpdateFlags
1077  get_needed_update_flags() const override;
1078 
1079 private:
1083  const std::string name;
1084  const UpdateFlags update_flags;
1085 };
1086 
1087 
1088 
1089 #ifndef DOXYGEN
1090 // -------------------- template functions ----------------------
1091 
1092 namespace DataPostprocessorInputs
1093 {
1094  template <int spacedim>
1095  template <typename DoFHandlerType>
1096  void
1098  const typename DoFHandlerType::cell_iterator &new_cell)
1099  {
1100  // see if we had previously already stored a cell that has the same
1101  // data type; if so, reuse the memory location and avoid calling 'new'
1102  // inside boost::any
1103  if (typename DoFHandlerType::cell_iterator *storage_location =
1104  boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell))
1105  *storage_location = new_cell;
1106  else
1107  // if we had nothing stored before, or if we had stored a different
1108  // data type, just let boost::any replace things
1109  cell = new_cell;
1110  }
1111 
1112 
1113 
1114  template <int spacedim>
1115  template <typename DoFHandlerType>
1116  typename DoFHandlerType::cell_iterator
1118  {
1119  Assert(cell.empty() == false,
1120  ExcMessage(
1121  "You are trying to access the cell associated with a "
1122  "DataPostprocessorInputs::Scalar object for which no cell has "
1123  "been set."));
1124  Assert(boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell) !=
1125  nullptr,
1126  ExcMessage(
1127  "You are trying to access the cell associated with a "
1128  "DataPostprocessorInputs::Scalar with a DoFHandler type that "
1129  "is different from the type with which it has been set. For "
1130  "example, if the cell for which output is currently being "
1131  "generated belongs to a hp::DoFHandler<2,3> object, then you can "
1132  "only call the current function with a template argument "
1133  "equal to hp::DoFHandler<2,3>, but not with any other class "
1134  "type or dimension template argument."));
1135  return boost::any_cast<typename DoFHandlerType::cell_iterator>(cell);
1136  }
1137 } // namespace DataPostprocessorInputs
1138 
1139 #endif
1140 
1141 DEAL_II_NAMESPACE_CLOSE
1142 
1143 #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:1407
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