Skip to content

Fix source statistics#4056

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

Fix source statistics#4056
dkachuma wants to merge 15 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
// 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)

@dkachuma
Copy link
Copy Markdown
Contributor Author

@copilot Review and suggest code comments

…uxStatistics

Agent-Logs-Url: https://github.com/GEOS-DEV/GEOS/sessions/bcea92d2-4f51-434e-9036-5f81b1953661

Co-authored-by: dkachuma <81433670+dkachuma@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

@copilot Review and suggest code comments

Added explanatory comments at both max() call sites (commit a7f0894):

  • finalizePeriod() (line ~382): explains that MPI ranks without cells in the flux region can bypass gatherTimeStepStats() and lag behind, so MpiWrapper::max is used to ensure all ranks converge on the most advanced period start time.
  • combine() (line ~404): explains that the same lag can occur across individual flux stats, so LvArray::math::max picks the most advanced time when merging two WrappedStats.

@dkachuma
Copy link
Copy Markdown
Contributor Author

Added explanatory comments at both max() call sites (commit a7f0894):

@copilot This is OK but I expected to have to approve the commit.

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

Added explanatory comments at both max() call sites (commit a7f0894):

@copilot This is OK but I expected to h...

As a coding agent, I commit and push changes directly when making edits — there's no approval step in between. If you'd prefer to review proposed changes before they're committed, you can describe what you'd like in a comment and I'll outline the changes first before applying them.

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

4 participants