Skip to content

feat: Adding flow statistics for arbitrary mesh cell element sets#4005

Open
MelReyCG wants to merge 31 commits intobugfix/rey/split-statistics-componentsfrom
feature/rey/arbitrary-regions-stats
Open

feat: Adding flow statistics for arbitrary mesh cell element sets#4005
MelReyCG wants to merge 31 commits intobugfix/rey/split-statistics-componentsfrom
feature/rey/arbitrary-regions-stats

Conversation

@MelReyCG
Copy link
Copy Markdown
Contributor

@MelReyCG MelReyCG commented Mar 26, 2026

This PR aims at extending the flow statistics components by introducing an optional setNames parameter to SinglePhaseStatistics and CompositionalMultiphaseStatistics, allowing users to obtain statistics computation from arbitrary mesh element sets instead of being forced to process solver regions.

Sets can already be defined with Geometry objects like Box.

Multiple set can be provided for a given statistics component, and in that case, statistics over all provided sets are also logged. To support intersecting sets and give valid statistics, they are computed on a compound set (union of all selected set).
Here is an example:

    <!-- stats table to compare the domain element set with the well surroundings element set -->
    <CompositionalMultiphaseStatistics 
      name="domainAndInjectorFlowStats"
      flowSolverName="compositionalMultiphaseFlow"
      setNames="{all, injectorSurrounding}"
      logLevel="1"
      writeCSV="1"/>
--------------------------------------------------------------------------------------------------------------
|                  Statistics: domainAndInjectorFlowStats / Discretization: fluidTPFA                        |
|------------------------------------------------------------------------------------------------------------|
|                         Statistics time  |                                                      496000000  |
|------------------------------------------------------------------------------------------------------------|
|                                                                                                            |
|                                               Discretization: 'fluidTPFA' / Selected sets (7500 elements)  |
|------------------------------------------------------------------------------------------------------------|
|                              statistics  |            min  |                average  |                max  |
|------------------------------------------|-----------------|-------------------------|---------------------|
|                           Pressure [Pa]  |   39856089.824  |                  7.599  |       51367844.277  |
|                     Delta pressure [Pa]  |   27356089.824  |                      /  |       38867844.277  |
|                         Temperature [K]  |         368.15  |              6.135e-05  |             368.15  |
|------------------------------------------|-----------------|-----------------------------------------------|
|         Total dynamic pore volume [rm3]  |            all  |                                  6096116.064  |
|         Phase dynamic pore volume [rm3]  |            gas  |                                       119209  |
|                                          |          water  |                                  5.97691e+06  |
|------------------------------------------|-----------------|-----------------------------------------------|
|                   Total fluid mass [kg]  |            all  |                               5978216181.947  |
|                         Phase mass [kg]  |            gas  |                                  9.50193e+07  |
|                                          |          water  |                                   5.8832e+09  |
|------------------------------------------|-----------------|-----------------------------------------------|
|      Trapped phase mass (metric 1) [kg]  |            gas  |                                  4.71814e+07  |
|                                          |          water  |                                  1.80049e+09  |
|  Non-trapped phase mass (metric 1) [kg]  |            gas  |                                  4.78379e+07  |
|                                          |          water  |                                  4.08271e+09  |
|------------------------------------------|-----------------|-----------------------------------------------|
|     Immobile phase mass (metric 2) [kg]  |            gas  |                                            0  |
|                                          |          water  |                                            0  |
|       Mobile phase mass (metric 2) [kg]  |            gas  |                                  9.50193e+07  |
|                                          |          water  |                                   5.8832e+09  |
|------------------------------------------|-----------------|-----------------------------------------------|
|                     Component mass [kg]  |      gas / co2  |                                  9.50193e+07  |
|                                          |    gas / water  |                                            0  |
|                                          |    water / co2  |                                  7.33584e+07  |
|                                          |  water / water  |                                  5.80984e+09  |
|------------------------------------------------------------------------------------------------------------|
|                                                                                                            |
|                                          Discretization: 'fluidTPFA' / Element set: 'all' (7500 elements)  |
|------------------------------------------------------------------------------------------------------------|
|                              statistics  |            min  |                average  |                max  |
|------------------------------------------|-----------------|-------------------------|---------------------|
|                           Pressure [Pa]  |   39856089.824  |           45598543.119  |       51367844.277  |
|                     Delta pressure [Pa]  |   27356089.824  |                      /  |       38867844.277  |
|                         Temperature [K]  |         368.15  |                368.149  |             368.15  |
|------------------------------------------|-----------------|-----------------------------------------------|
|         Total dynamic pore volume [rm3]  |            all  |                                  6096116.064  |
|         Phase dynamic pore volume [rm3]  |            gas  |                                       119209  |
|                                          |          water  |                                  5.97691e+06  |
|------------------------------------------|-----------------|-----------------------------------------------|
|                   Total fluid mass [kg]  |            all  |                               5978216181.947  |
|                         Phase mass [kg]  |            gas  |                                  9.50193e+07  |
|                                          |          water  |                                   5.8832e+09  |
|------------------------------------------|-----------------|-----------------------------------------------|
|      Trapped phase mass (metric 1) [kg]  |            gas  |                                  4.71814e+07  |
|                                          |          water  |                                  1.80049e+09  |
|  Non-trapped phase mass (metric 1) [kg]  |            gas  |                                  4.78379e+07  |
|                                          |          water  |                                  4.08271e+09  |
|------------------------------------------|-----------------|-----------------------------------------------|
|     Immobile phase mass (metric 2) [kg]  |            gas  |                                            0  |
|                                          |          water  |                                            0  |
|       Mobile phase mass (metric 2) [kg]  |            gas  |                                  9.50193e+07  |
|                                          |          water  |                                   5.8832e+09  |
|------------------------------------------|-----------------|-----------------------------------------------|
|                     Component mass [kg]  |      gas / co2  |                                  9.50193e+07  |
|                                          |    gas / water  |                                            0  |
|                                          |    water / co2  |                                  7.33584e+07  |
|                                          |  water / water  |                                  5.80984e+09  |
|------------------------------------------------------------------------------------------------------------|
|                                                                                                            |
|                            Discretization: 'fluidTPFA' / Element set: 'injectorSurrounding' (25 elements)  |
|------------------------------------------------------------------------------------------------------------|
|                              statistics  |            min  |                average  |                max  |
|------------------------------------------|-----------------|-------------------------|---------------------|
|                           Pressure [Pa]  |   50203624.560  |           50359670.971  |       50515575.020  |
|                     Delta pressure [Pa]  |   37703624.560  |                      /  |       38015575.020  |
|                         Temperature [K]  |         368.15  |      368.1499906997449  |             368.15  |
|------------------------------------------|-----------------|-----------------------------------------------|
|         Total dynamic pore volume [rm3]  |            all  |                                    20363.237  |
|         Phase dynamic pore volume [rm3]  |            gas  |                                      1199.65  |
|                                          |          water  |                                      19163.6  |
|------------------------------------------|-----------------|-----------------------------------------------|
|                   Total fluid mass [kg]  |            all  |                                 20103033.517  |
|                         Phase mass [kg]  |            gas  |                                  1.00122e+06  |
|                                          |          water  |                                  1.91018e+07  |
|------------------------------------------|-----------------|-----------------------------------------------|
|      Trapped phase mass (metric 1) [kg]  |            gas  |                                       842127  |
|                                          |          water  |                                  6.08927e+06  |
|  Non-trapped phase mass (metric 1) [kg]  |            gas  |                                       159097  |
|                                          |          water  |                                  1.30125e+07  |
|------------------------------------------|-----------------|-----------------------------------------------|
|     Immobile phase mass (metric 2) [kg]  |            gas  |                                            0  |
|                                          |          water  |                                            0  |
|       Mobile phase mass (metric 2) [kg]  |            gas  |                                  1.00122e+06  |
|                                          |          water  |                                  1.91018e+07  |
|------------------------------------------|-----------------|-----------------------------------------------|
|                     Component mass [kg]  |      gas / co2  |                                  1.00122e+06  |
|                                          |    gas / water  |                                            0  |
|                                          |    water / co2  |                                  1.18866e+06  |
|                                          |  water / water  |                                  1.79132e+07  |
--------------------------------------------------------------------------------------------------------------

