Skip to content

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

Open
MelReyCG wants to merge 38 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 38 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.

MelReyCG and others added 4 commits April 8, 2026 14:46
- Add an inError parameter to basicCleanup, cleanupEnvironment, finalizeMPI, and MpiWrapper::finalize to distinguish normal vs. error shutdown and adjusting MPI finalization behavior, preventing any MPI infinite hanging.
- Avoid normal MPI finalization/reporting on error paths (terminate via the error handler instead) to prevent collective/finalize hangs.
- Update main entrypoints and a broad set of unit/integration tests to use the new cleanup signatures.
…onents' into feature/rey/arbitrary-regions-stats
@MelReyCG MelReyCG added the flag: requires rebaseline Requires rebaseline branch in integratedTests label Apr 8, 2026
castelletto1 and others added 6 commits April 8, 2026 13:18
* Refactored importNodesets
* Update dfn_market meshes
* Uncrustify
* Replace bitwise AND with equality check
* Add ConstitutiveDriver base class
* Restore reactive fluid file
* Change documentation
* Fix rst
* Remove reactive driver tests
* Fix ats file
* Add step_check to test cases
* Rebaseline
* Copilot comments
* Update PR #3883 entry with new date and link
* Update baseline path in integrated tests configuration
* wip: balance compilation time and memory usage for MFD kernels
* Trigger CI pipeline
* Add Poisson's ratio and Young's modulus to register data fields

* Delete comments

* Change logs

* regenerate schema after adding youngModulus/poissonRatio fields to ElasticIsotropic

* Uncrustify

* Rebaseline

---------

Co-authored-by: Jian Huang <53012159+jhuang2601@users.noreply.github.com>
Co-authored-by: dkachuma <dickkachuma@googlemail.com>
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.

6 participants