mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
replace asserts with OPM_DEFLOG_THROW
This commit is contained in:
parent
6bac5da27c
commit
58fa3eaf31
@ -390,7 +390,7 @@ namespace Opm {
|
|||||||
|
|
||||||
void updateWellControls(Opm::DeferredLogger& deferred_logger, const bool checkGroupControls);
|
void updateWellControls(Opm::DeferredLogger& deferred_logger, const bool checkGroupControls);
|
||||||
|
|
||||||
void updateAndCommunicateGroupData();
|
void updateAndCommunicateGroupData(Opm::DeferredLogger& deferred_logger);
|
||||||
void updateNetworkPressures();
|
void updateNetworkPressures();
|
||||||
|
|
||||||
// setting the well_solutions_ based on well_state.
|
// setting the well_solutions_ based on well_state.
|
||||||
|
@ -306,7 +306,7 @@ namespace Opm {
|
|||||||
|
|
||||||
well_state_ = previous_well_state_;
|
well_state_ = previous_well_state_;
|
||||||
well_state_.disableGliftOptimization();
|
well_state_.disableGliftOptimization();
|
||||||
updateAndCommunicateGroupData();
|
updateAndCommunicateGroupData(local_deferredLogger);
|
||||||
const int reportStepIdx = ebosSimulator_.episodeIndex();
|
const int reportStepIdx = ebosSimulator_.episodeIndex();
|
||||||
const double simulationTime = ebosSimulator_.time();
|
const double simulationTime = ebosSimulator_.time();
|
||||||
int exception_thrown = 0;
|
int exception_thrown = 0;
|
||||||
@ -1225,7 +1225,7 @@ namespace Opm {
|
|||||||
// For no well active globally we simply return.
|
// For no well active globally we simply return.
|
||||||
if( !wellsActive() ) return ;
|
if( !wellsActive() ) return ;
|
||||||
|
|
||||||
updateAndCommunicateGroupData();
|
updateAndCommunicateGroupData(deferred_logger);
|
||||||
|
|
||||||
updateNetworkPressures();
|
updateNetworkPressures();
|
||||||
|
|
||||||
@ -1239,7 +1239,7 @@ namespace Opm {
|
|||||||
// Check group's constraints from higher levels.
|
// Check group's constraints from higher levels.
|
||||||
updateGroupHigherControls(deferred_logger, switched_groups);
|
updateGroupHigherControls(deferred_logger, switched_groups);
|
||||||
|
|
||||||
updateAndCommunicateGroupData();
|
updateAndCommunicateGroupData(deferred_logger);
|
||||||
|
|
||||||
// Check wells' group constraints and communicate.
|
// Check wells' group constraints and communicate.
|
||||||
for (const auto& well : well_container_) {
|
for (const auto& well : well_container_) {
|
||||||
@ -1249,7 +1249,7 @@ namespace Opm {
|
|||||||
switched_wells.insert(well->name());
|
switched_wells.insert(well->name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateAndCommunicateGroupData();
|
updateAndCommunicateGroupData(deferred_logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check individual well constraints and communicate.
|
// Check individual well constraints and communicate.
|
||||||
@ -1260,7 +1260,7 @@ namespace Opm {
|
|||||||
const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Individual;
|
const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Individual;
|
||||||
well->updateWellControl(ebosSimulator_, mode, well_state_, deferred_logger);
|
well->updateWellControl(ebosSimulator_, mode, well_state_, deferred_logger);
|
||||||
}
|
}
|
||||||
updateAndCommunicateGroupData();
|
updateAndCommunicateGroupData(deferred_logger);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1303,7 +1303,7 @@ namespace Opm {
|
|||||||
template<typename TypeTag>
|
template<typename TypeTag>
|
||||||
void
|
void
|
||||||
BlackoilWellModel<TypeTag>::
|
BlackoilWellModel<TypeTag>::
|
||||||
updateAndCommunicateGroupData()
|
updateAndCommunicateGroupData(Opm::DeferredLogger& deferred_logger)
|
||||||
{
|
{
|
||||||
const int reportStepIdx = ebosSimulator_.episodeIndex();
|
const int reportStepIdx = ebosSimulator_.episodeIndex();
|
||||||
const Group& fieldGroup = schedule().getGroup("FIELD", reportStepIdx);
|
const Group& fieldGroup = schedule().getGroup("FIELD", reportStepIdx);
|
||||||
@ -1332,7 +1332,7 @@ namespace Opm {
|
|||||||
const double simulationTime = ebosSimulator_.time();
|
const double simulationTime = ebosSimulator_.time();
|
||||||
std::vector<double> pot(numPhases(), 0.0);
|
std::vector<double> pot(numPhases(), 0.0);
|
||||||
WellGroupHelpers::updateGuideRateForProductionGroups(fieldGroup, schedule(), phase_usage_, reportStepIdx, simulationTime, well_state_, comm, guideRate_.get(), pot);
|
WellGroupHelpers::updateGuideRateForProductionGroups(fieldGroup, schedule(), phase_usage_, reportStepIdx, simulationTime, well_state_, comm, guideRate_.get(), pot);
|
||||||
WellGroupHelpers::updateGuideRatesForInjectionGroups(fieldGroup, schedule(), summaryState, phase_usage_, reportStepIdx, well_state_, guideRate_.get());
|
WellGroupHelpers::updateGuideRatesForInjectionGroups(fieldGroup, schedule(), summaryState, phase_usage_, reportStepIdx, well_state_, guideRate_.get(), deferred_logger);
|
||||||
|
|
||||||
WellGroupHelpers::updateREINForGroups(fieldGroup, schedule(), reportStepIdx, phase_usage_, summaryState, well_state_nupcol_, well_state_);
|
WellGroupHelpers::updateREINForGroups(fieldGroup, schedule(), reportStepIdx, phase_usage_, summaryState, well_state_nupcol_, well_state_);
|
||||||
WellGroupHelpers::updateVREPForGroups(fieldGroup, schedule(), reportStepIdx, well_state_nupcol_, well_state_);
|
WellGroupHelpers::updateVREPForGroups(fieldGroup, schedule(), reportStepIdx, well_state_nupcol_, well_state_);
|
||||||
|
@ -169,13 +169,14 @@ namespace WellGroupHelpers
|
|||||||
class InjectionTargetCalculator
|
class InjectionTargetCalculator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InjectionTargetCalculator(const Group::InjectionCMode cmode,
|
InjectionTargetCalculator(const Group::InjectionCMode& cmode,
|
||||||
const PhaseUsage& pu,
|
const PhaseUsage& pu,
|
||||||
const std::vector<double>& resv_coeff,
|
const std::vector<double>& resv_coeff,
|
||||||
const std::string& group_name,
|
const std::string& group_name,
|
||||||
const double sales_target,
|
const double sales_target,
|
||||||
const WellStateFullyImplicitBlackoil& well_state,
|
const WellStateFullyImplicitBlackoil& well_state,
|
||||||
const Phase& injection_phase)
|
const Phase& injection_phase,
|
||||||
|
DeferredLogger& deferred_logger)
|
||||||
: cmode_(cmode)
|
: cmode_(cmode)
|
||||||
, pu_(pu)
|
, pu_(pu)
|
||||||
, resv_coeff_(resv_coeff)
|
, resv_coeff_(resv_coeff)
|
||||||
@ -204,7 +205,9 @@ namespace WellGroupHelpers
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
assert(false);
|
OPM_DEFLOG_THROW(std::logic_error,
|
||||||
|
"Invalid injection phase in InjectionTargetCalculator",
|
||||||
|
deferred_logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +218,7 @@ namespace WellGroupHelpers
|
|||||||
return rates[pos_];
|
return rates[pos_];
|
||||||
}
|
}
|
||||||
|
|
||||||
double groupTarget(const Group::InjectionControls ctrl) const
|
double groupTarget(const Group::InjectionControls& ctrl, Opm::DeferredLogger& deferred_logger) const
|
||||||
{
|
{
|
||||||
switch (cmode_) {
|
switch (cmode_) {
|
||||||
case Group::InjectionCMode::RATE:
|
case Group::InjectionCMode::RATE:
|
||||||
@ -253,8 +256,9 @@ namespace WellGroupHelpers
|
|||||||
return inj_rate;
|
return inj_rate;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// Should never be here.
|
OPM_DEFLOG_THROW(std::logic_error,
|
||||||
assert(false);
|
"Invalid Group::InjectionCMode in InjectionTargetCalculator",
|
||||||
|
deferred_logger);
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include <opm/simulators/wells/TargetCalculator.hpp>
|
#include <opm/simulators/wells/TargetCalculator.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -233,12 +232,13 @@ namespace WellGroupHelpers
|
|||||||
const Opm::PhaseUsage& pu,
|
const Opm::PhaseUsage& pu,
|
||||||
const int reportStepIdx,
|
const int reportStepIdx,
|
||||||
const WellStateFullyImplicitBlackoil& wellState,
|
const WellStateFullyImplicitBlackoil& wellState,
|
||||||
GuideRate* guideRate)
|
GuideRate* guideRate,
|
||||||
|
Opm::DeferredLogger& deferred_logger)
|
||||||
{
|
{
|
||||||
for (const std::string& groupName : group.groups()) {
|
for (const std::string& groupName : group.groups()) {
|
||||||
const Group& groupTmp = schedule.getGroup(groupName, reportStepIdx);
|
const Group& groupTmp = schedule.getGroup(groupName, reportStepIdx);
|
||||||
updateGuideRatesForInjectionGroups(
|
updateGuideRatesForInjectionGroups(
|
||||||
groupTmp, schedule, summaryState, pu, reportStepIdx, wellState, guideRate);
|
groupTmp, schedule, summaryState, pu, reportStepIdx, wellState, guideRate, deferred_logger);
|
||||||
}
|
}
|
||||||
const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS};
|
const Phase all[] = {Phase::WATER, Phase::OIL, Phase::GAS};
|
||||||
for (Phase phase : all) {
|
for (Phase phase : all) {
|
||||||
@ -269,13 +269,15 @@ namespace WellGroupHelpers
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Group::GuideRateInjTarget::RESV:
|
case Group::GuideRateInjTarget::RESV:
|
||||||
OPM_THROW(std::runtime_error, "GUIDE PHASE RESV not implemented. Group " + group.name());
|
OPM_DEFLOG_THROW(std::runtime_error, "GUIDE PHASE RESV not implemented. Group " + group.name(), deferred_logger);
|
||||||
case Group::GuideRateInjTarget::POTN:
|
case Group::GuideRateInjTarget::POTN:
|
||||||
break;
|
break;
|
||||||
case Group::GuideRateInjTarget::NO_GUIDE_RATE:
|
case Group::GuideRateInjTarget::NO_GUIDE_RATE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
OPM_DEFLOG_THROW(std::logic_error,
|
||||||
|
"Invalid GuideRateInjTarget in updateGuideRatesForInjectionGroups",
|
||||||
|
deferred_logger);
|
||||||
}
|
}
|
||||||
guideRate->compute(group.name(), phase, reportStepIdx, guideRateValue);
|
guideRate->compute(group.name(), phase, reportStepIdx, guideRateValue);
|
||||||
}
|
}
|
||||||
@ -1136,7 +1138,7 @@ namespace WellGroupHelpers
|
|||||||
const auto& gconsale = schedule[reportStepIdx].gconsale().get(group.name(), summaryState);
|
const auto& gconsale = schedule[reportStepIdx].gconsale().get(group.name(), summaryState);
|
||||||
sales_target = gconsale.sales_target;
|
sales_target = gconsale.sales_target;
|
||||||
}
|
}
|
||||||
InjectionTargetCalculator tcalc(currentGroupControl, pu, resv_coeff, group.name(), sales_target, wellState, injectionPhase);
|
InjectionTargetCalculator tcalc(currentGroupControl, pu, resv_coeff, group.name(), sales_target, wellState, injectionPhase, deferred_logger);
|
||||||
FractionCalculator fcalc(schedule, summaryState, wellState, reportStepIdx, guideRate, tcalc.guideTargetMode(), pu, false, injectionPhase);
|
FractionCalculator fcalc(schedule, summaryState, wellState, reportStepIdx, guideRate, tcalc.guideTargetMode(), pu, false, injectionPhase);
|
||||||
|
|
||||||
auto localFraction = [&](const std::string& child) { return fcalc.localFraction(child, name); };
|
auto localFraction = [&](const std::string& child) { return fcalc.localFraction(child, name); };
|
||||||
@ -1147,7 +1149,7 @@ namespace WellGroupHelpers
|
|||||||
return tcalc.calcModeRateFromRates(groupTargetReductions);
|
return tcalc.calcModeRateFromRates(groupTargetReductions);
|
||||||
};
|
};
|
||||||
|
|
||||||
const double orig_target = tcalc.groupTarget(group.injectionControls(injectionPhase, summaryState));
|
const double orig_target = tcalc.groupTarget(group.injectionControls(injectionPhase, summaryState), deferred_logger);
|
||||||
// Assume we have a chain of groups as follows: BOTTOM -> MIDDLE -> TOP.
|
// Assume we have a chain of groups as follows: BOTTOM -> MIDDLE -> TOP.
|
||||||
// Then ...
|
// Then ...
|
||||||
// TODO finish explanation.
|
// TODO finish explanation.
|
||||||
|
@ -223,7 +223,8 @@ namespace WellGroupHelpers
|
|||||||
const Opm::PhaseUsage& pu,
|
const Opm::PhaseUsage& pu,
|
||||||
const int reportStepIdx,
|
const int reportStepIdx,
|
||||||
const WellStateFullyImplicitBlackoil& wellState,
|
const WellStateFullyImplicitBlackoil& wellState,
|
||||||
GuideRate* guideRate);
|
GuideRate* guideRate,
|
||||||
|
Opm::DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
void updateVREPForGroups(const Group& group,
|
void updateVREPForGroups(const Group& group,
|
||||||
const Schedule& schedule,
|
const Schedule& schedule,
|
||||||
|
@ -597,7 +597,8 @@ namespace Opm
|
|||||||
const EvalWell& bhp,
|
const EvalWell& bhp,
|
||||||
const EvalWell& injection_rate,
|
const EvalWell& injection_rate,
|
||||||
EvalWell& control_eq,
|
EvalWell& control_eq,
|
||||||
double efficiencyFactor);
|
double efficiencyFactor,
|
||||||
|
Opm::DeferredLogger& deferred_logger);
|
||||||
|
|
||||||
template <class EvalWell>
|
template <class EvalWell>
|
||||||
void getGroupProductionControl(const Group& group,
|
void getGroupProductionControl(const Group& group,
|
||||||
|
@ -2016,7 +2016,8 @@ namespace Opm
|
|||||||
bhp,
|
bhp,
|
||||||
injection_rate,
|
injection_rate,
|
||||||
control_eq,
|
control_eq,
|
||||||
efficiencyFactor);
|
efficiencyFactor,
|
||||||
|
deferred_logger);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Well::InjectorCMode::CMODE_UNDEFINED: {
|
case Well::InjectorCMode::CMODE_UNDEFINED: {
|
||||||
@ -2153,7 +2154,8 @@ namespace Opm
|
|||||||
const EvalWell& bhp,
|
const EvalWell& bhp,
|
||||||
const EvalWell& injection_rate,
|
const EvalWell& injection_rate,
|
||||||
EvalWell& control_eq,
|
EvalWell& control_eq,
|
||||||
double efficiencyFactor)
|
double efficiencyFactor,
|
||||||
|
Opm::DeferredLogger& deferred_logger)
|
||||||
{
|
{
|
||||||
// Setting some defaults to silence warnings below.
|
// Setting some defaults to silence warnings below.
|
||||||
// Will be overwritten in the switch statement.
|
// Will be overwritten in the switch statement.
|
||||||
@ -2198,7 +2200,7 @@ namespace Opm
|
|||||||
// Inject share of parents control
|
// Inject share of parents control
|
||||||
const auto& parent = schedule.getGroup( group.parent(), current_step_ );
|
const auto& parent = schedule.getGroup( group.parent(), current_step_ );
|
||||||
efficiencyFactor *= group.getGroupEfficiencyFactor();
|
efficiencyFactor *= group.getGroupEfficiencyFactor();
|
||||||
getGroupInjectionControl(parent, well_state, schedule, summaryState, injectorType, bhp, injection_rate, control_eq, efficiencyFactor);
|
getGroupInjectionControl(parent, well_state, schedule, summaryState, injectorType, bhp, injection_rate, control_eq, efficiencyFactor, deferred_logger);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2226,7 +2228,7 @@ namespace Opm
|
|||||||
const auto& gconsale = schedule[current_step_].gconsale().get(group.name(), summaryState);
|
const auto& gconsale = schedule[current_step_].gconsale().get(group.name(), summaryState);
|
||||||
sales_target = gconsale.sales_target;
|
sales_target = gconsale.sales_target;
|
||||||
}
|
}
|
||||||
WellGroupHelpers::InjectionTargetCalculator tcalc(currentGroupControl, pu, resv_coeff, group.name(), sales_target, well_state, injectionPhase);
|
WellGroupHelpers::InjectionTargetCalculator tcalc(currentGroupControl, pu, resv_coeff, group.name(), sales_target, well_state, injectionPhase, deferred_logger);
|
||||||
WellGroupHelpers::FractionCalculator fcalc(schedule, summaryState, well_state, current_step_, guide_rate_, tcalc.guideTargetMode(), pu, false, injectionPhase);
|
WellGroupHelpers::FractionCalculator fcalc(schedule, summaryState, well_state, current_step_, guide_rate_, tcalc.guideTargetMode(), pu, false, injectionPhase);
|
||||||
|
|
||||||
auto localFraction = [&](const std::string& child) {
|
auto localFraction = [&](const std::string& child) {
|
||||||
@ -2238,7 +2240,7 @@ namespace Opm
|
|||||||
return tcalc.calcModeRateFromRates(groupTargetReductions);
|
return tcalc.calcModeRateFromRates(groupTargetReductions);
|
||||||
};
|
};
|
||||||
|
|
||||||
const double orig_target = tcalc.groupTarget(group.injectionControls(injectionPhase, summaryState));
|
const double orig_target = tcalc.groupTarget(group.injectionControls(injectionPhase, summaryState), deferred_logger);
|
||||||
const auto chain = WellGroupHelpers::groupChainTopBot(name(), group.name(), schedule, current_step_);
|
const auto chain = WellGroupHelpers::groupChainTopBot(name(), group.name(), schedule, current_step_);
|
||||||
// Because 'name' is the last of the elements, and not an ancestor, we subtract one below.
|
// Because 'name' is the last of the elements, and not an ancestor, we subtract one below.
|
||||||
const size_t num_ancestors = chain.size() - 1;
|
const size_t num_ancestors = chain.size() - 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user