Skip to content

feat: Split statistics components computation & output#3836

Open
MelReyCG wants to merge 310 commits intodevelopfrom
bugfix/rey/split-statistics-components
Open

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

Conversation

@MelReyCG
Copy link
Contributor

@MelReyCG MelReyCG commented Sep 26, 2025

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 statistics component, and also aims at avoiding to recompute the same statistics for a given timestep.

To achieve these goals, I separated 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)
         |      |       |-> flowStats : Group (storage for this instance stats)
         |      |       |   |-> 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.

amandinehry and others added 30 commits June 12, 2025 11:38
… + methods reanming + switch the streamMultilineYamlAttribute() method to private
…dToMsg method which takes an std::exception + add a boolean toEnd in the addToMsg methods
…ethod because this code is already exception-free
@MelReyCG MelReyCG self-assigned this Mar 2, 2026
@MelReyCG MelReyCG marked this pull request as ready for review March 2, 2026 17:21
@MelReyCG MelReyCG changed the title [DRAFT] Split statistics components computation & output feat: Split statistics components computation & output Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants