Skip to content

Commit

Permalink
CONJOIN: Fix handling of parts with different sideset counts
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Dec 19, 2023
1 parent 4d28f6b commit 8399fb6
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 48 deletions.
4 changes: 2 additions & 2 deletions packages/seacas/applications/conjoin/CJ_Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

static const std::array<std::string, 3> qainfo{
"conjoin",
"1.4.10",
"2023/08/18",
"1.5.00",
"2023/12/19",
};
108 changes: 62 additions & 46 deletions packages/seacas/applications/conjoin/Conjoin.C
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,23 @@ namespace {
const std::vector<std::vector<T>> &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();
}
}
}
Expand Down Expand Up @@ -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++;
}
}
Expand Down Expand Up @@ -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...
Expand Down Expand Up @@ -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);

Expand All @@ -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<INT, INT> 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<INT, INT> 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...
Expand Down

0 comments on commit 8399fb6

Please sign in to comment.