Skip to content

Commit

Permalink
IOSS: Fix reading db with inconsistent timestep count
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Jul 9, 2024
1 parent 6c056df commit c1d8ced
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,9 @@ namespace Ioex {
// common
int64_t BaseDatabaseIO::add_results_fields(Ioss::GroupingEntity *entity, int64_t position)
{
auto timestep_count = get_region()->get_optional_property("state_count", 0);
if (timestep_count == 0) return 0;

ex_entity_type type = Ioex::map_exodus_type(entity->type());
return internal_add_results_fields(type, entity, position, m_groupCount[type],
m_truthTable[type], m_variables[type]);
Expand Down
23 changes: 20 additions & 3 deletions packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,24 @@ namespace Ioex {
{
Ioss::SerializeIO serializeIO_(this);
timestep_count = ex_inquire_int(get_file_pointer(), EX_INQ_TIME);
// Need to sync timestep count across ranks if parallel...
if (isParallel) {
auto min_timestep_count = util().global_minmax(timestep_count, Ioss::ParallelUtils::DO_MIN);
if (min_timestep_count == 0) {
auto max_timestep_count = util().global_minmax(timestep_count, Ioss::ParallelUtils::DO_MAX);
if (max_timestep_count != 0) {
if (myProcessor == 0) {
// NOTE: Don't want to warn on all processors if the
// timestep count is zero on some, but not all ranks.
fmt::print(Ioss::WarnOut(),
"At least one database has no timesteps. No times will be read on ANY"
" database for consistency.\n");
}
}
}
timestep_count = min_timestep_count;
}

if (timestep_count <= 0) {
return;
}
Expand Down Expand Up @@ -1125,12 +1143,11 @@ namespace Ioex {
Ioss::Int64Vector counts(m_groupCount[entity_type] * 4);
Ioss::Int64Vector local_X_count(m_groupCount[entity_type]);
Ioss::Int64Vector global_X_count(m_groupCount[entity_type]);
int iblk;

{
Ioss::SerializeIO serializeIO_(this);

for (iblk = 0; iblk < m_groupCount[entity_type]; iblk++) {
for (int iblk = 0; iblk < m_groupCount[entity_type]; iblk++) {
int index = 4 * iblk;
int64_t id = X_block_ids[iblk];

Expand Down Expand Up @@ -1184,7 +1201,7 @@ namespace Ioex {
// querying if none.
int nmap = std::numeric_limits<int>::max(); // Number of 'block' vars on database. Used to skip
// querying if none.
for (iblk = 0; iblk < m_groupCount[entity_type]; iblk++) {
for (int iblk = 0; iblk < m_groupCount[entity_type]; iblk++) {
int index = 4 * iblk;
int64_t nodes_per_X = counts[index + 0];
int64_t edges_per_X = counts[index + 1];
Expand Down

0 comments on commit c1d8ced

Please sign in to comment.