Reference documentation for deal.II version 9.4.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 - 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 
271  template <typename DoFHandlerType>
272  DEAL_II_DEPRECATED void
273  set_cell(const typename DoFHandlerType::cell_iterator &cell);
274 
280  template <int dim>
282  get_cell() const;
283 
292  template <typename DoFHandlerType>
293  DEAL_II_DEPRECATED typename DoFHandlerType::cell_iterator
294  get_cell() const;
295 
305  unsigned int
306  get_face_number() const;
307 
308  private:
316  boost::any cell;
317 
322  unsigned int face_number;
323  };
324 
341  template <int spacedim>
342  struct Scalar : public CommonInputs<spacedim>
343  {
349  std::vector<double> solution_values;
350 
364  std::vector<Tensor<1, spacedim>> solution_gradients;
365 
379  std::vector<Tensor<2, spacedim>> solution_hessians;
380  };
381 
382 
383 
419  template <int spacedim>
420  struct Vector : public CommonInputs<spacedim>
421  {
431  std::vector<::Vector<double>> solution_values;
432 
450  std::vector<std::vector<Tensor<1, spacedim>>> solution_gradients;
451 
469  std::vector<std::vector<Tensor<2, spacedim>>> solution_hessians;
470  };
471 
472 } // namespace DataPostprocessorInputs
473 
474 
602 template <int dim>
604 {
605 public:
611  virtual ~DataPostprocessor() override = default;
612 
632  virtual void
634  std::vector<Vector<double>> &computed_quantities) const;
635 
646  virtual void
648  std::vector<Vector<double>> &computed_quantities) const;
649 
654  virtual std::vector<std::string>
655  get_names() const = 0;
656 
679  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
681 
692  virtual UpdateFlags
694 };
695 
696 
697 
727 template <int dim>
729 {
730 public:
746  DataPostprocessorScalar(const std::string &name,
747  const UpdateFlags update_flags);
748 
754  virtual std::vector<std::string>
755  get_names() const override;
756 
764  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
765  get_data_component_interpretation() const override;
766 
772  virtual UpdateFlags
773  get_needed_update_flags() const override;
774 
775 private:
779  const std::string name;
781 };
782 
783 
784 
971 template <int dim>
973 {
974 public:
990  DataPostprocessorVector(const std::string &name,
991  const UpdateFlags update_flags);
992 
998  virtual std::vector<std::string>
999  get_names() const override;
1000 
1008  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1009  get_data_component_interpretation() const override;
1010 
1016  virtual UpdateFlags
1017  get_needed_update_flags() const override;
1018 
1019 private:
1023  const std::string name;
1025 };
1026 
1027 
1028 
1219 template <int dim>
1221 {
1222 public:
1238  DataPostprocessorTensor(const std::string &name,
1239  const UpdateFlags update_flags);
1240 
1246  virtual std::vector<std::string>
1247  get_names() const override;
1248 
1256  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1257  get_data_component_interpretation() const override;
1258 
1264  virtual UpdateFlags
1265  get_needed_update_flags() const override;
1266 
1267 private:
1271  const std::string name;
1273 };
1274 
1275 
1276 
1284 {
1306  template <int dim>
1308  {
1309  public:
1313  BoundaryIds();
1314 
1319  virtual void
1322  std::vector<Vector<double>> &computed_quantities) const override;
1323  };
1324 } // namespace DataPostprocessors
1325 
1326 
1327 
1328 #ifndef DOXYGEN
1329 // -------------------- template functions ----------------------
1330 
1331 namespace DataPostprocessorInputs
1332 {
1333  template <int spacedim>
1334  template <typename DoFHandlerType>
1335  void
1337  const typename DoFHandlerType::cell_iterator &new_cell)
1338  {
1339  return set_cell<DoFHandlerType::dimension>(new_cell);
1340  }
1341 
1342 
1343 
1344  template <int spacedim>
1345  template <int dim>
1346  void
1348  const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell)
1349  {
1350  // see if we had previously already stored a cell that has the same
1351  // data type; if so, reuse the memory location and avoid calling 'new'
1352  // inside boost::any
1353  if (typename DoFHandler<dim, spacedim>::cell_iterator *storage_location =
1354  boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1355  &cell))
1356  *storage_location = new_cell;
1357  else
1358  // if we had nothing stored before, or if we had stored a different
1359  // data type, just let boost::any replace things
1360  cell = new_cell;
1361 
1362  // Also reset the face number, just to make sure nobody
1363  // accidentally uses an outdated value.
1364  face_number = numbers::invalid_unsigned_int;
1365  }
1366 
1367 
1368 
1369  template <int spacedim>
1370  template <int dim>
1371  void
1373  const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell,
1374  const unsigned int new_face_number)
1375  {
1376  set_cell<dim>(new_cell);
1377  face_number = new_face_number;
1378  }
1379 
1380 
1381 
1382  template <int spacedim>
1383  template <typename DoFHandlerType>
1384  typename DoFHandlerType::cell_iterator
1386  {
1387  return get_cell<DoFHandlerType::dimension>();
1388  }
1389 
1390 
1391 
1392  template <int spacedim>
1393  template <int dim>
1396  {
1397  Assert(cell.empty() == false,
1398  ExcMessage(
1399  "You are trying to access the cell associated with a "
1400  "DataPostprocessorInputs::Scalar object for which no cell has "
1401  "been set."));
1402  Assert((boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1403  &cell) != nullptr),
1404  ExcMessage(
1405  "You are trying to access the cell associated with a "
1406  "DataPostprocessorInputs::Scalar with a DoFHandler type that is "
1407  "different from the type with which it has been set. For example, "
1408  "if the cell for which output is currently being generated "
1409  "belongs to a DoFHandler<2, 3> object, then you can only call the "
1410  "current function with a template argument equal to "
1411  "DoFHandler<2, 3>, but not with any other class type or dimension "
1412  "template argument."));
1413 
1414  return boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1415  cell);
1416  }
1417 } // namespace DataPostprocessorInputs
1418 
1419 #endif
1420 
1422 
1423 #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_DEPRECATED
Definition: config.h:164
#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(const typename DoFHandlerType::cell_iterator &cell)
void set_cell_and_face(const typename DoFHandler< dim, spacedim >::cell_iterator &cell, const unsigned int face_number)
std::vector< Point< spacedim > > evaluation_points
DoFHandlerType::cell_iterator get_cell() const
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