Reference documentation for deal.II version GIT 472adc65c1 2022-06-27 15:55:01+00:00
\(\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 - 2022 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 
30 
31 #include <deal.II/lac/vector.h>
32 
34 
35 #include <boost/any.hpp>
36 
37 #include <string>
38 #include <vector>
39 
41 
42 
48 {
192  template <int spacedim>
194  {
198  CommonInputs();
199 
216  std::vector<Tensor<1, spacedim>> normals;
217 
230  std::vector<Point<spacedim>> evaluation_points;
231 
240  template <int dim>
241  void
243 
254  template <int dim>
255  void
258  const unsigned int face_number);
259 
265  template <int dim>
267  get_cell() const;
268 
278  unsigned int
279  get_face_number() const;
280 
281  private:
289  boost::any cell;
290 
295  unsigned int face_number;
296  };
297 
314  template <int spacedim>
315  struct Scalar : public CommonInputs<spacedim>
316  {
322  std::vector<double> solution_values;
323 
337  std::vector<Tensor<1, spacedim>> solution_gradients;
338 
352  std::vector<Tensor<2, spacedim>> solution_hessians;
353  };
354 
355 
356 
392  template <int spacedim>
393  struct Vector : public CommonInputs<spacedim>
394  {
404  std::vector<::Vector<double>> solution_values;
405 
423  std::vector<std::vector<Tensor<1, spacedim>>> solution_gradients;
424 
442  std::vector<std::vector<Tensor<2, spacedim>>> solution_hessians;
443  };
444 
445 } // namespace DataPostprocessorInputs
446 
447 
575 template <int dim>
577 {
578 public:
584  virtual ~DataPostprocessor() override = default;
585 
605  virtual void
607  std::vector<Vector<double>> &computed_quantities) const;
608 
619  virtual void
621  std::vector<Vector<double>> &computed_quantities) const;
622 
627  virtual std::vector<std::string>
628  get_names() const = 0;
629 
652  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
654 
665  virtual UpdateFlags
667 };
668 
669 
670 
700 template <int dim>
702 {
703 public:
719  DataPostprocessorScalar(const std::string &name,
720  const UpdateFlags update_flags);
721 
727  virtual std::vector<std::string>
728  get_names() const override;
729 
737  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
738  get_data_component_interpretation() const override;
739 
745  virtual UpdateFlags
746  get_needed_update_flags() const override;
747 
748 private:
752  const std::string name;
754 };
755 
756 
757 
944 template <int dim>
946 {
947 public:
963  DataPostprocessorVector(const std::string &name,
964  const UpdateFlags update_flags);
965 
971  virtual std::vector<std::string>
972  get_names() const override;
973 
981  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
982  get_data_component_interpretation() const override;
983 
989  virtual UpdateFlags
990  get_needed_update_flags() const override;
991 
992 private:
996  const std::string name;
998 };
999 
1000 
1001 
1192 template <int dim>
1194 {
1195 public:
1211  DataPostprocessorTensor(const std::string &name,
1212  const UpdateFlags update_flags);
1213 
1219  virtual std::vector<std::string>
1220  get_names() const override;
1221 
1229  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1230  get_data_component_interpretation() const override;
1231 
1237  virtual UpdateFlags
1238  get_needed_update_flags() const override;
1239 
1240 private:
1244  const std::string name;
1246 };
1247 
1248 
1249 
1257 {
1279  template <int dim>
1281  {
1282  public:
1286  BoundaryIds();
1287 
1292  virtual void
1295  std::vector<Vector<double>> &computed_quantities) const override;
1296  };
1297 } // namespace DataPostprocessors
1298 
1299 
1300 
1301 #ifndef DOXYGEN
1302 // -------------------- template functions ----------------------
1303 
1304 namespace DataPostprocessorInputs
1305 {
1306  template <int spacedim>
1307  template <int dim>
1308  void
1310  const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell)
1311  {
1312  // see if we had previously already stored a cell that has the same
1313  // data type; if so, reuse the memory location and avoid calling 'new'
1314  // inside boost::any
1315  if (typename DoFHandler<dim, spacedim>::cell_iterator *storage_location =
1316  boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1317  &cell))
1318  *storage_location = new_cell;
1319  else
1320  // if we had nothing stored before, or if we had stored a different
1321  // data type, just let boost::any replace things
1322  cell = new_cell;
1323 
1324  // Also reset the face number, just to make sure nobody
1325  // accidentally uses an outdated value.
1326  face_number = numbers::invalid_unsigned_int;
1327  }
1328 
1329 
1330 
1331  template <int spacedim>
1332  template <int dim>
1333  void
1335  const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell,
1336  const unsigned int new_face_number)
1337  {
1338  set_cell<dim>(new_cell);
1339  face_number = new_face_number;
1340  }
1341 
1342 
1343 
1344  template <int spacedim>
1345  template <int dim>
1348  {
1349  Assert(cell.empty() == false,
1350  ExcMessage(
1351  "You are trying to access the cell associated with a "
1352  "DataPostprocessorInputs::Scalar object for which no cell has "
1353  "been set."));
1354  Assert((boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1355  &cell) != nullptr),
1356  ExcMessage(
1357  "You are trying to access the cell associated with a "
1358  "DataPostprocessorInputs::Scalar with a DoFHandler type that is "
1359  "different from the type with which it has been set. For example, "
1360  "if the cell for which output is currently being generated "
1361  "belongs to a DoFHandler<2, 3> object, then you can only call the "
1362  "current function with a template argument equal to "
1363  "DoFHandler<2, 3>, but not with any other class type or dimension "
1364  "template argument."));
1365 
1366  return boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1367  cell);
1368  }
1369 } // namespace DataPostprocessorInputs
1370 
1371 #endif
1372 
1374 
1375 #endif
DataPostprocessorScalar(const std::string &name, const UpdateFlags update_flags)
virtual std::vector< std::string > get_names() const override
virtual UpdateFlags get_needed_update_flags() const override
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
const UpdateFlags update_flags
DataPostprocessorTensor(const std::string &name, const UpdateFlags update_flags)
virtual std::vector< std::string > get_names() const override
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
const UpdateFlags update_flags
virtual UpdateFlags get_needed_update_flags() const override
virtual std::vector< std::string > get_names() const override
virtual UpdateFlags get_needed_update_flags() const override
DataPostprocessorVector(const std::string &name, const UpdateFlags update_flags)
const UpdateFlags update_flags
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
virtual void evaluate_vector_field(const DataPostprocessorInputs::Vector< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
virtual std::vector< std::string > get_names() const =0
virtual ~DataPostprocessor() override=default
virtual UpdateFlags get_needed_update_flags() const =0
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &inputs, std::vector< Vector< double >> &computed_quantities) const override
Definition: vector.h:109
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
UpdateFlags
#define Assert(cond, exc)
Definition: exceptions.h:1473
static ::ExceptionBase & ExcMessage(std::string arg1)
static const unsigned int invalid_unsigned_int
Definition: types.h:201
DoFHandler< dim, spacedim >::cell_iterator get_cell() const
std::vector< Tensor< 1, spacedim > > normals
void set_cell_and_face(const typename DoFHandler< dim, spacedim >::cell_iterator &cell, const unsigned int face_number)
std::vector< Point< spacedim > > evaluation_points
void set_cell(const typename DoFHandler< dim, spacedim >::cell_iterator &cell)
std::vector< double > solution_values
std::vector< Tensor< 2, spacedim > > solution_hessians
std::vector< Tensor< 1, spacedim > > solution_gradients
std::vector< std::vector< Tensor< 2, spacedim > > > solution_hessians
std::vector<::Vector< double > > solution_values
std::vector< std::vector< Tensor< 1, spacedim > > > solution_gradients