Reference documentation for deal.II version Git d435e92be9 2020-09-23 09:04:26 -0400
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
data_postprocessor.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2007 - 2020 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/config.h>
22 
23 #include <deal.II/base/point.h>
25 #include <deal.II/base/tensor.h>
26 
28 
29 #include <deal.II/lac/vector.h>
30 
32 
33 #include <boost/any.hpp>
34 
35 #include <string>
36 #include <vector>
37 
39 
40 
46 {
148  template <int spacedim>
150  {
167  std::vector<Tensor<1, spacedim>> normals;
168 
181  std::vector<Point<spacedim>> evaluation_points;
182 
191  template <typename DoFHandlerType>
192  void
193  set_cell(const typename DoFHandlerType::cell_iterator &cell);
194 
200  template <typename DoFHandlerType>
201  typename DoFHandlerType::cell_iterator
202  get_cell() const;
203 
204  private:
212  boost::any cell;
213  };
214 
231  template <int spacedim>
232  struct Scalar : public CommonInputs<spacedim>
233  {
239  std::vector<double> solution_values;
240 
254  std::vector<Tensor<1, spacedim>> solution_gradients;
255 
269  std::vector<Tensor<2, spacedim>> solution_hessians;
270  };
271 
272 
273 
309  template <int spacedim>
310  struct Vector : public CommonInputs<spacedim>
311  {
321  std::vector<::Vector<double>> solution_values;
322 
340  std::vector<std::vector<Tensor<1, spacedim>>> solution_gradients;
341 
359  std::vector<std::vector<Tensor<2, spacedim>>> solution_hessians;
360  };
361 
362 } // namespace DataPostprocessorInputs
363 
364 
492 template <int dim>
494 {
495 public:
501  virtual ~DataPostprocessor() override = default;
502 
522  virtual void
523  evaluate_scalar_field(const DataPostprocessorInputs::Scalar<dim> &input_data,
524  std::vector<Vector<double>> &computed_quantities) const;
525 
536  virtual void
537  evaluate_vector_field(const DataPostprocessorInputs::Vector<dim> &input_data,
538  std::vector<Vector<double>> &computed_quantities) const;
539 
544  virtual std::vector<std::string>
545  get_names() const = 0;
546 
569  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
570  get_data_component_interpretation() const;
571 
582  virtual UpdateFlags
583  get_needed_update_flags() const = 0;
584 };
585 
586 
587 
617 template <int dim>
619 {
620 public:
636  DataPostprocessorScalar(const std::string &name,
637  const UpdateFlags update_flags);
638 
644  virtual std::vector<std::string>
645  get_names() const override;
646 
654  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
655  get_data_component_interpretation() const override;
656 
662  virtual UpdateFlags
663  get_needed_update_flags() const override;
664 
665 private:
669  const std::string name;
671 };
672 
673 
674 
861 template <int dim>
863 {
864 public:
880  DataPostprocessorVector(const std::string &name,
881  const UpdateFlags update_flags);
882 
888  virtual std::vector<std::string>
889  get_names() const override;
890 
898  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
899  get_data_component_interpretation() const override;
900 
906  virtual UpdateFlags
907  get_needed_update_flags() const override;
908 
909 private:
913  const std::string name;
915 };
916 
917 
918 
1109 template <int dim>
1111 {
1112 public:
1128  DataPostprocessorTensor(const std::string &name,
1129  const UpdateFlags update_flags);
1130 
1136  virtual std::vector<std::string>
1137  get_names() const override;
1138 
1146  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1147  get_data_component_interpretation() const override;
1148 
1154  virtual UpdateFlags
1155  get_needed_update_flags() const override;
1156 
1157 private:
1161  const std::string name;
1163 };
1164 
1165 
1166 
1167 #ifndef DOXYGEN
1168 // -------------------- template functions ----------------------
1169 
1170 namespace DataPostprocessorInputs
1171 {
1172  template <int spacedim>
1173  template <typename DoFHandlerType>
1174  void
1176  const typename DoFHandlerType::cell_iterator &new_cell)
1177  {
1178  // see if we had previously already stored a cell that has the same
1179  // data type; if so, reuse the memory location and avoid calling 'new'
1180  // inside boost::any
1181  if (typename DoFHandlerType::cell_iterator *storage_location =
1182  boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell))
1183  *storage_location = new_cell;
1184  else
1185  // if we had nothing stored before, or if we had stored a different
1186  // data type, just let boost::any replace things
1187  cell = new_cell;
1188  }
1189 
1190 
1191 
1192  template <int spacedim>
1193  template <typename DoFHandlerType>
1194  typename DoFHandlerType::cell_iterator
1196  {
1197  Assert(cell.empty() == false,
1198  ExcMessage(
1199  "You are trying to access the cell associated with a "
1200  "DataPostprocessorInputs::Scalar object for which no cell has "
1201  "been set."));
1202  Assert(boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell) !=
1203  nullptr,
1204  ExcMessage(
1205  "You are trying to access the cell associated with a "
1206  "DataPostprocessorInputs::Scalar with a DoFHandler type that is "
1207  "different from the type with which it has been set. For example, "
1208  "if the cell for which output is currently being generated "
1209  "belongs to a DoFHandler<2, 3> object, then you can only call the "
1210  "current function with a template argument equal to "
1211  "DoFHandler<2, 3>, but not with any other class type or dimension "
1212  "template argument."));
1213  return boost::any_cast<typename DoFHandlerType::cell_iterator>(cell);
1214  }
1215 } // namespace DataPostprocessorInputs
1216 
1217 #endif
1218 
1220 
1221 #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)
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:363
const UpdateFlags update_flags
std::vector< Tensor< 2, spacedim > > solution_hessians
const UpdateFlags update_flags
std::vector< Tensor< 1, spacedim > > solution_gradients
std::vector< Point< spacedim > > evaluation_points
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:362
const UpdateFlags update_flags
std::vector< Tensor< 1, spacedim > > normals
std::vector<::Vector< double > > solution_values