From 90dc27f8ab7e27ecd884ac2cd6437d06c29b1988 Mon Sep 17 00:00:00 2001 From: tjotaha Date: Thu, 13 Jun 2024 16:45:48 -0600 Subject: [PATCH] IOSS: Catalyst API 2 (#462) Allow CATALYST_READER_TIME_STEP to be defined as an environment variable. Changed default timestep to 0 for reading from Conduit files. --- .../ioss/src/catalyst/Iocatalyst_DatabaseIO.C | 6 +++++- .../Iocatalyst_ConduitReadTest.C | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C b/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C index 77f223fac3..e17738a9c6 100644 --- a/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -1244,10 +1245,13 @@ namespace Iocatalyst { this->Impl->setDatabaseNode(c_node_ptr); } else { - int timestep = 1; + int timestep = 0; if (pm.exists(detail::CATREADTIMESTEP)) { timestep = pm.get(detail::CATREADTIMESTEP).get_int(); } + else if(const char* ts = std::getenv(detail::CATREADTIMESTEP.c_str())) { + timestep = std::stoi(std::string(ts)); + } std::ostringstream path; path << get_catalyst_dump_dir() << detail::EXECUTE_INVC << timestep << detail::PARAMS_CONDUIT_BIN << util().parallel_size() << detail::DOT diff --git a/packages/seacas/libraries/ioss/src/catalyst_tests/Iocatalyst_ConduitReadTest.C b/packages/seacas/libraries/ioss/src/catalyst_tests/Iocatalyst_ConduitReadTest.C index 128fc09e53..766a8dc8c1 100644 --- a/packages/seacas/libraries/ioss/src/catalyst_tests/Iocatalyst_ConduitReadTest.C +++ b/packages/seacas/libraries/ioss/src/catalyst_tests/Iocatalyst_ConduitReadTest.C @@ -69,4 +69,22 @@ TEST_F(Iocatalyst_DatabaseIOTest, SetReaderTimeStepWithIOSSProp) auto maxt = reg.get_max_time(); EXPECT_EQ(maxt.first, 1); EXPECT_DOUBLE_EQ(maxt.second, 0.0011999331181868911); +} + +TEST_F(Iocatalyst_DatabaseIOTest, SetReaderTimeStepWithIOSSEnvVar) +{ + setenv("CATALYST_READER_TIME_STEP", "24", 1); + + auto db = getCatalystDatabaseFromConduitFiles("Iocatalyst_can_ex2_MPI_1"); + ASSERT_TRUE(db != nullptr); + + Ioss::Region reg(db); + + auto mint = reg.get_min_time(); + EXPECT_EQ(mint.first, 1); + EXPECT_DOUBLE_EQ(mint.second, 0.0024000538978725672); + + auto maxt = reg.get_max_time(); + EXPECT_EQ(maxt.first, 1); + EXPECT_DOUBLE_EQ(maxt.second, 0.0024000538978725672); } \ No newline at end of file