GridFormat 0.4.0
I/O-Library for grid-like data structures
Loading...
Searching...
No Matches
pvti_reader.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022-2023 Dennis Gläser <dennis.glaeser@iws.uni-stuttgart.de>
2// SPDX-License-Identifier: MIT
8#ifndef GRIDFORMAT_VTK_PVTI_READER_HPP_
9#define GRIDFORMAT_VTK_PVTI_READER_HPP_
10
13
14namespace GridFormat {
15
21class PVTIReader : public VTK::PXMLStructuredGridReader<VTIReader> {
23
24 public:
26 : ParentType("PImageData")
27 {}
28
29 explicit PVTIReader(const NullCommunicator&)
30 : ParentType("PImageData")
31 {}
32
33 template<Concepts::Communicator C>
34 explicit PVTIReader(const C& comm)
35 : ParentType("PImageData", comm)
36 {}
37
38 private:
39 std::string _name() const override {
40 return "PVTIReader";
41 }
42
43 std::vector<double> _ordinates(unsigned int direction) const override {
44 if (this->_num_process_pieces() == 0)
45 return {};
46 if (this->_num_process_pieces() == 1)
47 return this->_readers().front().ordinates(direction);
48
49 const auto extents = this->_specs().extents;
50 const auto extent_begin = this->_specs().extents[2*direction];
51 const auto origin = this->origin();
52 const auto spacing = this->spacing();
53 const std::size_t num_ordinates(extents[2*direction + 1] - extent_begin + 1);
54 std::vector<double> result(num_ordinates);
55 std::ranges::copy(
56 std::views::iota(std::size_t{0}, num_ordinates) | std::views::transform([&] (const std::size_t i) {
57 return origin[direction] + (extent_begin + i)*spacing[direction];
58 }),
59 result.begin()
60 );
61 return result;
62 }
63};
64
65} // namespace GridFormat
66
67#endif // GRIDFORMAT_VTK_PVTI_READER_HPP_
std::array< std::size_t, 3 > extents() const
Return the extents of the grid (only available for structured grid formats)
Definition: reader.hpp:113
Vector origin() const
Return the origin of the grid (only available for image grid formats)
Definition: reader.hpp:140
Vector spacing() const
Return the spacing of the grid (only available for image grid formats)
Definition: reader.hpp:135
Reader for .pvtp file format.
Definition: pvti_reader.hpp:21
Base class for readers of parallel vtk-xml file formats for structured grids.
Definition: pxml_reader.hpp:294