GCC Code Coverage Report


Directory: gridformat/
File: gridformat/vtk/hdf_image_grid_reader.hpp
Date: 2026-10-12 17:50:57
Exec Total Coverage
Lines: 154 171 90.1%
Functions: 31 53 58.5%
Branches: 160 373 42.9%

Line Branch Exec Source
1 // SPDX-FileCopyrightText: 2022-2023 Dennis Gläser <dennis.glaeser@iws.uni-stuttgart.de>
2 // SPDX-License-Identifier: MIT
3 /*!
4 * \file
5 * \ingroup VTK
6 * \brief Reader for the VTK HDF file format for image grids.
7 */
8 #ifndef GRIDFORMAT_VTK_HDF_IMAGE_GRID_READER_HPP_
9 #define GRIDFORMAT_VTK_HDF_IMAGE_GRID_READER_HPP_
10 #if GRIDFORMAT_HAVE_HIGH_FIVE
11
12 #include <iterator>
13 #include <optional>
14 #include <algorithm>
15 #include <functional>
16 #include <concepts>
17 #include <numeric>
18 #include <utility>
19 #include <ranges>
20
21 #include <gridformat/common/field.hpp>
22 #include <gridformat/common/range_field.hpp>
23 #include <gridformat/common/field_transformations.hpp>
24 #include <gridformat/common/exceptions.hpp>
25 #include <gridformat/common/lazy_field.hpp>
26 #include <gridformat/common/ranges.hpp>
27
28 #include <gridformat/grid/reader.hpp>
29 #include <gridformat/parallel/concepts.hpp>
30 #include <gridformat/vtk/common.hpp>
31 #include <gridformat/vtk/hdf_common.hpp>
32
33 namespace GridFormat {
34
35 /*!
36 * \ingroup VTK
37 * \brief Reader for the VTK-HDF file format for image grids.
38 */
39 class VTKHDFImageGridReader : public GridReader {
40 using Communicator = NullCommunicator;
41 using HDF5File = HDF5::File<Communicator>;
42 static constexpr std::size_t vtk_space_dim = 3;
43
44 public:
45 88 explicit VTKHDFImageGridReader() = default;
46
47 template<Concepts::Communicator C>
48 explicit VTKHDFImageGridReader(C&&) {
49 static_assert(
50 std::is_same_v<std::remove_cvref_t<C>, NullCommunicator>,
51 "Cannot read vtk-hdf image grid files in parallel"
52 );
53 }
54
55 private:
56 2 std::string _name() const override {
57
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (_is_transient())
58 ✗ return "VTKHDFImageGridReader (transient)";
59
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
4 return "VTKHDFImageGridReader";
60 }
61
62 89 void _open(const std::string& filename, typename GridReader::FieldNames& field_names) override {
63
2/4
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 89 times.
✗ Branch 5 not taken.
89 _file = HDF5File{filename, _comm, HDF5File::read_only};
64
65
2/4
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 89 times.
✗ Branch 5 not taken.
89 const auto type = VTKHDF::get_file_type(_file.value());
66
3/4
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 35 times.
89 if (type != "ImageData")
67
3/6
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 54 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 54 times.
✗ Branch 10 not taken.
54 throw ValueError("Incompatible VTK-HDF type: '" + type + "', expected 'ImageData'.");
68
69
2/4
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
35 VTKHDF::check_version_compatibility(_file.value(), {2, 0});
70
71
4/6
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 17 times.
105 if (_file->exists("/VTKHDF/Steps"))
72
2/4
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
90 _file->visit_attribute("/VTKHDF/Steps/NSteps", [&] (auto&& field) {
73 36 _num_steps.emplace();
74 36 field.export_to(_num_steps.value());
75 36 _step_index.emplace(0);
76 36 });
77
78 105 const auto copy_names_in = [&] (const std::string& group, auto& storage) {
79
2/2
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 12 times.
105 if (_file->exists(group))
80
2/4
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 93 times.
✗ Branch 7 not taken.
93 std::ranges::copy(_file->dataset_names_in(group), std::back_inserter(storage));
81 105 };
82
2/4
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
70 copy_names_in("VTKHDF/CellData", field_names.cell_fields);
83
2/4
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
70 copy_names_in("VTKHDF/PointData", field_names.point_fields);
84
2/4
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
70 copy_names_in("VTKHDF/FieldData", field_names.meta_data_fields);
85
86
3/6
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 35 times.
✗ Branch 8 not taken.
70 auto spacing = _file.value().template read_attribute_to<std::vector<double>>("/VTKHDF/Spacing");
87
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
35 if (spacing.size() != vtk_space_dim)
88 ✗ throw SizeError("Unexpected spacing vector read (size = " + as_string(spacing.size()) + ")");
89
1/2
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
35 _cell_spacing = Ranges::to_array<vtk_space_dim>(spacing);
90
91
1/2
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
70 auto direction = std::vector<double>{1., 0., 0., 0., 1., 0., 0., 0., 1.};
92
3/6
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 35 times.
✗ Branch 9 not taken.
105 if (_file->has_attribute_at("/VTKHDF/Direction"))
93
2/4
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
105 direction = _file->template read_attribute_to<std::vector<double>>("/VTKHDF/Direction");
94
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
35 if (direction.size() != 9)
95 ✗ throw SizeError("Unexpected direction vector read (size = " + as_string(direction.size()) + ")");
96
1/2
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
35 _direction = Ranges::to_array<9>(direction);
97
98
1/2
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
70 auto origin = std::vector<double>{0., 0., 0.};
99
3/6
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 35 times.
✗ Branch 9 not taken.
105 if (_file->has_attribute_at("/VTKHDF/Origin"))
100
2/4
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
105 origin = _file->template read_attribute_to<std::vector<double>>("/VTKHDF/Origin");
101
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
35 if (origin.size() != vtk_space_dim)
102 ✗ throw SizeError("Unexpected origin read (size = " + as_string(origin.size()) + ")");
103
1/2
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
35 _point_origin = Ranges::to_array<vtk_space_dim>(origin);
104
105
3/6
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 35 times.
✗ Branch 8 not taken.
70 auto extents = _file.value().template read_attribute_to<std::vector<std::size_t>>("/VTKHDF/WholeExtent");
106
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
35 if (extents.size() != 6)
107 ✗ throw SizeError("Unexpected 'WholeExtents' attribute (size = " + as_string(extents.size()) + ").");
108 35 _piece_location.lower_left = {extents[0], extents[2], extents[4]};
109 35 _piece_location.upper_right = {extents[1], extents[3], extents[5]};
110 89 }
111
112 ✗ void _close() override {
113 ✗ _file = {};
114 ✗ _piece_location = {};
115 ✗ _cell_spacing = {};
116 ✗ _point_origin = {};
117 ✗ _direction = {};
118 ✗ }
119
120 5 typename GridReader::PieceLocation _location() const override {
121 5 return _piece_location;
122 }
123
124 4 typename GridReader::Vector _spacing() const override {
125 4 return _cell_spacing;
126 }
127
128 2 typename GridReader::Vector _origin() const override {
129 2 return _point_origin;
130 }
131
132 1254 std::size_t _number_of_cells() const override {
133 1254 const auto counts = _get_extents();
134
2/4
✓ Branch 1 taken 1254 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1254 times.
✗ Branch 5 not taken.
5016 auto actives = counts | std::views::filter([] (auto e) { return e != 0; });
135
3/6
✓ Branch 1 taken 1254 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1254 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1254 times.
✗ Branch 8 not taken.
1254 return std::accumulate(
136 std::ranges::begin(actives),
137 std::ranges::end(actives),
138 std::size_t{1},
139 std::multiplies{}
140 2508 );
141 }
142
143 1411 std::size_t _number_of_points() const override {
144
1/2
✓ Branch 2 taken 1411 times.
✗ Branch 3 not taken.
1411 auto counts = Ranges::incremented(_get_extents(), 1);
145 1411 return std::accumulate(
146 std::ranges::begin(counts),
147 std::ranges::end(counts),
148 std::size_t{1},
149 std::multiplies{}
150 2822 );
151 }
152
153 4 std::size_t _number_of_pieces() const override {
154 4 return 1;
155 }
156
157 187 void _visit_cells(const typename GridReader::CellVisitor& visitor) const override {
158
1/2
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
187 VTK::CommonDetail::visit_structured_cells(visitor, _make_vtk_extents_array());
159 187 }
160
161 67 FieldPtr _points() const override {
162 67 std::array<std::size_t, 6> extents = _make_vtk_extents_array();
163 67 extents[1] += 1;
164 67 extents[3] += 1;
165 67 extents[5] += 1;
166 67 return make_field_ptr(LazyField{
167 int{}, // dummy source
168
1/2
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
67 MDLayout{{VTK::CommonDetail::number_of_entities(extents), std::size_t{vtk_space_dim}}},
169 Precision<double>{},
170 ✗ [ex=extents, o=_point_origin, s=_cell_spacing, d=_direction] (const int&) {
171 67 return VTK::CommonDetail::serialize_structured_points(ex, o, s, d);
172 }
173
3/9
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 67 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 67 times.
✗ Branch 9 not taken.
201 });
174 }
175
176 25 bool _is_sequence() const override {
177 25 return _is_transient();
178 }
179
180 230 std::size_t _number_of_steps() const override {
181
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
230 if (!_num_steps.has_value())
182 ✗ throw ValueError("Read file is not a sequence");
183 230 return _num_steps.value();
184 }
185
186 75 double _time_at_step(std::size_t step_idx) const override {
187
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
75 if (step_idx >= _number_of_steps())
188 ✗ throw ValueError("Only " + as_string(_number_of_steps()) + " available");
189
4/12
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 75 times.
✗ Branch 6 not taken.
✓ Branch 10 taken 75 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 75 times.
✗ Branch 14 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
450 return _file.value().template read_dataset_to<double>("/VTKHDF/Steps/Values", HDF5::Slice{
190 .offset = {step_idx},
191 .count = {1}
192 150 });
193 }
194
195 104 void _set_step(std::size_t step_idx, typename GridReader::FieldNames&) override {
196
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
104 if (step_idx >= _number_of_steps())
197 ✗ throw ValueError("Only " + as_string(_number_of_steps()) + " available");
198 104 _step_index = step_idx;
199 104 }
200
201 1068 auto _serialization_callback(std::string path, std::size_t target_size) const {
202 1068 return [&, size=target_size, _step=_step_index, _p=std::move(path)] (const HDF5File& file) {
203
2/4
✓ Branch 1 taken 636 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 636 times.
✗ Branch 5 not taken.
636 auto count = file.get_dimensions(_p).value();
204
1/2
✓ Branch 1 taken 636 times.
✗ Branch 2 not taken.
636 auto offset = count;
205
1/2
✓ Branch 1 taken 636 times.
✗ Branch 2 not taken.
636 std::ranges::fill(offset, 0);
206
2/2
✓ Branch 1 taken 510 times.
✓ Branch 2 taken 126 times.
636 if (_step) {
207
1/2
✓ Branch 1 taken 510 times.
✗ Branch 2 not taken.
510 count.at(0) = 1;
208
2/4
✓ Branch 1 taken 510 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 510 times.
✗ Branch 5 not taken.
510 offset.at(0) = _step.value();
209 }
210 1908 return file.visit_dataset(_p, [&] <typename F> (F&& field) {
211
2/2
✓ Branch 1 taken 510 times.
✓ Branch 2 taken 126 times.
1272 const std::size_t step_offset = _step.has_value() ? 1 : 0;
212
1/2
✓ Branch 1 taken 636 times.
✗ Branch 2 not taken.
1272 const auto layout = field.layout();
213
4/6
✓ Branch 1 taken 636 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 636 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 408 times.
✓ Branch 7 taken 228 times.
1272 if (layout.dimension() == _grid_dimension() + step_offset)
214
3/6
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 408 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 408 times.
✗ Branch 9 not taken.
1632 return transform(make_field_ptr(std::move(field)), FieldTransformation::reshape_to(
215
1/2
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
1632 MDLayout{{size}}
216
1/2
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
816 ))->serialized();
217
3/6
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 228 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 228 times.
✗ Branch 7 not taken.
456 else if (layout.dimension() == _grid_dimension() + step_offset + 1)
218
3/6
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 228 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 228 times.
✗ Branch 9 not taken.
912 return transform(make_field_ptr(std::move(field)), FieldTransformation::reshape_to(
219
3/6
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 228 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 228 times.
✗ Branch 8 not taken.
456 MDLayout{{size, layout.extent(_grid_dimension() + step_offset)}}
220
1/2
✓ Branch 2 taken 228 times.
✗ Branch 3 not taken.
456 ))->serialized();
221 ✗ throw InvalidState("Unexpected field layout: " + as_string(layout));
222
3/10
✓ Branch 1 taken 636 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 636 times.
✗ Branch 5 not taken.
✓ Branch 9 taken 636 times.
✗ Branch 10 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
3180 }, HDF5::Slice{.offset = offset, .count = count});
223 1704 };
224 }
225
226 506 FieldPtr _cell_field(std::string_view name) const override {
227
2/4
✓ Branch 1 taken 506 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 506 times.
✗ Branch 5 not taken.
506 const std::string path = "VTKHDF/CellData/" + std::string{name};
228
1/2
✓ Branch 2 taken 506 times.
✗ Branch 3 not taken.
506 const auto num_components = _get_number_of_components(path);
229
3/4
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 170 times.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
506 const auto layout = num_components ? MDLayout{{_number_of_cells(), num_components.value()}}
230
4/8
✓ Branch 1 taken 336 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 336 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 170 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
506 : MDLayout{{_number_of_cells()}};
231 506 return make_field_ptr(VTKHDF::DataSetField{
232 _file.value(),
233 506 std::move(layout),
234
3/6
✓ Branch 1 taken 506 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 506 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 506 times.
✗ Branch 8 not taken.
506 _file.value().get_precision(path).value(),
235
1/2
✓ Branch 1 taken 506 times.
✗ Branch 2 not taken.
1012 _serialization_callback(path, _number_of_cells())
236
5/10
✓ Branch 1 taken 506 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 506 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 506 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 506 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 506 times.
✗ Branch 15 not taken.
2530 });
237 506 }
238
239 562 FieldPtr _point_field(std::string_view name) const override {
240
2/4
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 562 times.
✗ Branch 5 not taken.
562 const std::string path = "VTKHDF/PointData/" + std::string{name};
241
1/2
✓ Branch 2 taken 562 times.
✗ Branch 3 not taken.
562 const auto num_components = _get_number_of_components(path);
242
3/4
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 190 times.
✓ Branch 4 taken 372 times.
✗ Branch 5 not taken.
562 const auto layout = num_components ? MDLayout{{_number_of_points(), num_components.value()}}
243
4/8
✓ Branch 1 taken 372 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 372 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 190 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 190 times.
✗ Branch 11 not taken.
562 : MDLayout{{_number_of_points()}};
244 562 return make_field_ptr(VTKHDF::DataSetField{
245 _file.value(),
246 562 std::move(layout),
247
3/6
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 562 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 562 times.
✗ Branch 8 not taken.
562 _file.value().get_precision(path).value(),
248
1/2
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
1124 _serialization_callback(path, _number_of_points())
249
5/10
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 562 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 562 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 562 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 562 times.
✗ Branch 15 not taken.
2810 });
250 562 }
251
252 99 FieldPtr _meta_data_field(std::string_view name) const override {
253 return VTKHDF::read_field_data(
254 _file.value(),
255
1/2
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
297 std::string{name},
256 99 _is_transient() ? std::optional{_step_index.value()} : std::nullopt
257
4/6
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 14 times.
✓ Branch 6 taken 99 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 99 times.
✗ Branch 10 not taken.
297 );
258 }
259
260 254 std::array<std::size_t, 6> _make_vtk_extents_array() const {
261 std::array<std::size_t, 6> extents;
262 254 extents[0] = _piece_location.lower_left[0];
263 254 extents[2] = _piece_location.lower_left[1];
264 254 extents[4] = _piece_location.lower_left[2];
265 254 extents[1] = _piece_location.upper_right[0];
266 254 extents[3] = _piece_location.upper_right[1];
267 254 extents[5] = _piece_location.upper_right[2];
268 254 return extents;
269 }
270
271 1068 std::optional<std::size_t> _get_number_of_components(std::string_view path) const {
272
4/8
✓ Branch 1 taken 1068 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1068 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1068 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1068 times.
✗ Branch 11 not taken.
2136 const auto layout = _file.value().get_dimensions(std::string{path}).value();
273
2/2
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 198 times.
1068 const std::size_t step_offset = _is_transient() ? 1 : 0;
274
3/4
✓ Branch 2 taken 1068 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 708 times.
✓ Branch 5 taken 360 times.
1068 if (layout.size() == _grid_dimension() + step_offset + 1)
275 708 return layout.back();
276 360 return {};
277 1068 }
278
279 2160 std::size_t _grid_dimension() const {
280
1/2
✓ Branch 2 taken 2160 times.
✗ Branch 3 not taken.
2160 return VTK::CommonDetail::structured_grid_dimension(_get_extents());
281 }
282
283 4825 std::array<std::size_t, 3> _get_extents() const {
284 return {
285 4825 _piece_location.upper_right[0] - _piece_location.lower_left[0],
286 4825 _piece_location.upper_right[1] - _piece_location.lower_left[1],
287 4825 _piece_location.upper_right[2] - _piece_location.lower_left[2]
288 14475 };
289 }
290
291 1194 bool _is_transient() const {
292 1194 return static_cast<bool>(_num_steps);
293 }
294
295 Communicator _comm;
296 std::optional<HDF5File> _file;
297 typename GridReader::PieceLocation _piece_location;
298 std::array<double, 9> _direction;
299 std::array<double, 3> _cell_spacing;
300 std::array<double, 3> _point_origin;
301 std::optional<std::size_t> _num_steps;
302 std::optional<std::size_t> _step_index;
303 };
304
305 } // namespace GridFormat
306
307 #endif // GRIDFORMAT_HAVE_HIGH_FIVE
308 #endif // GRIDFORMAT_VTK_HDF_IMAGE_GRID_READER_HPP_
309