Reference documentation for deal.II version GIT 0980a66d4b 2023-03-23 20:20:03+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 
238  std::vector<Point<spacedim>> evaluation_points;
239 
248  template <int dim>
249  void
251 
262  template <int dim>
263  void
266  const unsigned int face_number);
267 
273  template <int dim>
275  get_cell() const;
276 
286  unsigned int
287  get_face_number() const;
288 
289  private:
297  boost::any cell;
298 
303  unsigned int face_number;
304  };
305 
322  template <int spacedim>
323  struct Scalar : public CommonInputs<spacedim>
324  {
330  std::vector<double> solution_values;
331 
345  std::vector<Tensor<1, spacedim>> solution_gradients;
346 
360  std::vector<Tensor<2, spacedim>> solution_hessians;
361  };
362 
363 
364 
400  template <int spacedim>
401  struct Vector : public CommonInputs<spacedim>
402  {
412  std::vector<::Vector<double>> solution_values;
413 
431  std::vector<std::vector<Tensor<1, spacedim>>> solution_gradients;
432 
450  std::vector<std::vector<Tensor<2, spacedim>>> solution_hessians;
451  };
452 
453 } // namespace DataPostprocessorInputs
454 
455 
583 template <int dim>
585 {
586 public:
592  virtual ~DataPostprocessor() override = default;
593 
613  virtual void
615  std::vector<Vector<double>> &computed_quantities) const;
616 
627  virtual void
629  std::vector<Vector<double>> &computed_quantities) const;
630 
635  virtual std::vector<std::string>
636  get_names() const = 0;
637 
660  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
662 
681  virtual UpdateFlags
683 };
684 
685 
686 
716 template <int dim>
718 {
719 public:
743  DataPostprocessorScalar(const std::string &name,
744  const UpdateFlags update_flags);
745 
751  virtual std::vector<std::string>
752  get_names() const override;
753 
761  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
762  get_data_component_interpretation() const override;
763 
769  virtual UpdateFlags
770  get_needed_update_flags() const override;
771 
772 private:
776  const std::string name;
778 };
779 
780 
781 
978 template <int dim>
980 {
981 public:
1005  DataPostprocessorVector(const std::string &name,
1006  const UpdateFlags update_flags);
1007 
1013  virtual std::vector<std::string>
1014  get_names() const override;
1015 
1023  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1024  get_data_component_interpretation() const override;
1025 
1031  virtual UpdateFlags
1032  get_needed_update_flags() const override;
1033 
1034 private:
1038  const std::string name;
1040 };
1041 
1042 
1043 
1244 template <int dim>
1246 {
1247 public:
1271  DataPostprocessorTensor(const std::string &name,
1272  const UpdateFlags update_flags);
1273 
1279  virtual std::vector<std::string>
1280  get_names() const override;
1281 
1289  virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1290  get_data_component_interpretation() const override;
1291 
1297  virtual UpdateFlags
1298  get_needed_update_flags() const override;
1299 
1300 private:
1304  const std::string name;
1306 };
1307 
1308 
1309 
1317 {
1339  template <int dim>
1341  {
1342  public:
1346  BoundaryIds();
1347 
1352  virtual void
1355  std::vector<Vector<double>> &computed_quantities) const override;
1356  };
1357 } // namespace DataPostprocessors
1358 
1359 
1360 
1361 #ifndef DOXYGEN
1362 // -------------------- template functions ----------------------
1363 
1364 namespace DataPostprocessorInputs
1365 {
1366  template <int spacedim>
1367  template <int dim>
1368  void
1370  const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell)
1371  {
1372  // see if we had previously already stored a cell that has the same
1373  // data type; if so, reuse the memory location and avoid calling 'new'
1374  // inside boost::any
1375  if (typename DoFHandler<dim, spacedim>::cell_iterator *storage_location =
1376  boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1377  &cell))
1378  *storage_location = new_cell;
1379  else
1380  // if we had nothing stored before, or if we had stored a different
1381  // data type, just let boost::any replace things
1382  cell = new_cell;
1383 
1384  // Also reset the face number, just to make sure nobody
1385  // accidentally uses an outdated value.
1386  face_number = numbers::invalid_unsigned_int;
1387  }
1388 
1389 
1390 
1391  template <int spacedim>
1392  template <int dim>
1393  void
1395  const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell,
1396  const unsigned int new_face_number)
1397  {
1398  set_cell<dim>(new_cell);
1399  face_number = new_face_number;
1400  }
1401 
1402 
1403 
1404  template <int spacedim>
1405  template <int dim>
1408  {
1409  Assert(cell.empty() == false,
1410  ExcMessage(
1411  "You are trying to access the cell associated with a "
1412  "DataPostprocessorInputs::Scalar object for which no cell has "
1413  "been set."));
1414  Assert((boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1415  &cell) != nullptr),
1416  ExcMessage(
1417  "You are trying to access the cell associated with a "
1418  "DataPostprocessorInputs::Scalar with a DoFHandler type that is "
1419  "different from the type with which it has been set. For example, "
1420  "if the cell for which output is currently being generated "
1421  "belongs to a DoFHandler<2, 3> object, then you can only call the "
1422  "current function with a template argument equal to "
1423  "DoFHandler<2, 3>, but not with any other class type or dimension "
1424  "template argument."));
1425 
1426  return boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1427  cell);
1428  }
1429 } // namespace DataPostprocessorInputs
1430 
1431 #endif
1432 
1434 
1435 #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:474
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:475
#define Assert(cond, exc)
Definition: exceptions.h:1586
static ::ExceptionBase & ExcMessage(std::string arg1)
UpdateFlags
static const unsigned int invalid_unsigned_int
Definition: types.h:213
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