Skip to content

Commit

Permalink
IOSS: Catalyst API 2 (#462)
Browse files Browse the repository at this point in the history
Allow CATALYST_READER_TIME_STEP to be defined as an environment
variable.

Changed default timestep to 0 for reading from Conduit files.
  • Loading branch information
tjotaha authored Jun 13, 2024
1 parent b03564a commit 90dc27f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <cstdlib>
#include <fmt/ostream.h>
#include <map>
#include <cstdlib>

#include <catalyst.hpp>
#include <catalyst/Iocatalyst_DatabaseIO.h>
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 90dc27f

Please sign in to comment.