diff --git a/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C b/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C index 0d3391e309..0b6499dcbe 100644 --- a/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C @@ -24,6 +24,7 @@ #include "Ioss_Property.h" // for Property #include "Ioss_SideBlock.h" // for SideBlock #include // for Assembly +#include // for Blob #include // for HAVE_MPI #include // for NameList #include // for ParallelUtils, etc @@ -113,6 +114,13 @@ namespace Iocatalyst { localSizes, parentOffsets, globalSizes); } + template <> + Ioss::Assembly *createEntityGroup(const conduit_cpp::Node &node, + Ioss::DatabaseIO *dbase) + { + return new Ioss::Assembly(dbase, node["properties/name/value"].as_string()); + } + } // namespace detail class DatabaseIO::ImplementationT @@ -448,6 +456,18 @@ namespace Iocatalyst { return true; } + bool defineEntityGroup(conduit_cpp::Node parent, const Ioss::AssemblyContainer &container) + { + for (auto group : container) { + this->addProperties(parent[getName(group)], group); + parent[getName(group) + "/member_type"].set(group->get_member_type()); + for (auto as : group->get_members()) { + parent[getName(group) + "/members"].append().set(as->name()); + } + } + return true; + } + bool defineEntityGroup(conduit_cpp::Node parent, const Ioss::StructuredBlockContainer &container) { @@ -697,6 +717,50 @@ namespace Iocatalyst { return true; } + template <> + bool DatabaseIO::ImplementationT::readEntityGroup(conduit_cpp::Node &&parent, + Ioss::Region *region) + { + for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { + auto &&child = parent[idx]; + auto block = detail::createEntityGroup(child, region->get_database()); + auto member_type = child["member_type"].as_int(); + for (int i = 0; i < child["members"].number_of_children(); i++) { + auto name = child["members"].child(i).as_string(); + Ioss::GroupingEntity *ge = nullptr; + switch (member_type) { + case Ioss::EntityType::NODEBLOCK: ge = region->get_node_block(name); break; + case Ioss::EntityType::EDGEBLOCK: ge = region->get_edge_block(name); break; + case Ioss::EntityType::EDGESET: ge = region->get_edgeset(name); break; + case Ioss::EntityType::FACEBLOCK: ge = region->get_face_block(name); break; + case Ioss::EntityType::ELEMENTBLOCK: ge = region->get_element_block(name); break; + case Ioss::EntityType::NODESET: ge = region->get_nodeset(name); break; + case Ioss::EntityType::FACESET: ge = region->get_faceset(name); break; + case Ioss::EntityType::ELEMENTSET: ge = region->get_elementset(name); break; + case Ioss::EntityType::SIDESET: ge = region->get_sideset(name); break; + case Ioss::EntityType::COMMSET: ge = region->get_commset(name); break; + case Ioss::EntityType::SIDEBLOCK: ge = region->get_sideblock(name); break; + case Ioss::EntityType::ASSEMBLY: ge = region->get_assembly(name); break; + case Ioss::EntityType::BLOB: ge = region->get_blob(name); break; + default: + fmt::print(stderr, "ERROR in {} {}: unknown grouping entity type.\n", __func__, name); + } + if (ge) { + block->add(ge); + } + else { + fmt::print(stderr, "ERROR in {} {}: grouping entity not found.\n", __func__, name); + } + } + region->add(block); + this->readProperties(child["properties"], block); + + // read fields (meta-data only) + this->readFields(child["fields"], block); + } + return true; + } + template <> bool DatabaseIO::ImplementationT::readEntityGroup(conduit_cpp::Node &&parent, @@ -796,7 +860,7 @@ namespace Iocatalyst { // this->readEntityGroup(node["facesets"], region); // this->readEntityGroup(node["elementsets"], region); this->readEntityGroup(node["structuredblocks"], region); - // this->readEntityGroup(node["assemblies"], region); + this->readEntityGroup(node["assemblies"], region); return true; } @@ -954,7 +1018,7 @@ namespace Iocatalyst { { return Ioss::NODEBLOCK | Ioss::EDGEBLOCK | Ioss::FACEBLOCK | Ioss::ELEMENTBLOCK | Ioss::NODESET | Ioss::EDGESET | Ioss::FACESET | Ioss::ELEMENTSET | Ioss::SIDESET | - Ioss::SIDEBLOCK | Ioss::STRUCTUREDBLOCK | Ioss::REGION; + Ioss::SIDEBLOCK | Ioss::STRUCTUREDBLOCK | Ioss::ASSEMBLY | Ioss::REGION; } void DatabaseIO::read_meta_data__() @@ -1087,11 +1151,11 @@ namespace Iocatalyst { return -1; } - int64_t DatabaseIO::put_field_internal(const Ioss::Assembly * /*as*/, - const Ioss::Field & /*field*/, void * /*data*/, - size_t /*data_size*/) const + int64_t DatabaseIO::put_field_internal(const Ioss::Assembly *as, const Ioss::Field &field, + void *data, size_t data_size) const { - return -1; + auto &impl = (*this->Impl.get()); + return impl.putField("assemblies", as, field, data, data_size, this->deep_copy()); } int64_t DatabaseIO::put_field_internal(const Ioss::Blob * /*bl*/, const Ioss::Field & /*field*/, @@ -1234,11 +1298,11 @@ namespace Iocatalyst { { return -1; } - int64_t DatabaseIO::get_field_internal(const Ioss::Assembly * /*as*/, - const Ioss::Field & /*field*/, void * /*data*/, - size_t /*data_size*/) const + int64_t DatabaseIO::get_field_internal(const Ioss::Assembly *as, const Ioss::Field &field, + void *data, size_t data_size) const { - return -1; + auto &impl = (*this->Impl.get()); + return impl.getField("assemblies", as, field, data, data_size); } int64_t DatabaseIO::get_field_internal(const Ioss::Blob * /*bl*/, const Ioss::Field & /*field*/, void * /*data*/, size_t /*data_size*/) const diff --git a/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.h b/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.h index 70f64c63c6..8d1bc2a2cd 100644 --- a/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.h +++ b/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.h @@ -23,7 +23,7 @@ namespace Iocatalyst { class IOCATALYST_EXPORT DatabaseIO : public Ioss::DatabaseIO { - using Superclass = Ioss::DatabaseIO; + using Superclass = Ioss::DatabaseIO; public: DatabaseIO(Ioss::Region *region, const std::string &filename, Ioss::DatabaseUsage db_usage, @@ -127,8 +127,8 @@ namespace Iocatalyst { size_t data_size) const override; int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data, size_t data_size) const override; - int64_t get_field_internal(const Ioss::Assembly * /*as*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /*data_size*/) const override; + int64_t get_field_internal(const Ioss::Assembly *as, const Ioss::Field &field, void *data, + size_t data_size) const override; int64_t get_field_internal(const Ioss::Blob * /*bl*/, const Ioss::Field & /*field*/, void * /*data*/, size_t /*data_size*/) const override; int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field, @@ -167,8 +167,8 @@ namespace Iocatalyst { size_t data_size) const override; int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data, size_t data_size) const override; - int64_t put_field_internal(const Ioss::Assembly * /*as*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /*data_size*/) const override; + int64_t put_field_internal(const Ioss::Assembly *as, const Ioss::Field &field, void *data, + size_t data_size) const override; int64_t put_field_internal(const Ioss::Blob * /*bl*/, const Ioss::Field & /*field*/, void * /*data*/, size_t /*data_size*/) const override; int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field, diff --git a/packages/seacas/libraries/ioss/src/catalyst_tests/CMakeLists.txt b/packages/seacas/libraries/ioss/src/catalyst_tests/CMakeLists.txt index 5170a608d3..eb1f405c42 100644 --- a/packages/seacas/libraries/ioss/src/catalyst_tests/CMakeLists.txt +++ b/packages/seacas/libraries/ioss/src/catalyst_tests/CMakeLists.txt @@ -177,6 +177,7 @@ endfunction() catalyst_test_ioshell_exodus_file("catalyst_ioshell_cube_g" "cube.g" "1" "1") catalyst_test_ioshell_exodus_file("catalyst_ioshell_two_block_g" "two-block.g" "1" "1") +catalyst_test_ioshell_exodus_file("catalyst_ioshell_eight_block_g" "8-block.g" "0.05" "5") IF (TPL_ENABLE_CGNS)