Reference documentation for deal.II version 9.1.1
\(\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
460  std::vector<Vector<double>> &computed_quantities) const;
461 
467  virtual void
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>
502 
510  virtual UpdateFlags
511  get_needed_update_flags() const = 0;
512 };
513 
514 
515 
538 template <int dim>
540 {
541 public:
554  DataPostprocessorScalar(const std::string &name,
555  const UpdateFlags update_flags);
556 
562  virtual std::vector<std::string>
563  get_names() const override;
564 
572  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
573  get_data_component_interpretation() const override;
574 
580  virtual UpdateFlags
581  get_needed_update_flags() const override;
582 
583 private:
587  const std::string name;
588  const UpdateFlags update_flags;
589 };
590 
591 
592 
777 template <int dim>
779 {
780 public:
793  DataPostprocessorVector(const std::string &name,
794  const UpdateFlags update_flags);
795 
801  virtual std::vector<std::string>
802  get_names() const override;
803 
811  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
812  get_data_component_interpretation() const override;
813 
819  virtual UpdateFlags
820  get_needed_update_flags() const override;
821 
822 private:
826  const std::string name;
827  const UpdateFlags update_flags;
828 };
829 
830 
831 
1022 template <int dim>
1024 {
1025 public:
1038  DataPostprocessorTensor(const std::string &name,
1039  const UpdateFlags update_flags);
1040 
1046  virtual std::vector<std::string>
1047  get_names() const override;
1048 
1056  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1057  get_data_component_interpretation() const override;
1058 
1064  virtual UpdateFlags
1065  get_needed_update_flags() const override;
1066 
1067 private:
1071  const std::string name;
1072  const UpdateFlags update_flags;
1073 };
1074 
1075 
1076 
1077 #ifndef DOXYGEN
1078 // -------------------- template functions ----------------------
1079 
1080 namespace DataPostprocessorInputs
1081 {
1082  template <int spacedim>
1083  template <typename DoFHandlerType>
1084  void
1086  const typename DoFHandlerType::cell_iterator &new_cell)
1087  {
1088  // see if we had previously already stored a cell that has the same
1089  // data type; if so, reuse the memory location and avoid calling 'new'
1090  // inside boost::any
1091  if (typename DoFHandlerType::cell_iterator *storage_location =
1092  boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell))
1093  *storage_location = new_cell;
1094  else
1095  // if we had nothing stored before, or if we had stored a different
1096  // data type, just let boost::any replace things
1097  cell = new_cell;
1098  }
1099 
1100 
1101 
1102  template <int spacedim>
1103  template <typename DoFHandlerType>
1104  typename DoFHandlerType::cell_iterator
1106  {
1107  Assert(cell.empty() == false,
1108  ExcMessage(
1109  "You are trying to access the cell associated with a "
1110  "DataPostprocessorInputs::Scalar object for which no cell has "
1111  "been set."));
1112  Assert(boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell) !=
1113  nullptr,
1114  ExcMessage(
1115  "You are trying to access the cell associated with a "
1116  "DataPostprocessorInputs::Scalar with a DoFHandler type that "
1117  "is different from the type with which it has been set. For "
1118  "example, if the cell for which output is currently being "
1119  "generated belongs to a hp::DoFHandler<2,3> object, then you can "
1120  "only call the current function with a template argument "
1121  "equal to hp::DoFHandler<2,3>, but not with any other class "
1122  "type or dimension template argument."));
1123  return boost::any_cast<typename DoFHandlerType::cell_iterator>(cell);
1124  }
1125 } // namespace DataPostprocessorInputs
1126 
1127 #endif
1128 
1129 DEAL_II_NAMESPACE_CLOSE
1130 
1131 #endif
virtual std::vector< std::string > get_names() const override
DataPostprocessorTensor(const std::string &name, const UpdateFlags update_flags)
virtual std::vector< std::string > get_names() const override
std::vector< std::vector< Tensor< 2, spacedim > > > solution_hessians
std::vector< double > solution_values
virtual std::vector< std::string > get_names() const override
DoFHandlerType::cell_iterator get_cell() const
virtual UpdateFlags get_needed_update_flags() const override
virtual void evaluate_vector_field(const DataPostprocessorInputs::Vector< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
DataPostprocessorScalar(const std::string &name, const UpdateFlags update_flags)
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
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)
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
std::vector< Tensor< 2, spacedim > > solution_hessians
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
std::vector< Tensor< 1, spacedim > > solution_gradients
std::vector< Point< spacedim > > evaluation_points
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
DataPostprocessorVector(const std::string &name, const UpdateFlags update_flags)
virtual UpdateFlags get_needed_update_flags() const override
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const
std::vector< Tensor< 1, spacedim > > normals
virtual UpdateFlags get_needed_update_flags() const override
virtual std::vector< std::string > get_names() const =0
std::vector<::Vector< double > > solution_values
virtual ~DataPostprocessor() override=default
virtual UpdateFlags get_needed_update_flags() const =0