Reference documentation for deal.II version GIT 3a483e2de5 2022-11-28 08:40:02+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 
1202 template <int dim>
1204 {
1205 public:
1221  DataPostprocessorTensor(const std::string &name,
1222  const UpdateFlags update_flags);
1223 
1229  virtual std::vector<std::string>
1230  get_names() const override;
1231 
1239  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1240  get_data_component_interpretation() const override;
1241 
1247  virtual UpdateFlags
1248  get_needed_update_flags() const override;
1249 
1250 private:
1254  const std::string name;
1256 };
1257 
1258 
1259 
1267 {
1289  template <int dim>
1291  {
1292  public:
1296  BoundaryIds();
1297 
1302  virtual void
1305  std::vector<Vector<double>> &computed_quantities) const override;
1306  };
1307 } // namespace DataPostprocessors
1308 
1309 
1310 
1311 #ifndef DOXYGEN
1312 // -------------------- template functions ----------------------
1313 
1314 namespace DataPostprocessorInputs
1315 {
1316  template <int spacedim>
1317  template <int dim>
1318  void
1320  const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell)
1321  {
1322  // see if we had previously already stored a cell that has the same
1323  // data type; if so, reuse the memory location and avoid calling 'new'
1324  // inside boost::any
1325  if (typename DoFHandler<dim, spacedim>::cell_iterator *storage_location =
1326  boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1327  &cell))
1328  *storage_location = new_cell;
1329  else
1330  // if we had nothing stored before, or if we had stored a different
1331  // data type, just let boost::any replace things
1332  cell = new_cell;
1333 
1334  // Also reset the face number, just to make sure nobody
1335  // accidentally uses an outdated value.
1336  face_number = numbers::invalid_unsigned_int;
1337  }
1338 
1339 
1340 
1341  template <int spacedim>
1342  template <int dim>
1343  void
1345  const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell,
1346  const unsigned int new_face_number)
1347  {
1348  set_cell<dim>(new_cell);
1349  face_number = new_face_number;
1350  }
1351 
1352 
1353 
1354  template <int spacedim>
1355  template <int dim>
1358  {
1359  Assert(cell.empty() == false,
1360  ExcMessage(
1361  "You are trying to access the cell associated with a "
1362  "DataPostprocessorInputs::Scalar object for which no cell has "
1363  "been set."));
1364  Assert((boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1365  &cell) != nullptr),
1366  ExcMessage(
1367  "You are trying to access the cell associated with a "
1368  "DataPostprocessorInputs::Scalar with a DoFHandler type that is "
1369  "different from the type with which it has been set. For example, "
1370  "if the cell for which output is currently being generated "
1371  "belongs to a DoFHandler<2, 3> object, then you can only call the "
1372  "current function with a template argument equal to "
1373  "DoFHandler<2, 3>, but not with any other class type or dimension "
1374  "template argument."));
1375 
1376  return boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1377  cell);
1378  }
1379 } // namespace DataPostprocessorInputs
1380 
1381 #endif
1382 
1384 
1385 #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:458
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:459
#define Assert(cond, exc)
Definition: exceptions.h:1501
static ::ExceptionBase & ExcMessage(std::string arg1)
UpdateFlags
static const unsigned int invalid_unsigned_int
Definition: types.h:206
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