mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
some cleanup from review
This commit is contained in:
@@ -77,11 +77,11 @@ Scalar FractionCalculator<Scalar>::
|
||||
localFraction(const std::string& name,
|
||||
const std::string& always_included_child)
|
||||
{
|
||||
bool only_use_potentials = false;
|
||||
const Scalar my_guide_rate = guideRate(name, always_included_child, only_use_potentials);
|
||||
bool always_use_potentials = false;
|
||||
const Scalar my_guide_rate = guideRate(name, always_included_child, always_use_potentials);
|
||||
|
||||
const Group& parent_group = schedule_.getGroup(parent(name), report_step_);
|
||||
const auto [total_guide_rate, num_active_groups] = guideRateSum(parent_group, always_included_child, only_use_potentials);
|
||||
const auto [total_guide_rate, num_active_groups] = guideRateSum(parent_group, always_included_child, always_use_potentials);
|
||||
|
||||
// the group/well "name" is the only active group/well we therefore return 1 as the fraction
|
||||
// even though my_guide_rate may be zero
|
||||
@@ -91,9 +91,9 @@ localFraction(const std::string& name,
|
||||
if (total_guide_rate == 0 ) {
|
||||
// if the total guide rate is zero (for instance due to netv = 0) we use the potentials
|
||||
// to distribute the group rate
|
||||
only_use_potentials = true;
|
||||
const Scalar my_pot = guideRate(name, always_included_child, only_use_potentials);
|
||||
const Scalar my_total_pot = guideRateSum(parent_group, always_included_child, only_use_potentials).first;
|
||||
always_use_potentials = true;
|
||||
const Scalar my_pot = guideRate(name, always_included_child, always_use_potentials);
|
||||
const Scalar my_total_pot = guideRateSum(parent_group, always_included_child, always_use_potentials).first;
|
||||
return my_pot / my_total_pot;
|
||||
}
|
||||
return my_guide_rate / total_guide_rate;
|
||||
@@ -114,10 +114,10 @@ template<class Scalar>
|
||||
std::pair<Scalar, int> FractionCalculator<Scalar>::
|
||||
guideRateSum(const Group& group,
|
||||
const std::string& always_included_child,
|
||||
const bool use_potentials)
|
||||
const bool always_use_potentials)
|
||||
{
|
||||
Scalar total_guide_rate = 0.0;
|
||||
int number_of_included_well_or_group = 0;
|
||||
int number_of_included_well_or_groups = 0;
|
||||
for (const std::string& child_group : group.groups()) {
|
||||
bool included = (child_group == always_included_child);
|
||||
if (is_producer_) {
|
||||
@@ -131,9 +131,9 @@ guideRateSum(const Group& group,
|
||||
(ctrl == Group::InjectionCMode::NONE);
|
||||
}
|
||||
if (included) {
|
||||
if(groupControlledWells(child_group, always_included_child) > 0) {
|
||||
number_of_included_well_or_group++;
|
||||
total_guide_rate += guideRate(child_group, always_included_child, use_potentials);
|
||||
if (groupControlledWells(child_group, always_included_child) > 0) {
|
||||
number_of_included_well_or_groups++;
|
||||
total_guide_rate += guideRate(child_group, always_included_child, always_use_potentials);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,34 +146,34 @@ guideRateSum(const Group& group,
|
||||
included |= well_state_.isInjectionGrup(child_well);
|
||||
}
|
||||
if (included) {
|
||||
number_of_included_well_or_group++;
|
||||
total_guide_rate += guideRate(child_well, always_included_child, use_potentials);
|
||||
number_of_included_well_or_groups++;
|
||||
total_guide_rate += guideRate(child_well, always_included_child, always_use_potentials);
|
||||
}
|
||||
}
|
||||
return {total_guide_rate, number_of_included_well_or_group};
|
||||
return {total_guide_rate, number_of_included_well_or_groups};
|
||||
}
|
||||
|
||||
template<class Scalar>
|
||||
Scalar FractionCalculator<Scalar>::
|
||||
guideRate(const std::string& name,
|
||||
const std::string& always_included_child,
|
||||
const bool use_potentials)
|
||||
const bool always_use_potentials)
|
||||
{
|
||||
if (schedule_.hasWell(name, report_step_)) {
|
||||
return WellGroupHelpers<Scalar>::getGuideRate(name, schedule_, well_state_, group_state_,
|
||||
report_step_, guide_rate_, target_, pu_);
|
||||
} else {
|
||||
if (groupControlledWells(name, always_included_child) > 0) {
|
||||
if (is_producer_ && guide_rate_->has(name) && !use_potentials) {
|
||||
if (is_producer_ && guide_rate_->has(name) && !always_use_potentials) {
|
||||
return guide_rate_->get(name, target_, getGroupRateVector(name));
|
||||
} else if (!is_producer_ && guide_rate_->has(name, injection_phase_) && !use_potentials) {
|
||||
} else if (!is_producer_ && guide_rate_->has(name, injection_phase_) && !always_use_potentials) {
|
||||
return guide_rate_->get(name, injection_phase_);
|
||||
} else {
|
||||
// We are a group, with default guide rate.
|
||||
// Compute guide rate by accumulating our children's guide rates.
|
||||
const Group& group = schedule_.getGroup(name, report_step_);
|
||||
const double eff = group.getGroupEfficiencyFactor();
|
||||
return eff * guideRateSum(group, always_included_child, use_potentials).first;
|
||||
return eff * guideRateSum(group, always_included_child, always_use_potentials).first;
|
||||
}
|
||||
} else {
|
||||
// No group-controlled subordinate wells.
|
||||
|
||||
@@ -56,12 +56,15 @@ public:
|
||||
|
||||
private:
|
||||
std::string parent(const std::string& name);
|
||||
|
||||
// returns the sum of the guiderates of the given group
|
||||
// and the number of sub-groups/wells that contributed to the sum
|
||||
std::pair<Scalar,int> guideRateSum(const Group& group,
|
||||
const std::string& always_included_child,
|
||||
const bool use_potentials);
|
||||
const bool always_use_potentials);
|
||||
Scalar guideRate(const std::string& name,
|
||||
const std::string& always_included_child,
|
||||
const bool use_potentials);
|
||||
const bool always_use_potentials);
|
||||
int groupControlledWells(const std::string& group_name,
|
||||
const std::string& always_included_child);
|
||||
GuideRate::RateVector getGroupRateVector(const std::string& group_name);
|
||||
|
||||
@@ -325,6 +325,7 @@ updateGuideRatesForInjectionGroups(const Group& group,
|
||||
break;
|
||||
}
|
||||
case Group::GuideRateInjTarget::RESV:
|
||||
OPM_DEFLOG_THROW(std::runtime_error, "GUIDE PHASE RESV not implemented. Group " + group.name(), deferred_logger);
|
||||
case Group::GuideRateInjTarget::NO_GUIDE_RATE:
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user