diff --git a/test/CoreTest.cpp b/test/CoreTest.cpp index 3806aa0ea2..9619d9485a 100644 --- a/test/CoreTest.cpp +++ b/test/CoreTest.cpp @@ -212,7 +212,7 @@ TEST_CASE("custom_hierarchies", "[core]") auto meshesViaAlias = write.iterations[0].meshes; meshesViaAlias["E"]["x"].makeEmpty(2); - write.setMeshesPath("fields"); + write.setMeshesPath(std::vector{"fields/", ".*/meshes/"}); auto meshesManually = write.iterations[0]["fields"].asContainerOf(); REQUIRE(meshesManually.contains("E")); @@ -297,6 +297,89 @@ TEST_CASE("custom_hierarchies", "[core]") REQUIRE(constant_dataset.getDatatype() == Datatype::FLOAT); REQUIRE(constant_dataset.getExtent() == Extent{0, 0, 0}); } + read.close(); + + write = Series(filePath, Access::READ_WRITE); + { + std::vector data(10, 3); + + auto E_x = write.iterations[0]["custom_meshes"].meshes["E"]["x"]; + E_x.resetDataset({Datatype::INT, {10}}); + E_x.storeChunk(data, {0}, {10}); + + auto e_pos_x = write.iterations[0]["custom_particles"] + .particles["e"]["position"]["x"]; + e_pos_x.resetDataset({Datatype::INT, {10}}); + e_pos_x.storeChunk(data, {0}, {10}); + write.close(); + } + + read = Series(filePath, Access::READ_ONLY); + { + auto it0 = read.iterations[0]; + auto custom_meshes = it0["custom_meshes"]; + REQUIRE(custom_meshes.meshes.size() == 1); + REQUIRE(read.iterations[0]["custom_meshes"].meshes.count("E") == 1); + auto E_x_loaded = read.iterations[0]["custom_meshes"] + .meshes["E"]["x"] + .loadChunk(); + REQUIRE(read.iterations[0]["custom_particles"].particles.size() == 1); + REQUIRE( + read.iterations[0]["custom_particles"].particles.count("e") == 1); + auto e_pos_x_loaded = read.iterations[0]["custom_particles"] + .particles["e"]["position"]["x"] + .loadChunk(); + read.flush(); + + for (size_t i = 0; i < 10; ++i) + { + REQUIRE(E_x_loaded.get()[i] == 3); + REQUIRE(e_pos_x_loaded.get()[i] == 3); + } + } +} + +TEST_CASE("custom_hierarchies_no_rw", "[core]") +{ + std::string filePath = "../samples/custom_hierarchies_no_rw.json"; + Series write(filePath, Access::CREATE); + write.setMeshesPath(std::vector{".*/meshes/"}); + write.iterations[0]["custom"]["hierarchy"]; + write.iterations[0]["custom"].setAttribute("string", "attribute"); + write.iterations[0]["custom"]["hierarchy"].setAttribute("number", 3); + write.iterations[0]["no_attributes"]; + + { + write.iterations[0]["custom"]["hierarchy"]; + write.iterations[0]["custom"] + .asContainerOf()["emptyDataset"] + .makeEmpty(Datatype::FLOAT, 3); + write.iterations[0]["custom"]["hierarchy"].setAttribute("number", 3); + write.iterations[0]["no_attributes"]; + auto iteration_level_ds = + write.iterations[0] + .asContainerOf()["iteration_level_dataset"]; + iteration_level_ds.resetDataset({Datatype::INT, {10}}); + std::vector data(10, 5); + iteration_level_ds.storeChunk(data); + write.flush(); + } + + { + std::vector data(10, 3); + + auto E_x = write.iterations[0]["custom_meshes"].meshes["E"]["x"]; + E_x.resetDataset({Datatype::INT, {10}}); + E_x.storeChunk(data, {0}, {10}); + + auto e_pos_x = write.iterations[0]["custom_particles"] + .particles["e"]["position"]["x"]; + e_pos_x.resetDataset({Datatype::INT, {10}}); + e_pos_x.storeChunk(data, {0}, {10}); + write.close(); + } + + Series read(filePath, Access::READ_ONLY); } TEST_CASE("myPath", "[core]")