The infrastructure proposed here can be re-used for new statistics components which would process cell elements, and is implemented at the StatisticsAggregatorBase level, introduced in the PR #3836 .

The parameter has been used in the simpleCo2InjTutorial example to test that functionnality.

@MelReyCG MelReyCG changed the title feat: Adding statistics for given mesh element sets feat: Adding flow statistics for arbitrary mesh element sets Mar 26, 2026
@MelReyCG MelReyCG changed the title feat: Adding flow statistics for arbitrary mesh element sets feat: Adding flow statistics for arbitrary mesh cell element sets Apr 1, 2026
Copy link
Copy Markdown
Contributor

@dkachuma dkachuma left a comment

Choose a reason for hiding this comment

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

Very useful feature.
But I would keep it simple and have a single output for each statistics node i.e. only report the statistics for all the selected sets. This would keep the csv simple and directly loadable with numpy for plotting. If the user wants statistics for another set, they can add another statistics xml element.

TableLayout tableLayout( {
TableLayout::Column( GEOS_FMT( "Time [{}]", units::getSymbol( units::Unit::Time ))),
TableLayout::Column( "Region" ), // TODO : mention this change in PR description
TableLayout::Column( "Set" ),
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.

Does that mean all the sets have data written in the same csv? Usually we want to plot these values and having to filter per set is quite tedious. Can we have a separate file for each set?

Copy link
Copy Markdown
Contributor Author

@MelReyCG MelReyCG Apr 7, 2026

Choose a reason for hiding this comment

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

Separating in per-set files is not an issue, I would just like to ask why it is problematic to have every sets in one file, and not problematic to have every region in one file. Because of the post-processing / paraview tools?
I remember that at some point we had one CSV for all region, sometimes resulting in a lot of files, and I got asked to merge them in one file.

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.

I didn't realise we also have different regions in the same file. I always assumed the statistics are written out to a different file per region. I didn't know these had ben merged. With different files way it was easy to load and plot for each region. Of course we can always filter if need be.

@MelReyCG MelReyCG added the flag: requires rebaseline Requires rebaseline branch in integratedTests label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants