Skip to content

feat: Split statistics components computation & output#3836

Open
MelReyCG wants to merge 348 commits into
developfrom
bugfix/rey/split-statistics-components
Open

feat: Split statistics components computation & output#3836
MelReyCG wants to merge 348 commits into
developfrom
bugfix/rey/split-statistics-components

Conversation

@MelReyCG

@MelReyCG MelReyCG commented Sep 26, 2025

Copy link
Copy Markdown
Contributor

Issue: #3822
On top of PR : #3829

Planned refactor: The goal is to have a way to query statistics for solver (reservoir reference pressure for wells), with a clear separation with output statistics component.

The solution proposed here aims at giving a single data storage for each component needing statistics computation. In practices, the statistics are no longer recomputed for each convergence step, but only once, at start of each iteration (it gives the same result since the operation is read only).

To achieve these goals, the PR propose to separate each roles, instead of having everything in each *PhaseStatistics class:

  • RegionStatistics classes for resulting data storages at different levels:
    • sub-regions mpi-local kernel compute read-backs,
    • (cell element) regions,
    • solver discretisation MeshLevel,
  • StatsAggregator classes to compute & reduce the statistics to rank 0, can be instanciated as solver helpers (as done for wells in the PR),
  • StatsTask Group, the user component to schedule flow statistics computation & output to log & CSV.

Old stats data architecture (stats are sticked to regions, and shared by all components):

Problem : ProblemManager
|-> domain : DomainPartition
    |-> MeshBodies : Group
        |-> cartesianMesh : MeshBody
            |-> meshLevels : Group
                |-> Level0 : MeshLevel
                |   |-> nodeManager : NodeManager
                |   |   |  * RegionStatistics (aggregate, mpi reduced)  <- stats data
                |   |   |-> sets : Group
                |   |       | * all : Wrapper< index array >
                |   |       | * xneg : Wrapper< index array >
                |   |       [...] (other element sets)
                |   |
                |   |-> ElementRegions : ElementRegionManager
                |   |   |  * RegionStatistics (aggregate, mpi reduced)  <- stats data
                |   |   |-> Channel : CellElementRegion
                |   |   |   |-> cb-0_0_0 : CellElementSubRegion
                |   |   |   |   | * pressure : Wrapper< real64 array >
                |   |   |   |   | * temperature : Wrapper< real64 array >
                |   |   |   |   | * RegionStatistics (compute read-back)  <- stats data
                |   |   |   |   [...] (other fields)
                |   |   |   |
                |   |   |   |-> cb-0_0_1 : CellElementSubRegion
                |   |   |   |   | * pressure : Wrapper< real64 array >
                |   |   |   |   | * temperature : Wrapper< real64 array >
                |   |   |   |   | * RegionStatistics (compute read-back)  <- stats data
                |   |   |   |   [...] (other fields)
                |   |   |   |
                |   |   |   [...] (other sub-regions)
                |   |   |
                |   |   |-> Barrier : CellElementRegion
                |   |       |-> cb-1_0_0 : CellElementSubRegion
                |   |       |-> cb-1_0_1 : CellElementSubRegion
                |   |       |-> * RegionStatistics (compute read-back)  <- stats data
                |   |       [...] (other sub-regions)
                |   |
                |   [...] (other element managers)
                |
                [...] (other discretizations)

Proposed new way, with a clear storage for each aggregator instance:

Problem : ProblemManager
|-> domain : DomainPartition
    |-> MeshBodies : Group
        |-> cartesianMesh : MeshBody
            |-> meshLevels : Group
                |-> Level0 : MeshLevel
                |   |-> nodeManager : NodeManager
                |   |   |-> sets : Group
                |   |       | * all : Wrapper< index array >
                |   |       | * xneg : Wrapper< index array >
                |   |       [...] (other element sets)
                |   |
                |   |-> ElementRegions : ElementRegionManager
                |   |   |-> Channel : CellElementRegion
                |   |   |   |-> cb-0_0_0 : CellElementSubRegion
                |   |   |   |   | * pressure : Wrapper< real64 array >
                |   |   |   |   | * temperature : Wrapper< real64 array >
                |   |   |   |   [...] (other fields)
                |   |   |   |
                |   |   |   |-> cb-0_0_1 : CellElementSubRegion
                |   |   |   |   | * pressure : Wrapper< real64 array >
                |   |   |   |   | * temperature : Wrapper< real64 array >
                |   |   |   |   [...] (other fields)
                |   |   |   |
                |   |   |   [...] (other sub-regions)
                |   |   |
                |   |   |-> Barrier : CellElementRegion
                |   |       |-> cb-1_0_0 : CellElementSubRegion
                |   |       |-> cb-1_0_1 : CellElementSubRegion
                |   |       [...] (other sub-regions)
                |   |
                |   [...] (other element managers)
         ____   |   |
         |      |   |-> statistics : Group (storage for all stats)
         |      |       |-> compFlowStats : Group (storage for this instance stats)
         |      |       |   |-> cflStatistics : CFLStatistics
         |      |       |   |-> regionsStatistics : RegionStatistics (aggregate)
         |      |       |       |-> Channel : RegionStatistics (aggregate, mpi reduced)
         |      |       |       |   |-> cb-0_0_0 : RegionStatistics (compute read-back)
 stats   |      |       |       |   |-> cb-0_0_1 : RegionStatistics (compute read-back)
 data -> |      |       |       |   [...] (other sub-regions stats)
         |      |       |       |
         |      |       |       |-> Barrier : RegionStatistics (aggregate, mpi reduced)
         |      |       |           |-> cb-1_0_0 : RegionStatistics (compute read-back)
         |      |       |           |-> cb-1_0_1 : RegionStatistics (compute read-back)
         |      |       |           [...] (other sub-regions stats)
         |      |       |
         |___   |       [...] (other stats storages)
                |
                [...] (other discretizations)

Decoupling the storage of the CellElementRegion will help to provide a way of obtaining statistics from arbitrary mesh regions (defined by sets for instance).


PR also propose to consolidate testFlowStatistics by also checking the total mass balance of the compositional cases.

MelReyCG and others added 30 commits August 26, 2025 16:48
…ASSERT and GEOS_THROW are now compatible with context parameters)
…file-and-structure-2' into refactor/dudes/error-context

@OmarDuran OmarDuran left a comment

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.

Thank you for separating the statistics-gathering logic from the solvers. I have left some comments for you to address.

@MelReyCG MelReyCG requested review from bd713 and jafranc as code owners April 7, 2026 15:49
@MelReyCG MelReyCG requested a review from OmarDuran April 8, 2026 16:27
@MelReyCG MelReyCG removed ci: run integrated tests Allows to run the integrated tests in GEOS CI ci: run CUDA builds Allows to triggers (costly) CUDA jobs labels Apr 8, 2026
@MelReyCG

Copy link
Copy Markdown
Contributor Author

(rebaseline is only for structural data-repository changes)

@MelReyCG MelReyCG added the ci: run integrated tests Allows to run the integrated tests in GEOS CI label May 20, 2026
@MelReyCG MelReyCG added ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run code coverage enables running of the code coverage CI jobs labels May 21, 2026
@MelReyCG MelReyCG requested a review from jhuang2601 as a code owner June 26, 2026 14:33
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: ready for review flag: requires rebaseline Requires rebaseline branch in integratedTests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants