Skip to content

Reservoir coupling: Send slave group rates to master after initial well solve#6934

Draft
hakonhagland wants to merge 4 commits intoOPM:masterfrom
hakonhagland:send_sg_rates
Draft

Reservoir coupling: Send slave group rates to master after initial well solve#6934
hakonhagland wants to merge 4 commits intoOPM:masterfrom
hakonhagland:send_sg_rates

Conversation

@hakonhagland
Copy link
Contributor

Builds on #6931.

Complete the two-round reservoir coupling protocol in beginTimeStep().

  • Slave well solve under new constraints: Add slave_needs_well_solution flag, set when constraints are received from the master. This makes all wells enter the existing solve loop (line 516), reusing the scaleSegmentRatesAndPressuresolveWellEquation sequence without code duplication.
  • Slave Round 2 send: After the well solve, call updateAndCommunicateGroupData(false) to refresh stale GroupState caches (surface rates, injection rates, voidage rate, etc.), then sendSlaveGroupDataToMaster().
  • Master Round 2 receive: Add receiveSlaveGroupData() after sendMasterGroupConstraintsToSlaves(). Round 2 data overwrites Round 1 in the same map; MPI FIFO ordering guarantees correct matching.

The master's constraint calculator could propagate derived injection
cmodes (REIN, VREP, RESV) to the slave, but the slave cannot evaluate
these locally because it lacks the master's schedule data (reinj_group,
voidage_group, GCONSUMP, etc.). This caused a map::at crash in
updateWsolvent() when the slave tried to read gas injection controls
from its local schedule.

Always convert injection cmodes to RATE when sending to the slave,
since the numeric target is already a surface rate for all modes.

Also return the minimum of the top-level distributed target and the
bottom group's own target in calculateGroupConstraint(). Previously,
when the bottom group's rate was below the top-level target, the
group's own (potentially larger) target was returned, allowing the
slave to overshoot the master's budget during independent substeps.
PR OPM#6596 introduced updateNONEProductionGroups() which resets
production control to NONE for groups not targeted by any well.
On an RC master (no local wells), this incorrectly resets ALL
groups including FIELD and the master group hierarchy, causing
a crash in getProductionGroupTargetForMode() at the next report
step when the constraint calculator encounters NONE control on
FIELD.

Move updateNONEProductionGroups() from BlackoilWellModelGeneric
to GroupStateHelper, which has access to the rescoup_ proxy.
Add an exception for RC master hierarchy groups (master groups
and their ancestors up to FIELD) that actively distribute
targets to slave groups via the guide-rate hierarchy.
Consolidate 4 scattered #ifdef RESERVOIR_COUPLING_ENABLED
blocks into a single block at the end of the private
section. This reduces ifdef clutter and makes it clear
which methods are RC-specific.
Complete the two-round coupling protocol: after receiving constraints
from the master, the slave solves all wells under the new targets,
refreshes group state caches, and sends the updated flow rates back
to the master.

Changes in beginTimeStep():
- Add slave_needs_well_solution flag so all wells enter
  the existing solve loop on coupling timesteps
- Slave: updateAndCommunicateGroupData + send after solve
  (Round 2 send)
- Master: receiveSlaveGroupData after sending constraints
  (Round 2 receive)
@hakonhagland hakonhagland added the manual:irrelevant This PR is a minor fix and should not appear in the manual label Mar 13, 2026
@hakonhagland hakonhagland marked this pull request as draft March 13, 2026 06:42
@hakonhagland
Copy link
Contributor Author

Putting this in draft mode until #6931 has been merged.

@hakonhagland
Copy link
Contributor Author

jenkins build this serial please

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.

1 participant