Reference documentation for deal.II version 9.3.3
\(\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
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{
148 template <int spacedim>
150 {
167 std::vector<Tensor<1, spacedim>> normals;
168
181 std::vector<Point<spacedim>> evaluation_points;
182
191 template <int dim>
192 void
194
206 template <typename DoFHandlerType>
208 set_cell(const typename DoFHandlerType::cell_iterator &cell);
209
215 template <int dim>
217 get_cell() const;
218
227 template <typename DoFHandlerType>
228 DEAL_II_DEPRECATED typename DoFHandlerType::cell_iterator
229 get_cell() const;
230
231 private:
239 boost::any cell;
240 };
241
258 template <int spacedim>
259 struct Scalar : public CommonInputs<spacedim>
260 {
266 std::vector<double> solution_values;
267
281 std::vector<Tensor<1, spacedim>> solution_gradients;
282
296 std::vector<Tensor<2, spacedim>> solution_hessians;
297 };
298
299
300
336 template <int spacedim>
337 struct Vector : public CommonInputs<spacedim>
338 {
348 std::vector<::Vector<double>> solution_values;
349
367 std::vector<std::vector<Tensor<1, spacedim>>> solution_gradients;
368
386 std::vector<std::vector<Tensor<2, spacedim>>> solution_hessians;
387 };
388
389} // namespace DataPostprocessorInputs
390
391
519template <int dim>
521{
522public:
528 virtual ~DataPostprocessor() override = default;
529
549 virtual void
551 std::vector<Vector<double>> &computed_quantities) const;
552
563 virtual void
565 std::vector<Vector<double>> &computed_quantities) const;
566
571 virtual std::vector<std::string>
572 get_names() const = 0;
573
596 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
598
609 virtual UpdateFlags
611};
612
613
614
644template <int dim>
646{
647public:
663 DataPostprocessorScalar(const std::string &name,
665
671 virtual std::vector<std::string>
672 get_names() const override;
673
681 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
682 get_data_component_interpretation() const override;
683
689 virtual UpdateFlags
690 get_needed_update_flags() const override;
691
692private:
696 const std::string name;
698};
699
700
701
888template <int dim>
890{
891public:
907 DataPostprocessorVector(const std::string &name,
909
915 virtual std::vector<std::string>
916 get_names() const override;
917
925 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
926 get_data_component_interpretation() const override;
927
933 virtual UpdateFlags
934 get_needed_update_flags() const override;
935
936private:
940 const std::string name;
942};
943
944
945
1136template <int dim>
1138{
1139public:
1155 DataPostprocessorTensor(const std::string &name,
1157
1163 virtual std::vector<std::string>
1164 get_names() const override;
1165
1173 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1174 get_data_component_interpretation() const override;
1175
1181 virtual UpdateFlags
1182 get_needed_update_flags() const override;
1183
1184private:
1188 const std::string name;
1190};
1191
1192
1193
1194#ifndef DOXYGEN
1195// -------------------- template functions ----------------------
1196
1198{
1199 template <int spacedim>
1200 template <typename DoFHandlerType>
1201 void
1203 const typename DoFHandlerType::cell_iterator &new_cell)
1204 {
1205 return set_cell<DoFHandlerType::dimension>(new_cell);
1206 }
1207
1208
1209
1210 template <int spacedim>
1211 template <int dim>
1212 void
1214 const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell)
1215 {
1216 // see if we had previously already stored a cell that has the same
1217 // data type; if so, reuse the memory location and avoid calling 'new'
1218 // inside boost::any
1219 if (typename DoFHandler<dim, spacedim>::cell_iterator *storage_location =
1220 boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1221 &cell))
1222 *storage_location = new_cell;
1223 else
1224 // if we had nothing stored before, or if we had stored a different
1225 // data type, just let boost::any replace things
1226 cell = new_cell;
1227 }
1228
1229
1230
1231 template <int spacedim>
1232 template <typename DoFHandlerType>
1233 typename DoFHandlerType::cell_iterator
1235 {
1236 return get_cell<DoFHandlerType::dimension>();
1237 }
1238
1239
1240
1241 template <int spacedim>
1242 template <int dim>
1245 {
1246 Assert(cell.empty() == false,
1247 ExcMessage(
1248 "You are trying to access the cell associated with a "
1249 "DataPostprocessorInputs::Scalar object for which no cell has "
1250 "been set."));
1251 Assert((boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1252 &cell) != nullptr),
1253 ExcMessage(
1254 "You are trying to access the cell associated with a "
1255 "DataPostprocessorInputs::Scalar with a DoFHandler type that is "
1256 "different from the type with which it has been set. For example, "
1257 "if the cell for which output is currently being generated "
1258 "belongs to a DoFHandler<2, 3> object, then you can only call the "
1259 "current function with a template argument equal to "
1260 "DoFHandler<2, 3>, but not with any other class type or dimension "
1261 "template argument."));
1262
1263 return boost::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1264 cell);
1265 }
1266} // namespace DataPostprocessorInputs
1267
1268#endif
1269
1271
1272#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 ~DataPostprocessor() override=default
virtual UpdateFlags get_needed_update_flags() const =0
virtual void evaluate_vector_field(const DataPostprocessorInputs::Vector< dim > &input_data, std::vector< Vector< double > > &computed_quantities) const
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &input_data, std::vector< Vector< double > > &computed_quantities) const
virtual std::vector< std::string > get_names() const =0
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const
Definition: vector.h:110
#define DEAL_II_DEPRECATED
Definition: config.h:162
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
UpdateFlags
#define Assert(cond, exc)
Definition: exceptions.h:1465
static ::ExceptionBase & ExcMessage(std::string arg1)
DoFHandler< dim, spacedim >::cell_iterator get_cell() const
std::vector< Tensor< 1, spacedim > > normals
void set_cell(const typename DoFHandlerType::cell_iterator &cell)
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