mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
added: parallel support to HDF5File / HDF5Serializer
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include <opm/input/eclipse/Schedule/Group/Group.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE HDF5FileTest
|
||||
#define BOOST_TEST_NO_MAIN
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
@@ -38,15 +39,21 @@ BOOST_AUTO_TEST_CASE(Header)
|
||||
auto path = std::filesystem::temp_directory_path() / Opm::unique_path("hdf5test%%%%%");
|
||||
std::filesystem::create_directory(path);
|
||||
auto rwpath = (path / "rw.hdf5").string();
|
||||
#if HAVE_MPI
|
||||
Parallel::Communication comm(MPI_COMM_SELF);
|
||||
#else
|
||||
Parallel::Communcation comm;
|
||||
#endif
|
||||
std::array<std::string,5> output{"foo", "bar", "foobar", "bob", "bobbar"};
|
||||
{
|
||||
HDF5Serializer ser(rwpath, HDF5File::OpenMode::OVERWRITE);
|
||||
HDF5Serializer ser(rwpath, HDF5File::OpenMode::OVERWRITE, comm);
|
||||
ser.writeHeader(output[0], output[1], output[2], output[3], output[4], 5);
|
||||
}
|
||||
{
|
||||
HDF5Serializer ser(rwpath, HDF5File::OpenMode::READ);
|
||||
HDF5Serializer ser(rwpath, HDF5File::OpenMode::READ, comm);
|
||||
std::tuple<std::array<std::string,5>,int> input;
|
||||
ser.read(input, "/", "simulator_info");
|
||||
ser.read(input, "/", "simulator_info",
|
||||
Opm::HDF5File::DataSetMode::ROOT_ONLY);
|
||||
const auto& [strings, num_procs] = input;
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(strings.begin(), strings.end(),
|
||||
output.begin(), output.end());
|
||||
@@ -62,13 +69,18 @@ BOOST_AUTO_TEST_CASE(WriteRead)
|
||||
auto path = std::filesystem::temp_directory_path() / Opm::unique_path("hdf5test%%%%%");
|
||||
std::filesystem::create_directory(path);
|
||||
auto rwpath = (path / "rw.hdf5").string();
|
||||
#if HAVE_MPI
|
||||
Parallel::Communication comm(MPI_COMM_SELF);
|
||||
#else
|
||||
Parallel::Communcation comm;
|
||||
#endif
|
||||
auto output = Group::serializationTestObject();
|
||||
{
|
||||
HDF5Serializer ser(rwpath, HDF5File::OpenMode::OVERWRITE);
|
||||
HDF5Serializer ser(rwpath, HDF5File::OpenMode::OVERWRITE, comm);
|
||||
ser.write(output, "/report_step/10", "test");
|
||||
}
|
||||
{
|
||||
HDF5Serializer ser(rwpath, HDF5File::OpenMode::READ);
|
||||
HDF5Serializer ser(rwpath, HDF5File::OpenMode::READ, comm);
|
||||
Group input;
|
||||
ser.read(input, "/report_step/10", "test");
|
||||
BOOST_CHECK_MESSAGE(input == output, "Deserialized data does not match input");
|
||||
@@ -81,3 +93,14 @@ BOOST_AUTO_TEST_CASE(WriteRead)
|
||||
std::filesystem::remove(rwpath);
|
||||
std::filesystem::remove(path);
|
||||
}
|
||||
|
||||
bool init_unit_test_func()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Dune::MPIHelper::instance(argc, argv);
|
||||
return boost::unit_test::unit_test_main(&init_unit_test_func, argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user