diff --git a/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C b/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C index dfcf6f2dec..0d3391e309 100644 --- a/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C @@ -32,6 +32,7 @@ #include // for StructuredBlock #include // for Utils, IOSS_ERROR, etc +#include #include #include #include @@ -162,6 +163,10 @@ namespace Iocatalyst { return true; } + void readZoneConnectivity(conduit_cpp::Node &&parent, Ioss::StructuredBlock *sb); + void readBoundaryConditions(conduit_cpp::Node &&parent, Ioss::StructuredBlock *sb); + Ioss::IJK_t readIJK(conduit_cpp::Node &&parent); + bool readModel(Ioss::Region *region); bool readTime(Ioss::Region *region) @@ -393,6 +398,7 @@ namespace Iocatalyst { else if (retVal.empty()) { retVal = entityGroup->generic_name(); } + std::replace(retVal.begin(), retVal.end(), '/', '-'); return retVal; } @@ -442,6 +448,75 @@ namespace Iocatalyst { return true; } + bool defineEntityGroup(conduit_cpp::Node parent, + const Ioss::StructuredBlockContainer &container) + { + for (auto group : container) { + this->addProperties(parent[getName(group)], group); + conduit_cpp::Node n; + for (auto zc : group->m_zoneConnectivity) { + defineZoneConnectivity(n, zc); + } + parent[getName(group) + "/zoneconnectivity"].set(n); + + n.set_node(conduit_cpp::Node()); + for (auto bc : group->m_boundaryConditions) { + defineBoundaryCondition(n, bc); + } + parent[getName(group) + "/boundaryconditions"].set(n); + + parent[getName(group) + "/blocklocalnodeindex"].set(group->m_blockLocalNodeIndex); + + n.set_node(conduit_cpp::Node()); + for (auto gm : group->m_globalIdMap) { + conduit_cpp::Node m; + m["key"] = gm.first; + m["value"] = gm.second; + m.append().set(n); + } + parent[getName(group) + "/globalidmap"].set(n); + } + return true; + } + + void defineZoneConnectivity(conduit_cpp::Node parent, Ioss::ZoneConnectivity &zc) + { + conduit_cpp::Node n; + n["m_connectionName"] = zc.m_connectionName; + n["m_donorName"] = zc.m_donorName; + n["m_transform"] = defineIJK(zc.m_transform); + n["m_ownerRangeBeg"] = defineIJK(zc.m_ownerRangeBeg); + n["m_ownerRangeEnd"] = defineIJK(zc.m_ownerRangeEnd); + n["m_ownerOffset"] = defineIJK(zc.m_ownerOffset); + n["m_donorRangeBeg"] = defineIJK(zc.m_donorRangeBeg); + n["m_donorRangeEnd"] = defineIJK(zc.m_donorRangeEnd); + n["m_donorOffset"] = defineIJK(zc.m_donorOffset); + n["m_ownerZone"] = zc.m_ownerZone; + n["m_donorZone"] = zc.m_donorZone; + n["m_fromDecomp"] = zc.m_fromDecomp; + parent.append().set(n); + } + + void defineBoundaryCondition(conduit_cpp::Node parent, Ioss::BoundaryCondition &bc) + { + conduit_cpp::Node n; + n["m_bcName"] = bc.m_bcName; + n["m_famName"] = bc.m_famName; + n["m_rangeBeg"] = defineIJK(bc.m_rangeBeg); + n["m_rangeEnd"] = defineIJK(bc.m_rangeEnd); + n["m_face"] = bc.m_face; + parent.append().set(n); + } + + conduit_cpp::Node defineIJK(Ioss::IJK_t &a) + { + conduit_cpp::Node n; + for (auto v : a) { + n.append().set(v); + } + return n; + } + template bool addProperties(conduit_cpp::Node parent, GroupingEntityT *entityGroup) { @@ -641,10 +716,66 @@ namespace Iocatalyst { this->readFields(child["fields"], block); this->readFields(child[getName(&block->get_node_block()) + "/fields"], &block->get_node_block()); + + readZoneConnectivity(child["zoneconnectivity"], block); + readBoundaryConditions(child["boundaryconditions"], block); + + conduit_uint64 *my_vals = child["blocklocalnodeindex"].as_uint64_ptr(); + block->m_blockLocalNodeIndex.clear(); + for (int i = 0; i < child["blocklocalnodeindex"].number_of_elements(); i++) { + block->m_blockLocalNodeIndex.push_back(my_vals[i]); + } + + conduit_cpp::Node &&n = child["globalidmap"]; + block->m_globalIdMap.clear(); + for (conduit_index_t i = 0, m = n.number_of_children(); i < m; ++i) { + auto &&c = n[i]; + block->m_globalIdMap.push_back( + std::pair(c["key"].as_int(), c["value"].as_int())); + } } return true; } + void DatabaseIO::ImplementationT::readZoneConnectivity(conduit_cpp::Node &&parent, + Ioss::StructuredBlock *sb) + { + for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { + auto &&child = parent[idx]; + Ioss::ZoneConnectivity zc(child["m_connectionName"].as_string(), + child["m_ownerZone"].as_int(), child["m_donorName"].as_string(), + child["m_donorZone"].as_int(), readIJK(child["p_transform"]), + readIJK(child["m_ownerRangeBeg"]), + readIJK(child["m_ownerRangeEnd"]), readIJK(child["m_ownerOffset"]), + readIJK(child["m_donorRangeBeg"]), + readIJK(child["m_donorRangeEnd"]), readIJK(child["m_donorOffset"])); + zc.m_fromDecomp = child["m_fromDecomp"].as_int(); + sb->m_zoneConnectivity.push_back(zc); + } + } + + void DatabaseIO::ImplementationT::readBoundaryConditions(conduit_cpp::Node &&parent, + Ioss::StructuredBlock *sb) + { + for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) { + + auto &&child = parent[idx]; + Ioss::BoundaryCondition bc(child["m_bcName"].as_string(), child["m_famName"].as_string(), + readIJK(child["m_rangeBeg"]), readIJK(child["m_rangeEnd"])); + bc.m_face = child["m_face"].as_int(); + sb->m_boundaryConditions.push_back(bc); + } + } + + Ioss::IJK_t DatabaseIO::ImplementationT::readIJK(conduit_cpp::Node &&parent) + { + Ioss::IJK_t a{{0, 0, 0}}; + for (auto i = 0; i < parent.number_of_children(); i++) { + a[i] = parent[i].as_int(); + } + return a; + } + bool DatabaseIO::ImplementationT::readModel(Ioss::Region *region) { auto &node = this->DBNode; diff --git a/packages/seacas/libraries/ioss/src/catalyst_tests/CMakeLists.txt b/packages/seacas/libraries/ioss/src/catalyst_tests/CMakeLists.txt index 689f9b7268..5170a608d3 100644 --- a/packages/seacas/libraries/ioss/src/catalyst_tests/CMakeLists.txt +++ b/packages/seacas/libraries/ioss/src/catalyst_tests/CMakeLists.txt @@ -90,22 +90,21 @@ function(catalyst_test_ioshell_generated test_name ioshell_gen_args ioshell_output_file_name test_time - diff_command - diff_args) + test_time_step) -set(CATALYST_FNAME catalyst_time_${test_time}_${ioshell_output_file_name}) -set(IOSHELL_FNAME ioshell_time_${test_time}_${ioshell_output_file_name}) +set(CATALYST_FNAME catalyst_time_${test_time_step}_${ioshell_output_file_name}) +set(IOSHELL_FNAME ioshell_time_${test_time_step}_${ioshell_output_file_name}) TRIBITS_ADD_ADVANCED_TEST(${test_name} TEST_0 EXEC io_shell ARGS --in_type generated ${ioshell_gen_args} ${ioshell_output_file_name} DIRECTORY ../main NOEXEPREFIX NOEXESUFFIX NUM_MPI_PROCS 1 - TEST_1 EXEC io_shell ARGS -out_type catalyst ${ioshell_output_file_name} ${test_time} + TEST_1 EXEC io_shell ARGS -out_type catalyst ${ioshell_output_file_name} ${test_time_step} DIRECTORY ../main NOEXEPREFIX NOEXESUFFIX NUM_MPI_PROCS 1 - TEST_2 EXEC io_shell ARGS -in_type catalyst ${test_time} ${CATALYST_FNAME} + TEST_2 EXEC io_shell ARGS -in_type catalyst ${test_time_step} ${CATALYST_FNAME} DIRECTORY ../main NOEXEPREFIX NOEXESUFFIX NUM_MPI_PROCS 1 @@ -114,7 +113,7 @@ TRIBITS_ADD_ADVANCED_TEST(${test_name} DIRECTORY ../main NOEXEPREFIX NOEXESUFFIX NUM_MPI_PROCS 1 - TEST_4 EXEC ${diff_command} ARGS ${diff_args} ${IOSHELL_FNAME} ${CATALYST_FNAME} + TEST_4 EXEC exodiff ARGS -pedantic ${IOSHELL_FNAME} ${CATALYST_FNAME} DIRECTORY ../../../../applications/exodiff NOEXEPREFIX NOEXESUFFIX NUM_MPI_PROCS 1 @@ -124,42 +123,43 @@ endfunction() catalyst_test_ioshell_generated("catalyst_ioshell_10x10x10" "10x10x10+times:4+variables:element,2,nodal,3" - "ioshell_10x10x10.g" "3" "exodiff" "-pedantic") + "ioshell_10x10x10.g" "3" "3") catalyst_test_ioshell_generated("catalyst_ioshell_10x10x10_tets" "10x10x10+tets:+times:2+variables:element,2,nodal,3" - "ioshell_10x10x10_tets.g" "1" "exodiff" "-pedantic") + "ioshell_10x10x10_tets.g" "1" "1") catalyst_test_ioshell_generated("catalyst_ioshell_10x10x10_pyramids" "10x10x10+pyramids:+times:2+variables:element,2,nodal,3" - "ioshell_10x10x10_pyramids.g" "1" "exodiff" "-pedantic") + "ioshell_10x10x10_pyramids.g" "1" "1") catalyst_test_ioshell_generated("catalyst_ioshell_10x10x10_shell" "10x10x10+shell:xX:+times:2+variables:element,2,nodal,3" - "ioshell_10x10x10_shell.g" "1" "exodiff" "-pedantic") + "ioshell_10x10x10_shell.g" "1" "1") catalyst_test_ioshell_generated("catalyst_ioshell_10x10x10_nodeset" "10x10x10+nodeset:xX:+times:2+variables:element,2,nodal,3,nodeset,4" - "ioshell_10x10x10_nodeset.g" "1" "exodiff" "-pedantic") + "ioshell_10x10x10_nodeset.g" "1" "1") catalyst_test_ioshell_generated("catalyst_ioshell_10x10x10_sideset" "10x10x10+sideset:xX:+times:2+variables:element,2,nodal,3,sideset,4" - "ioshell_10x10x10_sideset.g" "1" "exodiff" "-pedantic") + "ioshell_10x10x10_sideset.g" "1" "1") function(catalyst_test_ioshell_exodus_file test_name input_file - test_time) + test_time + test_time_step) -set(CATALYST_FNAME catalyst_time_${test_time}_${input_file}) -set(IOSHELL_FNAME ioshell_time_${test_time}_${input_file}) +set(CATALYST_FNAME catalyst_time_${test_time_step}_${input_file}) +set(IOSHELL_FNAME ioshell_time_${test_time_step}_${input_file}) set(INPUT_FILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../main/test/${input_file}) TRIBITS_ADD_ADVANCED_TEST(${test_name} - TEST_0 EXEC io_shell ARGS -out_type catalyst ${INPUT_FILE_PATH} ${test_time} + TEST_0 EXEC io_shell ARGS -out_type catalyst ${INPUT_FILE_PATH} ${test_time_step} DIRECTORY ../main NOEXEPREFIX NOEXESUFFIX NUM_MPI_PROCS 1 - TEST_1 EXEC io_shell ARGS -in_type catalyst ${test_time} ${CATALYST_FNAME} + TEST_1 EXEC io_shell ARGS -in_type catalyst ${test_time_step} ${CATALYST_FNAME} DIRECTORY ../main NOEXEPREFIX NOEXESUFFIX NUM_MPI_PROCS 1 @@ -175,8 +175,8 @@ TRIBITS_ADD_ADVANCED_TEST(${test_name} ) endfunction() -catalyst_test_ioshell_exodus_file("catalyst_ioshell_cube_g" "cube.g" "1") -catalyst_test_ioshell_exodus_file("catalyst_ioshell_two_block_g" "two-block.g" "1") +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") IF (TPL_ENABLE_CGNS) @@ -200,18 +200,19 @@ if ( CGNS_CGNSDIFF_BINARY ) function(catalyst_test_ioshell_cgns_file test_name input_file - test_time) + test_time + test_time_step) -set(CATALYST_FNAME catalyst_time_${test_time}_${input_file}) -set(IOSHELL_FNAME ioshell_time_${test_time}_${input_file}) +set(CATALYST_FNAME catalyst_time_${test_time_step}_${input_file}) +set(IOSHELL_FNAME ioshell_time_${test_time_step}_${input_file}) set(INPUT_FILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../main/test/${input_file}) TRIBITS_ADD_ADVANCED_TEST(${test_name} - TEST_0 EXEC io_shell ARGS -out_type catalyst ${INPUT_FILE_PATH} ${test_time} + TEST_0 EXEC io_shell ARGS -debug -out_type catalyst ${INPUT_FILE_PATH} ${test_time_step} DIRECTORY ../main NOEXEPREFIX NOEXESUFFIX NUM_MPI_PROCS 1 - TEST_1 EXEC io_shell ARGS -in_type catalyst ${test_time} ${CATALYST_FNAME} + TEST_1 EXEC io_shell ARGS -in_type catalyst ${test_time_step} ${CATALYST_FNAME} DIRECTORY ../main NOEXEPREFIX NOEXESUFFIX NUM_MPI_PROCS 1 @@ -226,7 +227,7 @@ TRIBITS_ADD_ADVANCED_TEST(${test_name} ) endfunction() -catalyst_test_ioshell_cgns_file("catalyst_ioshell_sparc1_cgns" "sparc1.cgns" "1") +catalyst_test_ioshell_cgns_file("catalyst_ioshell_sparc1_cgns" "sparc1.cgns" "15.992" "1") endif() endif()