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
533  std::vector<Vector<double>> &computed_quantities) const;
534 
545  virtual void
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>
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
DataPostprocessorVector
Definition: data_postprocessor.h:871
DataPostprocessorScalar::get_names
virtual std::vector< std::string > get_names() const override
Definition: data_postprocessor.cc:71
DataPostprocessor
Definition: data_postprocessor.h:502
DataPostprocessorVector::get_needed_update_flags
virtual UpdateFlags get_needed_update_flags() const override
Definition: data_postprocessor.cc:128
DataPostprocessorTensor::get_needed_update_flags
virtual UpdateFlags get_needed_update_flags() const override
Definition: data_postprocessor.cc:175
fe_update_flags.h
DataPostprocessorVector::name
const std::string name
Definition: data_postprocessor.h:922
DataPostprocessorTensor::get_names
virtual std::vector< std::string > get_names() const override
Definition: data_postprocessor.cc:149
DataPostprocessorTensor::DataPostprocessorTensor
DataPostprocessorTensor(const std::string &name, const UpdateFlags update_flags)
Definition: data_postprocessor.cc:138
DataPostprocessorScalar::DataPostprocessorScalar
DataPostprocessorScalar(const std::string &name, const UpdateFlags update_flags)
Definition: data_postprocessor.cc:60
DataPostprocessorInputs::CommonInputs
Definition: data_postprocessor.h:153
DataPostprocessorTensor::get_data_component_interpretation
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
Definition: data_postprocessor.cc:166
DataPostprocessorInputs::CommonInputs::get_cell
DoFHandlerType::cell_iterator get_cell() const
DataPostprocessorInputs::Vector::solution_hessians
std::vector< std::vector< Tensor< 2, spacedim > > > solution_hessians
Definition: data_postprocessor.h:367
DataPostprocessorScalar::name
const std::string name
Definition: data_postprocessor.h:679
Subscriptor
Definition: subscriptor.h:62
DataPostprocessor::evaluate_vector_field
virtual void evaluate_vector_field(const DataPostprocessorInputs::Vector< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
Definition: data_postprocessor.cc:37
tensor.h
DataPostprocessorInputs::Vector::solution_values
std::vector<::Vector< double > > solution_values
Definition: data_postprocessor.h:329
StandardExceptions::ExcMessage
static ::ExceptionBase & ExcMessage(std::string arg1)
DataPostprocessorInputs::Scalar
Definition: data_postprocessor.h:238
subscriptor.h
DataPostprocessorVector::update_flags
const UpdateFlags update_flags
Definition: data_postprocessor.h:923
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
DataPostprocessorTensor
Definition: data_postprocessor.h:1120
DataPostprocessorInputs::Scalar::solution_hessians
std::vector< Tensor< 2, spacedim > > solution_hessians
Definition: data_postprocessor.h:275
DataPostprocessorScalar::get_data_component_interpretation
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
Definition: data_postprocessor.cc:80
UpdateFlags
UpdateFlags
Definition: fe_update_flags.h:66
DataPostprocessorTensor::name
const std::string name
Definition: data_postprocessor.h:1171
DataPostprocessorInputs::CommonInputs::cell
boost::any cell
Definition: data_postprocessor.h:216
DataPostprocessorVector::get_data_component_interpretation
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
Definition: data_postprocessor.cc:119
DataPostprocessorInputs::CommonInputs::evaluation_points
std::vector< Point< spacedim > > evaluation_points
Definition: data_postprocessor.h:185
DataPostprocessorTensor::update_flags
const UpdateFlags update_flags
Definition: data_postprocessor.h:1172
DataPostprocessorInputs::Scalar::solution_gradients
std::vector< Tensor< 1, spacedim > > solution_gradients
Definition: data_postprocessor.h:260
Assert
#define Assert(cond, exc)
Definition: exceptions.h:1419
vector.h
DataPostprocessorInputs::CommonInputs::normals
std::vector< Tensor< 1, spacedim > > normals
Definition: data_postprocessor.h:171
DataPostprocessorInputs::CommonInputs::set_cell
void set_cell(const typename DoFHandlerType::cell_iterator &cell)
data_component_interpretation.h
DataPostprocessorInputs
Definition: data_postprocessor.h:45
DataPostprocessorInputs::Scalar::solution_values
std::vector< double > solution_values
Definition: data_postprocessor.h:245
config.h
DataPostprocessor::~DataPostprocessor
virtual ~DataPostprocessor() override=default
DataPostprocessorScalar
Definition: data_postprocessor.h:628
DataPostprocessor::get_needed_update_flags
virtual UpdateFlags get_needed_update_flags() const =0
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
DataPostprocessor::get_names
virtual std::vector< std::string > get_names() const =0
DataPostprocessorScalar::update_flags
const UpdateFlags update_flags
Definition: data_postprocessor.h:680
Vector< double >
DataPostprocessor::evaluate_scalar_field
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
Definition: data_postprocessor.cc:26
DataPostprocessorVector::DataPostprocessorVector
DataPostprocessorVector(const std::string &name, const UpdateFlags update_flags)
Definition: data_postprocessor.cc:99
DataPostprocessorInputs::Vector::solution_gradients
std::vector< std::vector< Tensor< 1, spacedim > > > solution_gradients
Definition: data_postprocessor.h:348
DataPostprocessorInputs::Vector
Definition: data_postprocessor.h:318
DataPostprocessorScalar::get_needed_update_flags
virtual UpdateFlags get_needed_update_flags() const override
Definition: data_postprocessor.cc:89
DataPostprocessor::get_data_component_interpretation
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const
Definition: data_postprocessor.cc:48
point.h
DataPostprocessorVector::get_names
virtual std::vector< std::string > get_names() const override
Definition: data_postprocessor.cc:110