Skip to content

Add Manager Class for Region Level Summary Variables - #5278

Merged
bska merged 1 commit into
OPM:masterfrom
bska:reg-var-mgr
Aug 17, 2026
Merged

Add Manager Class for Region Level Summary Variables#5278
bska merged 1 commit into
OPM:masterfrom
bska:reg-var-mgr

Conversation

@bska

@bska bska commented Aug 6, 2026

Copy link
Copy Markdown
Member

This PR introduces a new manager-style class

RegionVariableCollection

which aggregates region set descriptors and variable values and distributes per-cell variable contributions to all pertinent region sets. Client code is expected to create a single object of this class and initialise it with a populated region variable mapping. Then as needed, typically at the end of every converged time step, client code is expected to perform a value accumulation as follows:

  1. Prepare this object for accumulation (prepareValueAccumulation())
  2. For each applicable variable and cell, include the per-cell contribution (addCellValue()).
  3. Commit those contributions to compute the new variable values (commitValues()).

Once commitValues() has completed, client code may retrieve those new variable values through the regionVariableValues() member function. The process of committing values may involve cross-rank MPI communication in parallel and will add to or overwrite the current values depending on whether the variable is declared cumulative.

We also include two helper functions,

  • regionSetIndex()
  • variableIndex()

which essentially just forward a query to the variable mapping object supplied as an argument. The one exception is that regionSetIndex() knows that "FIELD" is a special region set pertaining to field-level quantities and will act accordingly.

@bska bska added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Aug 6, 2026
@bska

bska commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

I'm creating this PR in draft mode because it depends on, and contains, the earlier PR #5277. I will keep the PR in a draft state until such time as it is ready for review and merging.

@bska

bska commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

jenkins build this please

Copilot AI 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.

Pull request overview

This PR adds a new Opm::RegionVariableCollection manager that owns region-set descriptors and value storage, and provides a simple accumulation workflow for region-level summary variables (including special handling for the FIELD “region set”).

Changes:

  • Introduces RegionVariableCollection with initialise(), prepareValueAccumulation(), per-cell accumulation via addCellValue(), and commitValues().
  • Adds helper lookups regionSetIndex() and variableIndex() to bridge mapping names to numeric indices (with FIELD handled specially).
  • Wires the new implementation into the build and adds a dedicated unit test suite.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.

File Description
opm/output/eclipse/RegionVariableCollection.hpp Declares the new manager API and its documentation.
opm/output/eclipse/RegionVariableCollection.cpp Implements region descriptor/value initialization and per-cell accumulation logic.
tests/test_region_variable_collection.cpp Adds unit tests covering non-cumulative/cumulative behavior across region sets and variables.
CMakeLists_files.cmake Registers the new source, public header, and test in the build.
Suppressed comments (1)

opm/output/eclipse/RegionVariableCollection.hpp:141

  • The documentation refers to addRegionValue(), but callers will be using addCellValue() on this class. This should be updated to avoid confusion.
        /// Adds increment values for cumulative quantities and overwrites
        /// current values for non-cumulative quantities.
        ///
        /// Must be called after the last call to addRegionValue().
        void commitValues();

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread opm/output/eclipse/RegionVariableCollection.hpp
Comment thread opm/output/eclipse/RegionVariableCollection.hpp Outdated
Comment thread opm/output/eclipse/RegionVariableCollection.hpp Outdated
Comment thread opm/output/eclipse/RegionVariableCollection.hpp
Comment thread opm/output/eclipse/RegionVariableCollection.cpp
Comment thread opm/output/eclipse/RegionVariableCollection.cpp Outdated
@bska

bska commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

I have addressed Copilot's initial review comments and the PR goes through a build check. I'm marking this PR as "ready for review" now.

@bska
bska marked this pull request as ready for review August 14, 2026 13:53
@bska

bska commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

jenkins build this please

@bska

bska commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

jenkins build this please

@akva2 akva2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread opm/output/eclipse/RegionVariableCollection.hpp Outdated
This commit introduces a new manager-style class

    RegionVariableCollection

which aggregates region set descriptors and variable values and
distributes per-cell variable contributions to all pertinent region
sets.  Client code is expected to create a single object of this
class and initialise it with a populated region variable mapping.
Then as needed, typically at the end of every converged time step,
client code is expected to perform a value accumulation as follows:

    1. Prepare this object for accumulation (prepareValueAccumulation())
    2. For each applicable variable and cell, include the per-cell
       contribution (addCellValue()).
    3. Commit those contributions to compute the new variable
       values (commitValues()).

Once 'commitValues()' has completed, client code may retrieve those
new variable values through the regionVariableValues() member
function.  The process of committing values may involve cross-rank
MPI communication in parallel and will add to or overwrite the
current values depending on whether the variable is declared
cumlative.

We also include two helper functions,

    regionSetIndex()
    variableIndex()

which essentially just forward a query to the variable mapping
object supplied as an argument.  The one exception is that
regionSetIndex() knows that "FIELD" is a special region set
pertaining to field-level quantities and will act accordingly.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@bska

bska commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

jenkins build this please

@bska

bska commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

PR approved and build check is green. I'll merge into master.

@bska
bska merged commit 6f4a1dd into OPM:master Aug 17, 2026
2 checks passed
@bska
bska deleted the reg-var-mgr branch August 17, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual:irrelevant This PR is a minor fix and should not appear in the manual

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants