8#ifndef GRIDFORMAT_VTK_HDF_READER_HPP_
9#define GRIDFORMAT_VTK_HDF_READER_HPP_
10#if GRIDFORMAT_HAVE_HIGH_FIVE
17#include <gridformat/parallel/communication.hpp>
30template<
typename Communicator = Gr
idFormat::NullCommunicator>
33 explicit VTKHDFReader()
requires (std::is_default_constructible_v<Communicator>) =
default;
34 explicit VTKHDFReader(
const Communicator& comm) : _comm{comm} {}
38 std::string image_err;
39 std::string unstructured_err;
43 _reader = std::make_unique<VTKHDFImageGridReader>(std::move(reader));
44 }
catch (
const Exception& image_e) {
45 image_err = image_e.what();
47 using C = Communicator;
50 _reader = std::make_unique<VTKHDFUnstructuredGridReader<C>>(std::move(reader));
51 }
catch (
const Exception& unstructured_e) {
52 unstructured_err = unstructured_e.what();
58 "Could not open '" +
filename +
"' as vtk-hdf file.\n" +
59 "Error when trying to read as 'ImageData': " + image_err +
"\n" +
60 "Error when trying to read as 'UnstructuredGrid': " + unstructured_err
66 std::string _name()
const override {
68 return _reader->name();
69 return "VTKHDFReader";
72 void _close()
override {
78 void _visit_cells(
const CellVisitor& v)
const override {
86 FieldPtr _cell_field(std::string_view
name)
const override {
90 FieldPtr _point_field(std::string_view
name)
const override {
94 FieldPtr _meta_data_field(std::string_view
name)
const override {
98 std::size_t _number_of_cells()
const override {
102 std::size_t _number_of_points()
const override {
106 std::size_t _number_of_pieces()
const override {
114 std::vector<double> _ordinates(
unsigned int i)
const override {
118 std::array<double, 3> _spacing()
const override {
122 std::array<double, 3> _origin()
const override {
123 return _access().
origin();
126 std::array<double, 3> _basis_vector(
unsigned int i)
const override {
130 bool _is_sequence()
const override {
134 std::size_t _number_of_steps()
const override {
138 double _time_at_step(std::size_t step)
const override {
149 std::ranges::copy(
cell_field_names(_access()), std::back_inserter(names.cell_fields));
150 std::ranges::copy(
point_field_names(_access()), std::back_inserter(names.point_fields));
156 throw InvalidState(
"No active file opened");
162 throw InvalidState(
"No active file opened");
167 std::unique_ptr<GridReader> _reader;
Base class for grid data readers.
std::shared_ptr< const Field > FieldPtr
Pointer type used by writers/readers for fields.
Definition: field.hpp:186
Reader for the VTK HDF file format for image grids.
Reader for the VTK HDF file format for unstructured grids.