Centralize Rate Vector Derivation for Guide Rates

This commit creates a single implementation function for deriving
'RateVector' objects that go into the guiderate calculation.  In
particular, we now use the same implementation function for both the
well and the group levels.  While here, also expose the group level
derivation as a free function and reimplement the FractionCalculator
version in terms of this free function.  Finally, remove the
previous attempt at such a free function taking only the group name.
This function no longer exists in isolation and is only accessible
through the FractionCalculator.

This is in preparation of reporting guiderate values to the output
layer (summary and restart files).
This commit is contained in:
Bård Skaflestad 2020-07-20 17:00:00 +02:00
parent 3c91761999
commit e1ce1c9124
2 changed files with 31 additions and 32 deletions

View File

@ -24,6 +24,28 @@
#include <algorithm>
#include <vector>
namespace {
Opm::GuideRate::RateVector
getGuideRateVector(const std::vector<double>& rates, const Opm::PhaseUsage& pu)
{
using Opm::BlackoilPhases;
double oilRate = 0.0;
if (pu.phase_used[BlackoilPhases::Liquid])
oilRate = rates[pu.phase_pos[BlackoilPhases::Liquid]];
double gasRate = 0.0;
if (pu.phase_used[BlackoilPhases::Vapour])
gasRate = rates[pu.phase_pos[BlackoilPhases::Vapour]];
double waterRate = 0.0;
if (pu.phase_used[BlackoilPhases::Aqua])
waterRate = rates[pu.phase_pos[BlackoilPhases::Aqua]];
return {oilRate, gasRate, waterRate};
}
} // namespace Anonymous
namespace Opm
{
@ -566,22 +588,14 @@ namespace WellGroupHelpers
GuideRate::RateVector
getRateVector(const WellStateFullyImplicitBlackoil& well_state, const PhaseUsage& pu, const std::string& name)
{
const std::vector<double>& rates = well_state.currentWellRates(name);
double oilRate = 0.0;
if (pu.phase_used[BlackoilPhases::Liquid])
oilRate = rates[pu.phase_pos[BlackoilPhases::Liquid]];
double gasRate = 0.0;
if (pu.phase_used[BlackoilPhases::Vapour])
gasRate = rates[pu.phase_pos[BlackoilPhases::Vapour]];
double waterRate = 0.0;
if (pu.phase_used[BlackoilPhases::Aqua])
waterRate = rates[pu.phase_pos[BlackoilPhases::Aqua]];
return GuideRate::RateVector {oilRate, gasRate, waterRate};
return getGuideRateVector(well_state.currentWellRates(name), pu);
}
GuideRate::RateVector
getProductionGroupRateVector(const WellStateFullyImplicitBlackoil& well_state, const PhaseUsage& pu, const std::string& group_name)
{
return getGuideRateVector(well_state.currentProductionGroupRates(group_name), pu);
}
double getGuideRate(const std::string& name,
const Schedule& schedule,
@ -699,7 +713,6 @@ namespace WellGroupHelpers
return num_wells;
}
FractionCalculator::FractionCalculator(const Schedule& schedule,
const WellStateFullyImplicitBlackoil& well_state,
const int report_step,
@ -791,21 +804,7 @@ namespace WellGroupHelpers
GuideRate::RateVector FractionCalculator::getGroupRateVector(const std::string& group_name)
{
std::vector<double> groupRates = well_state_.currentProductionGroupRates(group_name);
double oilRate = 0.0;
if (pu_.phase_used[BlackoilPhases::Liquid])
oilRate = groupRates[pu_.phase_pos[BlackoilPhases::Liquid]];
double gasRate = 0.0;
if (pu_.phase_used[BlackoilPhases::Vapour])
gasRate = groupRates[pu_.phase_pos[BlackoilPhases::Vapour]];
double waterRate = 0.0;
if (pu_.phase_used[BlackoilPhases::Aqua])
waterRate = groupRates[pu_.phase_pos[BlackoilPhases::Aqua]];
return GuideRate::RateVector {oilRate, gasRate, waterRate};
return getProductionGroupRateVector(this->well_state_, this->pu_, group_name);
}

View File

@ -261,6 +261,8 @@ namespace WellGroupHelpers
GuideRate::RateVector
getRateVector(const WellStateFullyImplicitBlackoil& well_state, const PhaseUsage& pu, const std::string& name);
GuideRate::RateVector
getProductionGroupRateVector(const WellStateFullyImplicitBlackoil& well_state, const PhaseUsage& pu, const std::string& group_name);
double getGuideRate(const std::string& name,
const Schedule& schedule,
@ -280,7 +282,6 @@ namespace WellGroupHelpers
const Phase& injectionPhase,
const PhaseUsage& pu);
int groupControlledWells(const Schedule& schedule,
const WellStateFullyImplicitBlackoil& well_state,
const int report_step,
@ -314,7 +315,6 @@ namespace WellGroupHelpers
PhaseUsage pu_;
};
GuideRate::RateVector getGroupRateVector(const std::string& group_name);
double fractionFromGuideRates(const std::string& name,