From 8399fb60532ff9bd39305a9c92eced468adc306c Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Tue, 19 Dec 2023 11:04:44 -0700 Subject: [PATCH] CONJOIN: Fix handling of parts with different sideset counts --- .../seacas/applications/conjoin/CJ_Version.h | 4 +- .../seacas/applications/conjoin/Conjoin.C | 108 ++++++++++-------- 2 files changed, 64 insertions(+), 48 deletions(-) diff --git a/packages/seacas/applications/conjoin/CJ_Version.h b/packages/seacas/applications/conjoin/CJ_Version.h index d66cfd712c..7a9afb3600 100644 --- a/packages/seacas/applications/conjoin/CJ_Version.h +++ b/packages/seacas/applications/conjoin/CJ_Version.h @@ -9,6 +9,6 @@ static const std::array qainfo{ "conjoin", - "1.4.10", - "2023/08/18", + "1.5.00", + "2023/12/19", }; diff --git a/packages/seacas/applications/conjoin/Conjoin.C b/packages/seacas/applications/conjoin/Conjoin.C index b350e4f576..3117bed6d1 100644 --- a/packages/seacas/applications/conjoin/Conjoin.C +++ b/packages/seacas/applications/conjoin/Conjoin.C @@ -288,19 +288,23 @@ namespace { const std::vector> &sets) { bool problem = false; - for (size_t i = 0; i < global_sets.size(); i++) { - size_t loc_pos = global_sets[i].position_; - for (size_t p = 0; p < part_count; p++) { - if (global_sets[i].id != sets[p][loc_pos].id || - case_compare(global_sets[i].name_, sets[p][loc_pos].name_) != 0 || - sets[p][loc_pos].position_ != i) { + for (size_t p = 0; p < part_count; p++) { + for (size_t i = 0; i < sets[p].size(); i++) { + if (sets[p][i].id == 0) { + continue; + } + auto glob_pos = sets[p][i].position_; + if (global_sets[glob_pos].id != sets[p][i].id || + case_compare(global_sets[glob_pos].name_, sets[p][i].name_) != 0) { problem = true; fmt::print(stderr, - "\nERROR: Mismatch for global {0} at position {1} and local {0} in part {2} " - "position {3}\n", - type, i, p + 1, loc_pos); - global_sets[i].dump(); - sets[p][loc_pos].dump(); + "\nERROR: {0} Mismatch on part {1}:\n" + "\tpart {0} at position {2} has id {3} and name {4}\n" + "\tglobal {0} at position {5} has id {6} and name {7}\n", + type, p+1, i, sets[p][i].id, sets[p][i].name_, + glob_pos, global_sets[glob_pos].id, global_sets[glob_pos].name_); + global_sets[glob_pos].dump(); + sets[p][i].dump(); } } } @@ -2340,7 +2344,7 @@ namespace { size_t i = 0; for (auto set_id : set_ids) { glob_ssets[i].id = set_id; - glob_ssets[i].position_ = i; + glob_ssets[i].position_ = i; // Not used i++; } } @@ -2368,7 +2372,6 @@ namespace { } } SMART_ASSERT(gi != gsset_size); - glob_ssets[gi].position_ = i; sets[p][i].position_ = gi; // Get the parameters for this sideset... @@ -2418,21 +2421,24 @@ namespace { int ss_id = glob_ssets[ss].id; size_t offset = 0; - size_t lss = glob_ssets[ss].position_; for (size_t p = 0; p < part_count; p++) { - - Excn::ExodusFile id(p); - sets[p][lss].elems.resize(sets[p][lss].sideCount); - sets[p][lss].sides.resize(sets[p][lss].sideCount); - ex_get_set(id, EX_SIDE_SET, ss_id, sets[p][lss].elems.data(), sets[p][lss].sides.data()); - - // Add these to the elem_side vector... - for (size_t i = 0; i < sets[p][lss].sideCount; i++) { - size_t global_elem = local_mesh[p].localElementToGlobal[sets[p][lss].elems[i] - 1] + 1; - elem_side[offset + i] = std::make_pair((INT)global_elem, (INT)sets[p][lss].sides[i]); - } - offset += sets[p][lss].sideCount; - } + for (size_t lss = 0; lss < sets[p].size(); lss++) { + if (sets[p][lss].position_ == ss) { + Excn::ExodusFile id(p); + sets[p][lss].elems.resize(sets[p][lss].sideCount); + sets[p][lss].sides.resize(sets[p][lss].sideCount); + ex_get_set(id, EX_SIDE_SET, ss_id, sets[p][lss].elems.data(), sets[p][lss].sides.data()); + + // Add these to the elem_side vector... + for (size_t i = 0; i < sets[p][lss].sideCount; i++) { + size_t global_elem = local_mesh[p].localElementToGlobal[sets[p][lss].elems[i] - 1] + 1; + elem_side[offset + i] = std::make_pair((INT)global_elem, (INT)sets[p][lss].sides[i]); + } + offset += sets[p][lss].sideCount; + break; + } + } + } uniquify(elem_side); @@ -2455,32 +2461,42 @@ namespace { // Try the lower_bound searching of elem_side for now. If // inefficient, fix later... for (size_t p = 0; p < part_count; p++) { - sets[p][lss].elemOrderMap.resize(sets[p][lss].sideCount); - for (size_t i = 0; i < sets[p][lss].sideCount; i++) { - size_t global_elem = - local_mesh[p].localElementToGlobal[sets[p][lss].elems[i] - 1] + 1; - std::pair es = std::make_pair((INT)global_elem, (INT)sets[p][lss].sides[i]); - - auto iter = std::lower_bound(elem_side.begin(), elem_side.end(), es); - size_t pos = iter - elem_side.begin(); - sets[p][lss].elemOrderMap[i] = pos; - } + for (size_t lss = 0; lss < sets[p].size(); lss++) { + if (sets[p][lss].position_ == ss) { + sets[p][lss].elemOrderMap.resize(sets[p][lss].sideCount); + for (size_t i = 0; i < sets[p][lss].sideCount; i++) { + size_t global_elem = + local_mesh[p].localElementToGlobal[sets[p][lss].elems[i] - 1] + 1; + std::pair es = std::make_pair((INT)global_elem, (INT)sets[p][lss].sides[i]); + + auto iter = std::lower_bound(elem_side.begin(), elem_side.end(), es); + size_t pos = iter - elem_side.begin(); + sets[p][lss].elemOrderMap[i] = pos; + } + break; + } + } } } } // Calculate sideset offset - for (size_t b = 0; b < glob_ssets.size(); b++) { + for (size_t ss = 0; ss < glob_ssets.size(); ss++) { size_t sum = 0; for (size_t p = 0; p < part_count; p++) { - sets[p][b].offset_ = sum; - sum += sets[p][b].entity_count(); - - if (debug_level & 16) { - fmt::print("Part {} ", p + 1); - sets[p][b].dump(); - } - } + for (size_t lss = 0; lss < sets[p].size(); lss++) { + if (sets[p][lss].position_ == ss) { + sets[p][lss].offset_ = sum; + sum += sets[p][lss].entity_count(); + + if (debug_level & 16) { + fmt::print("Part {} ", p + 1); + sets[p][lss].dump(); + } + break; + } + } + } } // Free some memory which is no longer needed...