diff --git a/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C b/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C index 7531cff0d6..379fc673a5 100644 --- a/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C @@ -71,6 +71,8 @@ namespace Iocatalyst { inline static const std::string CATCONDNODE = "CATALYST_CONDUIT_NODE"; inline static const std::string CATDUMPDIR = "CATALYST_DATA_DUMP_DIRECTORY"; inline static const std::string CATREADTIMESTEP = "CATALYST_READER_TIME_STEP"; + inline static const std::string CELLIDS = "cell_ids"; + inline static const std::string CELLNODEIDS = "cell_node_ids"; inline static const std::string COMPONENTCOUNT = "component_count"; inline static const std::string COMPONENTDEGREE = "component_degree"; inline static const std::string COUNT = "count"; @@ -587,6 +589,41 @@ namespace Iocatalyst { std::string getTimePath() { return detail::DATABASE + detail::FS + detail::TIME; } + int64_t getStructuredBlockIDS(const Ioss::StructuredBlock *sb, const Ioss::Field &field, + void *data, size_t data_size) + { + auto num_to_get = field.verify(data_size); + + if (num_to_get > 0) { + switch (field.get_type()) { + case Ioss::Field::BasicType::INT32: + copyIDS(sb, field, reinterpret_cast(data)); + break; + + case Ioss::Field::BasicType::INT64: + copyIDS(sb, field, reinterpret_cast(data)); + break; + default: + std::ostringstream errmsg; + fmt::print(errmsg, "ERROR in {}: {} ({}), unsupported field type: {}\n", __func__, + field.get_name(), num_to_get, field.type_string()); + IOSS_ERROR(errmsg); + } + } + return num_to_get; + } + + template + void copyIDS(const Ioss::StructuredBlock *sb, const Ioss::Field &field, INT_t *data) + { + if (field.get_name() == detail::CELLIDS) { + sb->get_cell_ids(data, true); + } + else { + sb->get_cell_node_ids(data, true); + } + } + Ioss::Map &get_node_map(const Ioss::DatabaseIO *dbase) const { if (this->NodeMap.defined()) { @@ -1679,6 +1716,9 @@ namespace Iocatalyst { if (impl.hasField(blockPath, sb, field.get_name())) { return impl.getField(blockPath, sb, field, data, data_size); } + else if (field.get_name() == detail::CELLIDS || field.get_name() == detail::CELLNODEIDS) { + return impl.getStructuredBlockIDS(sb, field, data, data_size); + } else if ((field.get_name() == detail::MESHMODCO) && (impl.hasField(blockPath, sb, detail::MESHMODCOX) && impl.hasField(blockPath, sb, detail::MESHMODCOY) && 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 4283115b50..48bc674704 100644 --- a/packages/seacas/libraries/ioss/src/catalyst_tests/Iocatalyst_ConduitReadTest.C +++ b/packages/seacas/libraries/ioss/src/catalyst_tests/Iocatalyst_ConduitReadTest.C @@ -9,6 +9,7 @@ #include #include #include +#include TEST_F(Iocatalyst_DatabaseIOTest, ReadConduitCanExo) { @@ -97,4 +98,37 @@ TEST_F(Iocatalyst_DatabaseIOTest, SetRankNumRanksSerialParallel) auto db = getCatalystDatabaseFromConduitFiles("Iocatalyst_can_ex2_MPI_1", iossProp); ASSERT_TRUE(db != nullptr); +} + +TEST_F(Iocatalyst_DatabaseIOTest, CellIdsAndCellNodeIds) +{ + setenv("CATALYST_READER_TIME_STEP", "1", 1); + + auto db = getCatalystDatabaseFromConduitFiles("Iocatalyst_sparc1_cgns_MPI_1"); + ASSERT_TRUE(db != nullptr); + + Ioss::Region reg(db); + + auto sb = reg.get_structured_block("blk-1"); + + EXPECT_TRUE(sb->field_exists("cell_ids")); + EXPECT_TRUE(sb->field_exists("cell_node_ids")); + + auto cids = sb->get_fieldref("cell_ids"); + EXPECT_TRUE(cids.get_type() == Ioss::Field::INTEGER); + std::vector cidBuff(cids.raw_count()); + EXPECT_EQ(sb->get_field_data("cell_ids", Data(cidBuff), sizeof(int32_t) * cidBuff.size()), + cids.raw_count()); + EXPECT_EQ(cidBuff[0], 1); + EXPECT_EQ(cidBuff[cids.raw_count() - 1], 256); + + + auto cnids = sb->get_fieldref("cell_node_ids"); + EXPECT_TRUE(cnids.get_type() == Ioss::Field::INTEGER); + std::vector cnidsBuff(cnids.raw_count()); + EXPECT_EQ( + sb->get_field_data("cell_node_ids", Data(cnidsBuff), sizeof(int32_t) * cnidsBuff.size()), + cnids.raw_count()); + EXPECT_EQ(cnidsBuff[0], 1); + EXPECT_EQ(cnidsBuff[cnids.raw_count() - 1], 594); } \ No newline at end of file