deal.II version GIT relicensing-6809-ge913b9bb34 2026-09-25 17:20: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\}}\)
Loading...
Searching...
No Matches
data_postprocessor.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2007 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_data_postprocessor_h
14#define dealii_data_postprocessor_h
15
16
17
18#include <deal.II/base/config.h>
19
21
23
25
27
28#include <any>
29#include <string>
30#include <vector>
31
33
34
40{
184 template <int spacedim>
186 {
190 CommonInputs();
191
208 std::vector<Tensor<1, spacedim>> normals;
209
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 std::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
575template <int dim>
577{
578public:
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
673 virtual UpdateFlags
675};
676
677
678
708template <int dim>
710{
711public:
735 DataPostprocessorScalar(const std::string &name,
737
743 virtual std::vector<std::string>
744 get_names() const override;
745
753 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
754 get_data_component_interpretation() const override;
755
761 virtual UpdateFlags
762 get_needed_update_flags() const override;
763
764private:
768 const std::string name;
770};
771
772
773
970template <int dim>
972{
973public:
997 DataPostprocessorVector(const std::string &name,
999
1005 virtual std::vector<std::string>
1006 get_names() const override;
1007
1015 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1016 get_data_component_interpretation() const override;
1017
1023 virtual UpdateFlags
1024 get_needed_update_flags() const override;
1025
1026private:
1030 const std::string name;
1032};
1033
1034
1035
1241template <int dim>
1243{
1244public:
1268 DataPostprocessorTensor(const std::string &name,
1270
1276 virtual std::vector<std::string>
1277 get_names() const override;
1278
1286 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1287 get_data_component_interpretation() const override;
1288
1294 virtual UpdateFlags
1295 get_needed_update_flags() const override;
1296
1297private:
1301 const std::string name;
1303};
1304
1305
1306
1314{
1336 template <int dim>
1338 {
1339 public:
1343 BoundaryIds();
1344
1349 virtual void
1352 std::vector<Vector<double>> &computed_quantities) const override;
1353 };
1354} // namespace DataPostprocessors
1355
1356
1357
1358#ifndef DOXYGEN
1359// -------------------- template functions ----------------------
1360
1362{
1363 template <int spacedim>
1364 template <int dim>
1365 void
1367 const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell)
1368 {
1369 // see if we had previously already stored a cell that has the same
1370 // data type; if so, reuse the memory location and avoid calling 'new'
1371 // inside std::any
1372 if (typename DoFHandler<dim, spacedim>::cell_iterator *storage_location =
1373 std::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1374 &cell))
1375 *storage_location = new_cell;
1376 else
1377 // if we had nothing stored before, or if we had stored a different
1378 // data type, just let std::any replace things
1379 cell = new_cell;
1380
1381 // Also reset the face number, just to make sure nobody
1382 // accidentally uses an outdated value.
1383 face_number = numbers::invalid_unsigned_int;
1384 }
1385
1386
1387
1388 template <int spacedim>
1389 template <int dim>
1390 void
1392 const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell,
1393 const unsigned int new_face_number)
1394 {
1395 set_cell<dim>(new_cell);
1396 face_number = new_face_number;
1397 }
1398
1399
1400
1401 template <int spacedim>
1402 template <int dim>
1405 {
1406 Assert(cell.has_value(),
1407 ExcMessage(
1408 "You are trying to access the cell associated with a "
1409 "DataPostprocessorInputs::Scalar object for which no cell has "
1410 "been set."));
1411 Assert((std::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1412 &cell) != nullptr),
1413 ExcMessage(
1414 "You are trying to access the cell associated with a "
1415 "DataPostprocessorInputs::Scalar with a DoFHandler type that is "
1416 "different from the type with which it has been set. For example, "
1417 "if the cell for which output is currently being generated "
1418 "belongs to a DoFHandler<2, 3> object, then you can only call the "
1419 "current function with a template argument equal to "
1420 "DoFHandler<2, 3>, but not with any other class type or dimension "
1421 "template argument."));
1422
1423 return std::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1424 cell);
1425 }
1426} // namespace DataPostprocessorInputs
1427
1428#endif
1429
1431
1432#endif
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
virtual std::vector< std::string > get_names() const override
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
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
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
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &inputs, std::vector< Vector< double > > &computed_quantities) const override
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define Assert(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
typename ActiveSelector::cell_iterator cell_iterator
UpdateFlags
constexpr unsigned int invalid_unsigned_int
Definition types.h:228
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