TensorData.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <iosfwd>
8 #include <string>
9 #include <utility>
10 #include <vector>
11 
12 #include "DataStructures/DataVector.hpp"
13 
14 /// \cond
15 namespace PUP {
16 class er;
17 } // namespace PUP
18 /// \endcond
19 
20 /*!
21  * \ingroup DataStructuresGroup
22  * \brief An untyped tensor component with a name for observation.
23  *
24  * The name should be a path inside an H5 file, typically starting with the name
25  * of the volume subfile. For example,
26  * `element_volume_data.vol/ObservationId[ID]/[ElementIdName]/psi_xx`.
27  */
29  TensorComponent() = default;
31  : name(std::move(n)), data(std::move(d)) {}
32  void pup(PUP::er& p) noexcept; // NOLINT
33  std::string name{};
34  DataVector data{};
35 };
36 
37 std::ostream& operator<<(std::ostream& os, const TensorComponent& t) noexcept;
38 
39 bool operator==(const TensorComponent& lhs,
40  const TensorComponent& rhs) noexcept;
41 
42 bool operator!=(const TensorComponent& lhs,
43  const TensorComponent& rhs) noexcept;
44 
45 /*!
46  * \ingroup DataStructuresGroup
47  * \brief Holds the extents of the mesh and the tensor components on the mesh.
48  *
49  * The extents is a `std::vector<size_t>` where each element is the number of
50  * grid points in the given dimension. The `TensorComponent`s must live on the
51  * grid of the size of the extents. We use runtime extents instead of the
52  * `Index` class because observers may write 1D, 2D, or 3D data in a 3D
53  * simulation.
54  */
56  ExtentsAndTensorVolumeData() = default;
58  std::vector<TensorComponent> components) noexcept
59  : extents(std::move(exts)), tensor_components(std::move(components)) {}
60  void pup(PUP::er& p) noexcept; // NOLINT
61  std::vector<size_t> extents{};
62  std::vector<TensorComponent> tensor_components{};
63 };
Definition: Strahlkorper.hpp:14
An untyped tensor component with a name for observation.
Definition: TensorData.hpp:28
Stores a collection of function values.
Definition: DataVector.hpp:46
Holds the extents of the mesh and the tensor components on the mesh.
Definition: TensorData.hpp:55