From dbd1d343e8a27e97214509777d89d7577d40f767 Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Thu, 7 Sep 2023 14:14:56 +0200 Subject: [PATCH] Avoid adding/substracting GCONSUMP values per MPI process.. --- .../wells/BlackoilWellModelGeneric.cpp | 2 +- opm/simulators/wells/WellGroupHelpers.cpp | 17 ++++++++++------- opm/simulators/wells/WellGroupHelpers.hpp | 3 ++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index cbad29c19..9e3bf5a09 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -947,7 +947,7 @@ updateAndCommunicateGroupData(const int reportStepIdx, std::vector groupTargetReductionInj(numPhases(), 0.0); WellGroupHelpers::updateGroupTargetReduction(fieldGroup, schedule(), reportStepIdx, /*isInjector*/ true, phase_usage_, guideRate_, well_state, this->groupState(), groupTargetReductionInj); - WellGroupHelpers::updateREINForGroups(fieldGroup, schedule(), reportStepIdx, phase_usage_, summaryState_, well_state_nupcol, this->groupState()); + WellGroupHelpers::updateREINForGroups(fieldGroup, schedule(), reportStepIdx, phase_usage_, summaryState_, well_state_nupcol, this->groupState(), comm_.rank()==0); WellGroupHelpers::updateVREPForGroups(fieldGroup, schedule(), reportStepIdx, well_state_nupcol, this->groupState()); WellGroupHelpers::updateReservoirRatesInjectionGroups(fieldGroup, schedule(), reportStepIdx, well_state_nupcol, this->groupState()); diff --git a/opm/simulators/wells/WellGroupHelpers.cpp b/opm/simulators/wells/WellGroupHelpers.cpp index bfbfe3185..5313f2e49 100644 --- a/opm/simulators/wells/WellGroupHelpers.cpp +++ b/opm/simulators/wells/WellGroupHelpers.cpp @@ -657,12 +657,13 @@ namespace WellGroupHelpers const PhaseUsage& pu, const SummaryState& st, const WellState& wellState, - GroupState& group_state) + GroupState& group_state, + bool sum_rank) { const int np = wellState.numPhases(); for (const std::string& groupName : group.groups()) { const Group& groupTmp = schedule.getGroup(groupName, reportStepIdx); - updateREINForGroups(groupTmp, schedule, reportStepIdx, pu, st, wellState, group_state); + updateREINForGroups(groupTmp, schedule, reportStepIdx, pu, st, wellState, group_state, sum_rank); } std::vector rein(np, 0.0); @@ -671,11 +672,13 @@ namespace WellGroupHelpers } // add import rate and subtract consumption rate for group for gas - if (schedule[reportStepIdx].gconsump().has(group.name())) { - const auto& gconsump = schedule[reportStepIdx].gconsump().get(group.name(), st); - if (pu.phase_used[BlackoilPhases::Vapour]) { - rein[pu.phase_pos[BlackoilPhases::Vapour]] += gconsump.import_rate; - rein[pu.phase_pos[BlackoilPhases::Vapour]] -= gconsump.consumption_rate; + if (sum_rank) { + if (schedule[reportStepIdx].gconsump().has(group.name())) { + const auto& gconsump = schedule[reportStepIdx].gconsump().get(group.name(), st); + if (pu.phase_used[BlackoilPhases::Vapour]) { + rein[pu.phase_pos[BlackoilPhases::Vapour]] += gconsump.import_rate; + rein[pu.phase_pos[BlackoilPhases::Vapour]] -= gconsump.consumption_rate; + } } } diff --git a/opm/simulators/wells/WellGroupHelpers.hpp b/opm/simulators/wells/WellGroupHelpers.hpp index d2fd309d5..c48862db1 100644 --- a/opm/simulators/wells/WellGroupHelpers.hpp +++ b/opm/simulators/wells/WellGroupHelpers.hpp @@ -179,7 +179,8 @@ namespace WellGroupHelpers const PhaseUsage& pu, const SummaryState& st, const WellState& wellState, - GroupState& group_state); + GroupState& group_state, + bool sum_rank); template void updateGpMaintTargetForGroups(const Group& group,