Skip to content

Fix source statistics#4056

Open
dkachuma wants to merge 11 commits into
developfrom
dkachuma/fix-source-statistics
Open

Fix source statistics#4056
dkachuma wants to merge 11 commits into
developfrom
dkachuma/fix-source-statistics

Conversation

@dkachuma
Copy link
Copy Markdown
Contributor

@dkachuma dkachuma commented May 13, 2026

Fixes: #4010

This PR addresses issues regarding the collection and merge of source flux statistics.

Changes Made

  • Time Advancement: Ensures that the time is properly advanced when a new collection is completed.
  • Statistics Reset: Forces a reset of statistics prior to merging to prevent stale or cumulative data from corrupting the merge output.
  • CSV File Handling: Updates the file-writing behaviour so the CSV file is appended to rather than overwritten each time, preserving historical collection data.
  • Fix the element count to exclude ghost cells.

@dkachuma dkachuma self-assigned this May 13, 2026
@dkachuma dkachuma added the type: bug Something isn't working label May 13, 2026
@dkachuma dkachuma linked an issue May 13, 2026 that may be closed by this pull request
@dkachuma dkachuma added ci: run CUDA builds Allows to triggers (costly) CUDA jobs flag: ready for review ci: run integrated tests Allows to run the integrated tests in GEOS CI flag: no rebaseline Does not require rebaseline ci: run code coverage enables running of the code coverage CI jobs labels May 13, 2026
@dkachuma dkachuma marked this pull request as ready for review May 13, 2026 18:43
@dkachuma dkachuma requested review from MelReyCG May 13, 2026 19:50
void SourceFluxStatsAggregator::WrappedStats::combine( WrappedStats const & other )
{
stats().combine( other.stats() );
m_statsPeriodStart = LvArray::math::max( m_statsPeriodStart, other.m_statsPeriodStart );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be LvArray::math::min?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the processes lag behind because the time doesn't get advanced. So we need to pick the most advanced time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I just would add a short comment to explain this choice.

// produce the period stats of this rank
m_stats.m_elementCount = m_periodStats.m_elementCount;
m_statsPeriodStart = m_periodStats.m_periodStart;
m_statsPeriodStart = MpiWrapper::max( m_periodStats.m_periodStart );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can they be different over ranks?
Isn't SourceFluxStatistics::gatherTimeStepStats() called synchonously?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for mpi ranks without cells in the region, there is a bypass at CompositionalMultiphaseBase.cpp:1813-1816 - haven't checked single phase, but probably the same thing. This means some of the processes don't get to call SourceFluxStatistics::gatherTimeStepStats() and lag behind. Hence the need for a max.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!
Same thing, I would add a short comment to explain why this max() call.

Copy link
Copy Markdown
Contributor

@MelReyCG MelReyCG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few comments requests

@MelReyCG
Copy link
Copy Markdown
Contributor

I was thinking, if a process is not involved in this computation, could it be excluded in some way? (if elementcount is 0 as an example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: run code coverage enables running of the code coverage CI jobs ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI flag: no rebaseline Does not require rebaseline flag: ready for review type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Source flux statistics reporting errors in MPI

2 participants