deal.II version GIT relicensing-2289-g1e5549a87a 2024-12-21 21:30:00+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: LGPL-2.1-or-later
4// Copyright (C) 2007 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_data_postprocessor_h
16#define dealii_data_postprocessor_h
17
18
19
20#include <deal.II/base/config.h>
21
23#include <deal.II/base/point.h>
24#include <deal.II/base/tensor.h>
25
27
29
30#include <deal.II/lac/vector.h>
31
33
34#include <any>
35#include <string>
36#include <vector>
37
39
40
46{
190 template <int spacedim>
192 {
196 CommonInputs();
197
214 std::vector<Tensor<1, spacedim>> normals;
215
236 std::vector<Point<spacedim>> evaluation_points;
237
246 template <int dim>
247 void
249
260 template <int dim>
261 void
264 const unsigned int face_number);
265
271 template <int dim>
273 get_cell() const;
274
284 unsigned int
285 get_face_number() const;
286
287 private:
295 std::any cell;
296
301 unsigned int face_number;
302 };
303
320 template <int spacedim>
321 struct Scalar : public CommonInputs<spacedim>
322 {
328 std::vector<double> solution_values;
329
343 std::vector<Tensor<1, spacedim>> solution_gradients;
344
358 std::vector<Tensor<2, spacedim>> solution_hessians;
359 };
360
361
362
398 template <int spacedim>
399 struct Vector : public CommonInputs<spacedim>
400 {
410 std::vector<::Vector<double>> solution_values;
411
429 std::vector<std::vector<Tensor<1, spacedim>>> solution_gradients;
430
448 std::vector<std::vector<Tensor<2, spacedim>>> solution_hessians;
449 };
450
451} // namespace DataPostprocessorInputs
452
453
581template <int dim>
583{
584public:
590 virtual ~DataPostprocessor() override = default;
591
611 virtual void
613 std::vector<Vector<double>> &computed_quantities) const;
614
625 virtual void
627 std::vector<Vector<double>> &computed_quantities) const;
628
633 virtual std::vector<std::string>
634 get_names() const = 0;
635
658 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
660
679 virtual UpdateFlags
681};
682
683
684
714template <int dim>
716{
717public:
741 DataPostprocessorScalar(const std::string &name,
743
749 virtual std::vector<std::string>
750 get_names() const override;
751
759 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
760 get_data_component_interpretation() const override;
761
767 virtual UpdateFlags
768 get_needed_update_flags() const override;
769
770private:
774 const std::string name;
776};
777
778
779
976template <int dim>
978{
979public:
1003 DataPostprocessorVector(const std::string &name,
1005
1011 virtual std::vector<std::string>
1012 get_names() const override;
1013
1021 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1022 get_data_component_interpretation() const override;
1023
1029 virtual UpdateFlags
1030 get_needed_update_flags() const override;
1031
1032private:
1036 const std::string name;
1038};
1039
1040
1041
1242template <int dim>
1244{
1245public:
1269 DataPostprocessorTensor(const std::string &name,
1271
1277 virtual std::vector<std::string>
1278 get_names() const override;
1279
1287 virtual std::vector<DataComponentInterpretation::DataComponentInterpretation>
1288 get_data_component_interpretation() const override;
1289
1295 virtual UpdateFlags
1296 get_needed_update_flags() const override;
1297
1298private:
1302 const std::string name;
1304};
1305
1306
1307
1315{
1337 template <int dim>
1339 {
1340 public:
1344 BoundaryIds();
1345
1350 virtual void
1353 std::vector<Vector<double>> &computed_quantities) const override;
1354 };
1355} // namespace DataPostprocessors
1356
1357
1358
1359#ifndef DOXYGEN
1360// -------------------- template functions ----------------------
1361
1363{
1364 template <int spacedim>
1365 template <int dim>
1366 void
1368 const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell)
1369 {
1370 // see if we had previously already stored a cell that has the same
1371 // data type; if so, reuse the memory location and avoid calling 'new'
1372 // inside std::any
1373 if (typename DoFHandler<dim, spacedim>::cell_iterator *storage_location =
1374 std::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1375 &cell))
1376 *storage_location = new_cell;
1377 else
1378 // if we had nothing stored before, or if we had stored a different
1379 // data type, just let std::any replace things
1380 cell = new_cell;
1381
1382 // Also reset the face number, just to make sure nobody
1383 // accidentally uses an outdated value.
1384 face_number = numbers::invalid_unsigned_int;
1385 }
1386
1387
1388
1389 template <int spacedim>
1390 template <int dim>
1391 void
1393 const typename DoFHandler<dim, spacedim>::cell_iterator &new_cell,
1394 const unsigned int new_face_number)
1395 {
1396 set_cell<dim>(new_cell);
1397 face_number = new_face_number;
1398 }
1399
1400
1401
1402 template <int spacedim>
1403 template <int dim>
1406 {
1407 Assert(cell.has_value(),
1408 ExcMessage(
1409 "You are trying to access the cell associated with a "
1410 "DataPostprocessorInputs::Scalar object for which no cell has "
1411 "been set."));
1412 Assert((std::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1413 &cell) != nullptr),
1414 ExcMessage(
1415 "You are trying to access the cell associated with a "
1416 "DataPostprocessorInputs::Scalar with a DoFHandler type that is "
1417 "different from the type with which it has been set. For example, "
1418 "if the cell for which output is currently being generated "
1419 "belongs to a DoFHandler<2, 3> object, then you can only call the "
1420 "current function with a template argument equal to "
1421 "DoFHandler<2, 3>, but not with any other class type or dimension "
1422 "template argument."));
1423
1424 return std::any_cast<typename DoFHandler<dim, spacedim>::cell_iterator>(
1425 cell);
1426 }
1427} // namespace DataPostprocessorInputs
1428
1429#endif
1430
1432
1433#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:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
#define Assert(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
typename ActiveSelector::cell_iterator cell_iterator
UpdateFlags
static const unsigned int invalid_unsigned_int
Definition types.h:220
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