Skip to content

Refactor GroupTreeRates to OPM style and integrate with updateWellControls#1

Draft
Copilot wants to merge 8 commits intomasterfrom
copilot/test-group-tree-solution
Draft

Refactor GroupTreeRates to OPM style and integrate with updateWellControls#1
Copilot wants to merge 8 commits intomasterfrom
copilot/test-group-tree-solution

Conversation

Copy link

Copilot AI commented Feb 28, 2026

The GroupTreeRates module used Matlab-style free functions and camelCase naming. The TODO in updateWellControls described how distributeGroupTreeRates should integrate but had no implementation.

Style refactoring (GroupTreeRates.hpp/cpp)

  • Wrapped free functions into GroupTreeRates<Scalar> class with static methods, matching OPM patterns like BlackoilWellModelConstraints
  • Renamed to snake_case: distributeGroupTreeRatesdistribute, setSubRatesset_sub_rates, findWorstOffendingChildfind_worst_offending_child, updateParentStatusupdate_parent_status
  • GroupTreeNode::guideRateguide_rate
  • OPM-style include guard, \brief/\param Doxygen tags

Integration with updateWellControls (BlackoilWellModel_impl.hpp)

  • Original function preserved as updateWellControlsOriginal
  • New updateWellControls calls original first, then implements the three TODO items:
    1. Build tree: Recursive traversal from FIELD group, populating flat GroupTreeNode vector with rate limits (from productionControls), current rates (from well/group state), and guide rates
    2. Distribute: GroupTreeRates<Scalar>::distribute(tree)
    3. Apply: Write distributed rates back to wellState().surface_rates and groupState().production_rates

Only applies to single-phase rate controls (ORAT/WRAT/GRAT); skips LRAT/RESV/FLD where the simplified distribution doesn't apply.

// Usage after refactor:
GroupTreeRates<double>::distribute(tree);
GroupTreeRates<double>::set_sub_rates(tree, 0);
GroupTreeRates<double>::find_worst_offending_child(tree, 0, excess);
GroupTreeRates<double>::update_parent_status(tree, idx);

Tests

  • All 16 existing test cases updated to class-based API; no behavioral changes.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 28, 2026 21:54
Implements the group-tree rate distribution algorithm as standalone functions:
- distributeGroupTreeRates: Main iterative rate balancing
- setSubRates: Top-down guide-rate based distribution
- findWorstOffendingChild: Find worst limit violation in subtree
- updateParentStatus: Bottom-up status propagation

Includes comprehensive unit tests covering unconstrained trees,
single-well limits, group limit violations, cascading violations,
and deep tree hierarchies.

Co-authored-by: steink <6746854+steink@users.noreply.github.com>
…variable

Co-authored-by: steink <6746854+steink@users.noreply.github.com>
Co-authored-by: steink <6746854+steink@users.noreply.github.com>
Copilot AI changed the title [WIP] Add functionality to test group-tree convergence Add standalone GroupTreeRates module for iterative group-tree rate distribution Feb 28, 2026
Copilot AI and others added 2 commits March 2, 2026 13:11
…pdateWellControls

- Wrap free functions into GroupTreeRates<Scalar> class with static methods
- Rename to snake_case: distributeGroupTreeRates -> distribute,
  setSubRates -> set_sub_rates, findWorstOffendingChild ->
  find_worst_offending_child, updateParentStatus -> update_parent_status
- Rename struct member: guideRate -> guide_rate
- Use OPM-style include guard and Doxygen documentation
- Add include and integration comment in BlackoilWellModel_impl.hpp
  showing how distribute() fits into updateWellControls
- Update all tests to use new class-based API

Co-authored-by: steink <6746854+steink@users.noreply.github.com>
…rder

Co-authored-by: steink <6746854+steink@users.noreply.github.com>
Copilot AI changed the title Add standalone GroupTreeRates module for iterative group-tree rate distribution Refactor GroupTreeRates to OPM class-based style and show integration with updateWellControls Mar 2, 2026
Copilot AI and others added 2 commits March 2, 2026 14:15
…al as updateWellControlsOriginal

- Rename existing updateWellControls to updateWellControlsOriginal
- New updateWellControls calls updateWellControlsOriginal, then:
  1. Builds flat GroupTreeNode vector from the group hierarchy
  2. Calls GroupTreeRates<Scalar>::distribute(tree)
  3. Applies resulting rates back to well/group state
- Add updateWellControlsOriginal declaration to BlackoilWellModel.hpp

Co-authored-by: steink <6746854+steink@users.noreply.github.com>
Co-authored-by: steink <6746854+steink@users.noreply.github.com>
Copilot AI changed the title Refactor GroupTreeRates to OPM class-based style and show integration with updateWellControls Refactor GroupTreeRates to OPM style and integrate with updateWellControls Mar 2, 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.

2 participants