add minimal unit tests for reading binary dumps

This commit is contained in:
Axel Kohlmeyer
2021-12-11 21:03:32 -05:00
parent 0603dc6323
commit 87501347ad
2 changed files with 54 additions and 0 deletions

View File

@ -521,6 +521,32 @@ TEST_F(DumpAtomTest, rerun)
delete_file(dump_file); delete_file(dump_file);
} }
TEST_F(DumpAtomTest, rerun_bin)
{
auto dump_file = binary_dump_filename("rerun");
HIDE_OUTPUT([&] {
command("fix 1 all nve");
});
generate_dump(dump_file, "", 1);
double pe_1, pe_2, pe_rerun;
lmp->output->thermo->evaluate_keyword("pe", &pe_1);
ASSERT_FILE_EXISTS(dump_file);
continue_dump(1);
lmp->output->thermo->evaluate_keyword("pe", &pe_2);
ASSERT_FILE_EXISTS(dump_file);
HIDE_OUTPUT([&] {
command(fmt::format("rerun {} first 1 last 1 every 1 post no dump x y z", dump_file));
});
lmp->output->thermo->evaluate_keyword("pe", &pe_rerun);
ASSERT_NEAR(pe_1, pe_rerun,1.0e-14);
HIDE_OUTPUT([&] {
command(fmt::format("rerun {} first 2 last 2 every 1 post yes dump x y z", dump_file));
});
lmp->output->thermo->evaluate_keyword("pe", &pe_rerun);
ASSERT_NEAR(pe_2, pe_rerun,1.0e-14);
delete_file(dump_file);
}
TEST_F(DumpAtomTest, multi_file_run1) TEST_F(DumpAtomTest, multi_file_run1)
{ {
auto dump_file = dump_filename("run1_*"); auto dump_file = dump_filename("run1_*");

View File

@ -346,6 +346,34 @@ TEST_F(DumpCustomTest, rerun)
delete_file(dump_file); delete_file(dump_file);
} }
TEST_F(DumpCustomTest, rerun_bin)
{
auto dump_file = binary_dump_filename("rerun");
auto fields = "id type xs ys zs";
HIDE_OUTPUT([&] {
command("fix 1 all nve");
});
generate_dump(dump_file, fields, "", 1);
double pe_1, pe_2, pe_rerun;
lmp->output->thermo->evaluate_keyword("pe", &pe_1);
ASSERT_FILE_EXISTS(dump_file);
continue_dump(1);
lmp->output->thermo->evaluate_keyword("pe", &pe_2);
ASSERT_FILE_EXISTS(dump_file);
HIDE_OUTPUT([&] {
command(fmt::format("rerun {} first 1 last 1 every 1 post no dump x y z", dump_file));
});
lmp->output->thermo->evaluate_keyword("pe", &pe_rerun);
ASSERT_NEAR(pe_1, pe_rerun,1.0e-14);
HIDE_OUTPUT([&] {
command(fmt::format("rerun {} first 2 last 2 every 1 post yes dump x y z", dump_file));
});
lmp->output->thermo->evaluate_keyword("pe", &pe_rerun);
ASSERT_NEAR(pe_2, pe_rerun,1.0e-14);
delete_file(dump_file);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);