TargetCalculator: move to namespace Opm::WGHelpers

This commit is contained in:
Arne Morten Kvarving
2024-02-19 12:18:22 +01:00
parent 9a42b70f20
commit 6197aab409
6 changed files with 120 additions and 53 deletions

View File

@@ -30,7 +30,7 @@
#include <cassert>
namespace Opm::WellGroupHelpers {
namespace Opm::WGHelpers {
FractionCalculator::FractionCalculator(const Schedule& schedule,
const WellState<double>& well_state,

View File

@@ -32,7 +32,7 @@ class Schedule;
template<class Scalar> class WellState;
}
namespace Opm::WellGroupHelpers {
namespace Opm::WGHelpers {
class FractionCalculator
{
@@ -72,6 +72,6 @@ private:
Phase injection_phase_;
};
} // namespace Opm::WellGroupHelpers
} // namespace Opm::WGHelpers
#endif // OPM_FRACTION_CALCULATOR_HEADER_INCLUDED

View File

@@ -26,16 +26,10 @@
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/wells/GroupState.hpp>
#include <algorithm>
#include <cassert>
#include <stdexcept>
#include <type_traits>
namespace Opm
{
namespace WellGroupHelpers
{
namespace Opm::WGHelpers {
TargetCalculator::TargetCalculator(const Group::ProductionCMode cmode,
const PhaseUsage& pu,
@@ -279,6 +273,4 @@ INSTANCE_TARGET_CALCULATOR(DenseAd::Evaluation<double,-1,9>)
INSTANCE_TARGET_CALCULATOR(DenseAd::Evaluation<double,-1,10>)
INSTANCE_TARGET_CALCULATOR(DenseAd::Evaluation<double,-1,11>)
} // namespace WellGroupHelpers
} // namespace Opm
} // namespace Opm::WGHelpers

View File

@@ -34,7 +34,7 @@ class DeferredLogger;
template<class Scalar> class GroupState;
struct PhaseUsage;
namespace WellGroupHelpers {
namespace WGHelpers {
/// Based on a group control mode, extract or calculate rates, and
/// provide other conveniences.
@@ -109,7 +109,7 @@ private:
GuideRateModel::Target target_;
};
} // namespace WellGroupHelpers
} // namespace WGHelpers
} // namespace Opm

View File

@@ -136,17 +136,27 @@ getGroupInjectionControl(const Group& group,
const auto& gconsale = schedule[well_.currentStep()].gconsale().get(group.name(), summaryState);
sales_target = gconsale.sales_target;
}
WellGroupHelpers::InjectionTargetCalculator tcalc(currentGroupControl, pu,
resv_coeff, group.name(),
sales_target, group_state,
injectionPhase,
group.has_gpmaint_control(injectionPhase, currentGroupControl),
deferred_logger);
WellGroupHelpers::FractionCalculator fcalc(schedule, well_state,
group_state, well_.currentStep(),
well_.guideRate(),
tcalc.guideTargetMode(),
pu, false, injectionPhase);
WGHelpers::InjectionTargetCalculator tcalc(currentGroupControl,
pu,
resv_coeff,
group.name(),
sales_target,
group_state,
injectionPhase,
group.has_gpmaint_control(injectionPhase,
currentGroupControl),
deferred_logger);
WGHelpers::FractionCalculator fcalc(schedule,
well_state,
group_state,
well_.currentStep(),
well_.guideRate(),
tcalc.guideTargetMode(),
pu,
false,
injectionPhase);
auto localFraction = [&](const std::string& child) {
return fcalc.localFraction(child, child);
@@ -260,14 +270,26 @@ getGroupInjectionTargetRate(const Group& group,
const auto& gconsale = schedule[well_.currentStep()].gconsale().get(group.name(), summaryState);
sales_target = gconsale.sales_target;
}
WellGroupHelpers::InjectionTargetCalculator tcalc(currentGroupControl, pu, resv_coeff,
group.name(), sales_target, group_state,
injectionPhase,
group.has_gpmaint_control(injectionPhase, currentGroupControl),
deferred_logger);
WellGroupHelpers::FractionCalculator fcalc(schedule, well_state, group_state,
well_.currentStep(), well_.guideRate(),
tcalc.guideTargetMode(), pu, false, injectionPhase);
WGHelpers::InjectionTargetCalculator tcalc(currentGroupControl,
pu,
resv_coeff,
group.name(),
sales_target,
group_state,
injectionPhase,
group.has_gpmaint_control(injectionPhase,
currentGroupControl),
deferred_logger);
WGHelpers::FractionCalculator fcalc(schedule,
well_state,
group_state,
well_.currentStep(),
well_.guideRate(),
tcalc.guideTargetMode(),
pu,
false,
injectionPhase);
auto localFraction = [&](const std::string& child) {
return fcalc.localFraction(child, child); //Note child needs to be passed to always include since the global isGrup map is not updated yet.
@@ -363,15 +385,23 @@ void WellGroupControls::getGroupProductionControl(const Group& group,
if (group_state.has_grat_sales_target(group.name()))
gratTargetFromSales = group_state.grat_sales_target(group.name());
WellGroupHelpers::TargetCalculator tcalc(currentGroupControl, pu, resv_coeff,
gratTargetFromSales, group.name(),
group_state,
group.has_gpmaint_control(currentGroupControl));
WellGroupHelpers::FractionCalculator fcalc(schedule, well_state, group_state,
well_.currentStep(),
well_.guideRate(),
tcalc.guideTargetMode(),
pu, true, Phase::OIL);
WGHelpers::TargetCalculator tcalc(currentGroupControl,
pu,
resv_coeff,
gratTargetFromSales,
group.name(),
group_state,
group.has_gpmaint_control(currentGroupControl));
WGHelpers::FractionCalculator fcalc(schedule,
well_state,
group_state,
well_.currentStep(),
well_.guideRate(),
tcalc.guideTargetMode(),
pu,
true,
Phase::OIL);
auto localFraction = [&](const std::string& child) {
return fcalc.localFraction(child, child);
@@ -452,12 +482,23 @@ getGroupProductionTargetRate(const Group& group,
if (group_state.has_grat_sales_target(group.name()))
gratTargetFromSales = group_state.grat_sales_target(group.name());
WellGroupHelpers::TargetCalculator tcalc(currentGroupControl, pu, resv_coeff, gratTargetFromSales, group.name(), group_state, group.has_gpmaint_control(currentGroupControl));
WellGroupHelpers::FractionCalculator fcalc(schedule, well_state, group_state,
well_.currentStep(),
well_.guideRate(),
tcalc.guideTargetMode(),
pu, true, Phase::OIL);
WGHelpers::TargetCalculator tcalc(currentGroupControl,
pu,
resv_coeff,
gratTargetFromSales,
group.name(),
group_state,
group.has_gpmaint_control(currentGroupControl));
WGHelpers::FractionCalculator fcalc(schedule,
well_state,
group_state,
well_.currentStep(),
well_.guideRate(),
tcalc.guideTargetMode(),
pu,
true,
Phase::OIL);
auto localFraction = [&](const std::string& child) {
return fcalc.localFraction(child, child); //Note child needs to be passed to always include since the global isGrup map is not updated yet.
@@ -545,4 +586,5 @@ INSTANCE(DenseAd::Evaluation<double,-1,8u>)
INSTANCE(DenseAd::Evaluation<double,-1,9u>)
INSTANCE(DenseAd::Evaluation<double,-1,10u>)
INSTANCE(DenseAd::Evaluation<double,-1,11u>)
} // namespace Opm

View File

@@ -1165,8 +1165,23 @@ std::pair<bool, double> checkGroupConstraintsProd(const std::string& name,
if (group_state.has_grat_sales_target(group.name()))
gratTargetFromSales = group_state.grat_sales_target(group.name());
TargetCalculator tcalc(currentGroupControl, pu, resv_coeff, gratTargetFromSales, group.name(), group_state, group.has_gpmaint_control(currentGroupControl));
FractionCalculator fcalc(schedule, wellState, group_state, reportStepIdx, guideRate, tcalc.guideTargetMode(), pu, true, Phase::OIL);
WGHelpers::TargetCalculator tcalc(currentGroupControl,
pu,
resv_coeff,
gratTargetFromSales,
group.name(),
group_state,
group.has_gpmaint_control(currentGroupControl));
WGHelpers::FractionCalculator fcalc(schedule,
wellState,
group_state,
reportStepIdx,
guideRate,
tcalc.guideTargetMode(),
pu,
true,
Phase::OIL);
auto localFraction = [&](const std::string& child) { return fcalc.localFraction(child, name); };
@@ -1311,8 +1326,26 @@ std::pair<bool, double> checkGroupConstraintsInj(const std::string& name,
const auto& gconsale = schedule[reportStepIdx].gconsale().get(group.name(), summaryState);
sales_target = gconsale.sales_target;
}
InjectionTargetCalculator tcalc(currentGroupControl, pu, resv_coeff, group.name(), sales_target, group_state, injectionPhase, group.has_gpmaint_control(injectionPhase, currentGroupControl), deferred_logger);
FractionCalculator fcalc(schedule, wellState, group_state, reportStepIdx, guideRate, tcalc.guideTargetMode(), pu, false, injectionPhase);
WGHelpers::InjectionTargetCalculator tcalc(currentGroupControl,
pu,
resv_coeff,
group.name(),
sales_target,
group_state,
injectionPhase,
group.has_gpmaint_control(injectionPhase,
currentGroupControl),
deferred_logger);
WGHelpers::FractionCalculator fcalc(schedule,
wellState,
group_state,
reportStepIdx,
guideRate,
tcalc.guideTargetMode(),
pu,
false,
injectionPhase);
auto localFraction = [&](const std::string& child) { return fcalc.localFraction(child, name); };