|
| 1 | +#include "SerialIOTests.hpp" |
| 2 | + |
| 3 | +#include "openPMD/openPMD.hpp" |
| 4 | + |
| 5 | +#include <catch2/catch.hpp> |
| 6 | + |
| 7 | +#include <memory> |
| 8 | +#include <numeric> |
| 9 | + |
| 10 | +namespace components_without_extent |
| 11 | +{ |
| 12 | +auto components_without_extent() -> void |
| 13 | +{ |
| 14 | + auto filepath = "../samples/components_without_extent.bp5"; |
| 15 | + // write |
| 16 | + { |
| 17 | + openPMD::Series write(filepath, openPMD::Access::CREATE); |
| 18 | + auto it0 = write.writeIterations()[0]; |
| 19 | + auto e = it0.particles["e"]; |
| 20 | + for (auto comp_id : {"x", "y", "z"}) |
| 21 | + { |
| 22 | + auto position_comp = e["position"][comp_id]; |
| 23 | + position_comp.resetDataset({openPMD::Datatype::FLOAT, {5}}); |
| 24 | + std::unique_ptr<float[]> data{new float[5]}; |
| 25 | + std::iota(data.get(), data.get() + 5, 0); |
| 26 | + position_comp.storeChunk(std::move(data), {0}, {5}); |
| 27 | + |
| 28 | + auto offset_comp = e["positionOffset"][comp_id]; |
| 29 | + offset_comp.resetDataset({openPMD::Datatype::INT, {}}); |
| 30 | + offset_comp.makeConstant(0); |
| 31 | + } |
| 32 | + write.close(); |
| 33 | + } |
| 34 | + |
| 35 | + // read |
| 36 | + { |
| 37 | + openPMD::Series read(filepath, openPMD::Access::READ_RANDOM_ACCESS); |
| 38 | + auto e = read.snapshots()[0].particles["e"]; |
| 39 | + for (auto const &record : e) |
| 40 | + { |
| 41 | + for (auto const &component : record.second) |
| 42 | + { |
| 43 | + REQUIRE(component.second.getExtent() == openPMD::Extent{5}); |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | +} |
| 48 | +} // namespace components_without_extent |
0 commit comments