Check phase activity before querying active phase index

when calculating the group injecting VREP target.
This commit is contained in:
Kai Bao committed 2026-01-12 22:56:14 +01:00
1 parent c8045c9998
commit 29f747f079
1 file changed
+3 -3
+3 -3
View File
@@ -487,15 +487,15 @@ getInjectionGroupTarget(
const std::vector<Scalar>& group_injection_reservoir_rates =
this->groupState().injection_reservoir_rates(group.name());
Scalar voidage_rate = this->groupState().injection_vrep_rate(ctrl.voidage_group) * ctrl.target_void_fraction;
if (ctrl.phase != Phase::WATER) {
if (ctrl.phase != Phase::WATER && pu.phaseIsActive(IndexTraits::waterPhaseIdx)) {
const int water_pos = pu.canonicalToActivePhaseIdx(IndexTraits::waterPhaseIdx);
voidage_rate -= group_injection_reservoir_rates[water_pos];
}
if (ctrl.phase != Phase::OIL) {
if (ctrl.phase != Phase::OIL && pu.phaseIsActive(IndexTraits::oilPhaseIdx)) {
const int oil_pos = pu.canonicalToActivePhaseIdx(IndexTraits::oilPhaseIdx);
voidage_rate -= group_injection_reservoir_rates[oil_pos];
}
if (ctrl.phase != Phase::GAS) {
if (ctrl.phase != Phase::GAS && pu.phaseIsActive(IndexTraits::gasPhaseIdx)) {
const int gas_pos = pu.canonicalToActivePhaseIdx(IndexTraits::gasPhaseIdx);
voidage_rate -= group_injection_reservoir_rates[gas_pos];
}