Skip to content

Commit 3123911

Browse files
committed
IOSS: Allow names for decomp omitting blocks
1 parent b6d8ef8 commit 3123911

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

packages/seacas/libraries/ioss/src/Ioss_Decomposition.C

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,13 @@ namespace Ioss {
321321
"Should be VEC_INTEGER. Ignored.\n"));
322322
}
323323
}
324+
if (props.exists("DECOMP_OMITTED_BLOCK_NAMES")) {
325+
auto name_string = props.get("DECOMP_OMITTED_BLOCK_NAMES").get_string();
326+
auto names = Ioss::tokenize(name_string, ",");
327+
for (const auto &name : names) {
328+
m_omittedBlockNames.push_back(name);
329+
}
330+
}
324331
if (props.exists("PARMETIS_COMMON_NODE_COUNT") &&
325332
props.get("PARMETIS_COMMON_NODE_COUNT").get_int() > 0) {
326333
m_commonNodeCount = props.get("PARMETIS_COMMON_NODE_COUNT").get_int();

packages/seacas/libraries/ioss/src/Ioss_Decomposition.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ namespace Ioss {
820820
// if m_fileBlockIndex[B] <= I && m_fileBlockIndex[B+1] < I
821821
std::vector<size_t> m_fileBlockIndex;
822822
std::vector<int64_t> m_omittedBlocks;
823+
std::vector<std::string> m_omittedBlockNames;
823824

824825
private:
825826
// This processor "manages" the elements on the exodus mesh file from

packages/seacas/libraries/ioss/src/Ioss_Doxygen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ LOAD_BALANCE_THRESHOLD | {real} [1.4] | CGNS-Structured only -- Load imbalance p
6767
DECOMPOSITION_EXTRA | {name},{multiplier} | Specify the name of the element map or variable used if the decomposition method is `map` or `variable`. If it contains a comma, the value following the comma is used to scale (divide) the values in the map/variable. If it is 'auto', then all values will be scaled by `max_value/processorCount`
6868
DECOMP_OMITTED_BLOCK_IDS | {id_list} | A integer vector containing the
6969
element block ids that should be ignored during the parallel decomposition. The blocks will still appear in the decomposition, but will not affect the load balance. If specified via `IOSS_PROPERTIES` can be a comma-separated string of ids.
70+
DECOMP_OMITTED_BLOCK_NAMES | {name_list} | A comma-separated list of block names that should be ignored during the parallel decomposition. The blocks will still appear in the decomposition, but will not affect the load balance.
7071
7172
### Valid values for Decomposition Method
7273

packages/seacas/libraries/ioss/src/exodus/Ioex_DecompositionData.C

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,46 @@ namespace Ioex {
521521
Ioss::Decomposition<INT> &decomposition)
522522
{
523523
// This routine is assumed to be called *after* generate_adjacency...
524-
if (decomposition.m_omittedBlocks.empty()) {
524+
if (decomposition.m_omittedBlocks.empty() && decomposition.m_omittedBlockNames.empty()) {
525525
return;
526526
}
527527

528-
m_decomposition.show_progress(__func__);
529528
size_t block_count = el_blocks.size();
529+
std::vector<INT> ids(block_count);
530+
ex_get_ids(filePtr, EX_ELEM_BLOCK, Data(ids));
531+
532+
if (!decomposition.m_omittedBlockNames.empty()) {
533+
// Need to determine the id of each block name in the list...
534+
// Probably easiest to go through each id and get its name and
535+
// see if it exists in `m_omittedBlockNames`
536+
int max_name_length = ex_inquire_int(filePtr, EX_INQ_DB_MAX_USED_NAME_LENGTH);
537+
max_name_length = std::max(max_name_length, 32);
538+
size_t num_found = 0;
539+
for (INT id : ids) {
540+
std::vector<char> buffer(max_name_length+1);
541+
buffer[0] = '\0';
542+
ex_get_name(filePtr, EX_ELEM_BLOCK, id, Data(buffer));
543+
if (buffer[0] != '\0') {
544+
std::string name(Data(buffer));
545+
bool found = std::find(decomposition.m_omittedBlockNames.begin(), decomposition.m_omittedBlockNames.end(),
546+
name) != decomposition.m_omittedBlockNames.end();
547+
if (found) {
548+
#if IOSS_DEBUG_OUTPUT
549+
if (m_processor == 0) {
550+
fmt::print(stderr, "Found name {} with id {}\n", name, id);
551+
}
552+
#endif
553+
decomposition.m_omittedBlocks.push_back(id);
554+
num_found++;
555+
if (num_found == decomposition.m_omittedBlockNames.size()) {
556+
break;
557+
}
558+
}
559+
}
560+
}
561+
}
562+
563+
m_decomposition.show_progress(__func__);
530564
if (decomposition.m_fileBlockIndex.size() != block_count + 1) {
531565
std::ostringstream errmsg;
532566
fmt::print(errmsg, "ERROR: The `generate_adjacency` function was not called prior to calling "
@@ -535,9 +569,6 @@ namespace Ioex {
535569
IOSS_ERROR(errmsg);
536570
}
537571

538-
std::vector<INT> ids(block_count);
539-
ex_get_ids(filePtr, EX_ELEM_BLOCK, Data(ids));
540-
541572
// Get the global element block index list at this time also.
542573
// The global element at index 'I' (0-based) is on block B
543574
// if global_block_index[B] <= I && global_block_index[B+1] < I

0 commit comments

Comments
 (0)