Reference documentation for deal.II version 9.2.0
\(\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 {
152  template <int spacedim>
154  {
171  std::vector<Tensor<1, spacedim>> normals;
172 
185  std::vector<Point<spacedim>> evaluation_points;
186 
195  template <typename DoFHandlerType>
196  void
197  set_cell(const typename DoFHandlerType::cell_iterator &cell);
198 
204  template <typename DoFHandlerType>
205  typename DoFHandlerType::cell_iterator
206  get_cell() const;
207 
208  private:
216  boost::any cell;
217  };
218 
237  template <int spacedim>
238  struct Scalar : public CommonInputs<spacedim>
239  {
245  std::vector<double> solution_values;
246 
260  std::vector<Tensor<1, spacedim>> solution_gradients;
261 
275  std::vector<Tensor<2, spacedim>> solution_hessians;
276  };
277 
278 
279 
317  template <int spacedim>
318  struct Vector : public CommonInputs<spacedim>
319  {
329  std::vector<::Vector<double>> solution_values;
330 
348  std::vector<std::vector<Tensor<1, spacedim>>> solution_gradients;
349 
367  std::vector<std::vector<Tensor<2, spacedim>>> solution_hessians;
368  };
369 
370 } // namespace DataPostprocessorInputs
371 
372 
501 template <int dim>
503 {
504 public:
510  virtual ~DataPostprocessor() override = default;
511 
531  virtual void
532  evaluate_scalar_field(const DataPostprocessorInputs::Scalar<dim> &input_data,
533  std::vector<Vector<double>> &computed_quantities) const;
534 
545  virtual void
546  evaluate_vector_field(const DataPostprocessorInputs::Vector<dim> &input_data,
547  std::vector<Vector<double>> &computed_quantities) const;
548 
553  virtual std::vector<std::string>
554  get_names() const = 0;
555 
578  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
579  get_data_component_interpretation() const;
580 
591  virtual UpdateFlags
592  get_needed_update_flags() const = 0;
593 };
594 
595 
596 
627 template <int dim>
629 {
630 public:
646  DataPostprocessorScalar(const std::string &name,
647  const UpdateFlags update_flags);
648 
654  virtual std::vector<std::string>
655  get_names() const override;
656 
664  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
665  get_data_component_interpretation() const override;
666 
672  virtual UpdateFlags
673  get_needed_update_flags() const override;
674 
675 private:
679  const std::string name;
681 };
682 
683 
684 
870 template <int dim>
872 {
873 public:
889  DataPostprocessorVector(const std::string &name,
890  const UpdateFlags update_flags);
891 
897  virtual std::vector<std::string>
898  get_names() const override;
899 
907  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
908  get_data_component_interpretation() const override;
909 
915  virtual UpdateFlags
916  get_needed_update_flags() const override;
917 
918 private:
922  const std::string name;
924 };
925 
926 
927 
1119 template <int dim>
1121 {
1122 public:
1138  DataPostprocessorTensor(const std::string &name,
1139  const UpdateFlags update_flags);
1140 
1146  virtual std::vector<std::string>
1147  get_names() const override;
1148 
1156  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1157  get_data_component_interpretation() const override;
1158 
1164  virtual UpdateFlags
1165  get_needed_update_flags() const override;
1166 
1167 private:
1171  const std::string name;
1173 };
1174 
1175 
1176 
1177 #ifndef DOXYGEN
1178 // -------------------- template functions ----------------------
1179 
1180 namespace DataPostprocessorInputs
1181 {
1182  template <int spacedim>
1183  template <typename DoFHandlerType>
1184  void
1186  const typename DoFHandlerType::cell_iterator &new_cell)
1187  {
1188  // see if we had previously already stored a cell that has the same
1189  // data type; if so, reuse the memory location and avoid calling 'new'
1190  // inside boost::any
1191  if (typename DoFHandlerType::cell_iterator *storage_location =
1192  boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell))
1193  *storage_location = new_cell;
1194  else
1195  // if we had nothing stored before, or if we had stored a different
1196  // data type, just let boost::any replace things
1197  cell = new_cell;
1198  }
1199 
1200 
1201 
1202  template <int spacedim>
1203  template <typename DoFHandlerType>
1204  typename DoFHandlerType::cell_iterator
1206  {
1207  Assert(cell.empty() == false,
1208  ExcMessage(
1209  "You are trying to access the cell associated with a "
1210  "DataPostprocessorInputs::Scalar object for which no cell has "
1211  "been set."));
1212  Assert(boost::any_cast<typename DoFHandlerType::cell_iterator>(&cell) !=
1213  nullptr,
1214  ExcMessage(
1215  "You are trying to access the cell associated with a "
1216  "DataPostprocessorInputs::Scalar with a DoFHandler type that "
1217  "is different from the type with which it has been set. For "
1218  "example, if the cell for which output is currently being "
1219  "generated belongs to a hp::DoFHandler<2,3> object, then you can "
1220  "only call the current function with a template argument "
1221  "equal to hp::DoFHandler<2,3>, but not with any other class "
1222  "type or dimension template argument."));
1223  return boost::any_cast<typename DoFHandlerType::cell_iterator>(cell);
1224  }
1225 } // namespace DataPostprocessorInputs
1226 
1227 #endif
1228 
1230 
1231 #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:1419
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:359
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:358
const UpdateFlags update_flags
std::vector< Tensor< 1, spacedim > > normals
std::vector<::Vector< double > > solution_values