From b97385c96354ca5e94426a7f349df47d72f7dd2f Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Wed, 9 Dec 2020 12:29:56 +0100 Subject: [PATCH] Fix and move changes to commented code to code to WellGroupHlper.hpp --- opm/simulators/wells/WellGroupHelpers.cpp | 48 ++++++++--------------- opm/simulators/wells/WellGroupHelpers.hpp | 11 +++++- opm/simulators/wells/WellState.hpp | 7 ++++ 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/opm/simulators/wells/WellGroupHelpers.cpp b/opm/simulators/wells/WellGroupHelpers.cpp index 02ce2c764..cc807145a 100644 --- a/opm/simulators/wells/WellGroupHelpers.cpp +++ b/opm/simulators/wells/WellGroupHelpers.cpp @@ -112,15 +112,6 @@ namespace WellGroupHelpers schedule.getGroup(group.parent(), reportStepIdx), schedule, reportStepIdx, factor); } - bool wellIsOwned(std::size_t well_index, [[maybe_unused]] const std::string& wellName, - const WellStateFullyImplicitBlackoil& wellState) - { - const auto& well_info = wellState.parallelWellInfo(well_index); - assert(well_info.name() == wellName); - - return well_info.isOwner(); - } - double sumWellPhaseRates(const std::vector& rates, const Group& group, const Schedule& schedule, @@ -144,7 +135,7 @@ namespace WellGroupHelpers int well_index = it->second[0]; - if (! wellIsOwned(well_index, wellName, wellState) ) // Only sum once + if (! wellState.wellIsOwned(well_index, wellName) ) // Only sum once { continue; } @@ -209,7 +200,7 @@ namespace WellGroupHelpers int well_index = it->second[0]; - if (! wellIsOwned(well_index, wellName, wellState) ) // Only sum once + if (! wellState.wellIsOwned(well_index, wellName) ) // Only sum once { continue; } @@ -323,7 +314,7 @@ namespace WellGroupHelpers int well_index = it->second[0]; - if (! wellIsOwned(well_index, wellName, wellState) ) // Only sum once + if (! wellState.wellIsOwned(well_index, wellName) ) // Only sum once { continue; } @@ -462,27 +453,22 @@ namespace WellGroupHelpers double waterpot = 0.0; const auto& it = wellState.wellMap().find( well.name()); - if (it == end) // the well is not found - continue; - int well_index = it->second[0]; - - if (! wellIsOwned(well_index, wellName, wellState) ) // Only sum once + if (it != end && wellState.wellIsOwned(it->second[0], well.name())) { - continue; + // the well is found and owned + + const auto wpot = wellState.wellPotentials().data() + well_index*wellState.numPhases(); + if (pu.phase_used[BlackoilPhases::Liquid] > 0) + oilpot = wpot[pu.phase_pos[BlackoilPhases::Liquid]]; + + if (pu.phase_used[BlackoilPhases::Vapour] > 0) + gaspot = wpot[pu.phase_pos[BlackoilPhases::Vapour]]; + + if (pu.phase_used[BlackoilPhases::Aqua] > 0) + waterpot = wpot[pu.phase_pos[BlackoilPhases::Aqua]]; + + const double wefac = well.getEfficiencyFactor(); } - - - const auto wpot = wellState.wellPotentials().data() + well_index*wellState.numPhases(); - if (pu.phase_used[BlackoilPhases::Liquid] > 0) - oilpot = wpot[pu.phase_pos[BlackoilPhases::Liquid]]; - - if (pu.phase_used[BlackoilPhases::Vapour] > 0) - gaspot = wpot[pu.phase_pos[BlackoilPhases::Vapour]]; - - if (pu.phase_used[BlackoilPhases::Aqua] > 0) - waterpot = wpot[pu.phase_pos[BlackoilPhases::Aqua]]; - - const double wefac = well.getEfficiencyFactor(); oilpot = comm.sum(oilpot) * wefac; gaspot = comm.sum(gaspot) * wefac; waterpot = comm.sum(waterpot) * wefac; diff --git a/opm/simulators/wells/WellGroupHelpers.hpp b/opm/simulators/wells/WellGroupHelpers.hpp index 5c47ab609..db2a6a260 100644 --- a/opm/simulators/wells/WellGroupHelpers.hpp +++ b/opm/simulators/wells/WellGroupHelpers.hpp @@ -160,6 +160,12 @@ namespace WellGroupHelpers continue; int well_index = it->second[0]; + + if (! wellState.wellIsOwned(well_index, wellName) ) // Only sum once + { + continue; + } + const auto wellrate_index = well_index * wellState.numPhases(); // add contribution from wells unconditionally for (int phase = 0; phase < np; phase++) { @@ -207,8 +213,9 @@ namespace WellGroupHelpers double waterpot = 0.0; const auto& it = wellState.wellMap().find(well.name()); - if (it != end) { // the well is found - + if (it != end && wellState.wellIsOwned(it->second[0], well.name())) + { + // the well is found and owned int well_index = it->second[0]; const auto wpot = wellState.wellPotentials().data() + well_index * wellState.numPhases(); diff --git a/opm/simulators/wells/WellState.hpp b/opm/simulators/wells/WellState.hpp index 786746886..a8efbe955 100644 --- a/opm/simulators/wells/WellState.hpp +++ b/opm/simulators/wells/WellState.hpp @@ -200,6 +200,13 @@ namespace Opm return *parallel_well_info_[well_index]; } + bool wellIsOwned(std::size_t well_index, [[maybe_unused]] const std::string& wellName) const + { + const auto& well_info = parallelWellInfo(well_index); + assert(well_info.name() == wellName); + + return well_info.isOwner(); + } /// The number of wells present. int numWells() const {