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 updateAndCommunicateGroupData();
|
||||
void updateAndCommunicateGroupData(Opm::DeferredLogger& deferred_logger);
|
||||
void updateNetworkPressures();
|
||||
|
||||
// setting the well_solutions_ based on well_state.
|
||||
|
@ -306,7 +306,7 @@ namespace Opm {
|
||||
|
||||
well_state_ = previous_well_state_;
|
||||
well_state_.disableGliftOptimization();
|
||||
updateAndCommunicateGroupData();
|
||||
updateAndCommunicateGroupData(local_deferredLogger);
|
||||
const int reportStepIdx = ebosSimulator_.episodeIndex();
|
||||
const double simulationTime = ebosSimulator_.time();
|
||||
int exception_thrown = 0;
|
||||
@ -1225,7 +1225,7 @@ namespace Opm {
|
||||
// For no well active globally we simply return.
|
||||
if( !wellsActive() ) return ;
|
||||
|
||||
updateAndCommunicateGroupData();
|
||||
updateAndCommunicateGroupData(deferred_logger);
|
||||
|
||||
updateNetworkPressures();
|
||||
|
||||
@ -1239,7 +1239,7 @@ namespace Opm {
|
||||
// Check group's constraints from higher levels.
|
||||
updateGroupHigherControls(deferred_logger, switched_groups);
|
||||
|
||||
updateAndCommunicateGroupData();
|
||||
updateAndCommunicateGroupData(deferred_logger);
|
||||
|
||||
// Check wells' group constraints and communicate.
|
||||
for (const auto& well : well_container_) {
|
||||
@ -1249,7 +1249,7 @@ namespace Opm {
|
||||
switched_wells.insert(well->name());
|
||||
}
|
||||
}
|
||||
updateAndCommunicateGroupData();
|
||||
updateAndCommunicateGroupData(deferred_logger);
|
||||
}
|
||||
|
||||
// Check individual well constraints and communicate.
|
||||
@ -1260,7 +1260,7 @@ namespace Opm {
|
||||
const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Individual;
|
||||
well->updateWellControl(ebosSimulator_, mode, well_state_, deferred_logger);
|
||||
}
|
||||
updateAndCommunicateGroupData();
|
||||
updateAndCommunicateGroupData(deferred_logger);
|
||||
|
||||
}
|
||||
|
||||
@ -1303,7 +1303,7 @@ namespace Opm {
|
||||
template<typename TypeTag>
|
||||
void
|
||||
BlackoilWellModel<TypeTag>::
|
||||
updateAndCommunicateGroupData()
|
||||
updateAndCommunicateGroupData(Opm::DeferredLogger& deferred_logger)
|
||||
{
|
||||
const int reportStepIdx = ebosSimulator_.episodeIndex();
|
||||
const Group& fieldGroup = schedule().getGroup("FIELD", reportStepIdx);
|
||||
@ -1332,7 +1332,7 @@ namespace Opm {
|
||||
const double simulationTime = ebosSimulator_.time();
|
||||
std::vector<double> pot(numPhases(), 0.0);
|
||||
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::updateVREPForGroups(fieldGroup, schedule(), reportStepIdx, well_state_nupcol_, well_state_);
|
||||
|
@ -169,13 +169,14 @@ namespace WellGroupHelpers
|
||||
class InjectionTargetCalculator
|
||||
{
|
||||
public:
|
||||
InjectionTargetCalculator(const Group::InjectionCMode cmode,
|
||||
InjectionTargetCalculator(const Group::InjectionCMode& cmode,
|
||||
const PhaseUsage& pu,
|
||||
const std::vector<double>& resv_coeff,
|
||||
const std::string& group_name,
|
||||
const double sales_target,
|
||||
const WellStateFullyImplicitBlackoil& well_state,
|
||||
const Phase& injection_phase)
|
||||
const Phase& injection_phase,
|
||||
DeferredLogger& deferred_logger)
|
||||
: cmode_(cmode)
|
||||
, pu_(pu)
|
||||
, resv_coeff_(resv_coeff)
|
||||
@ -204,7 +205,9 @@ namespace WellGroupHelpers
|
||||
break;
|
||||
}
|
||||
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_];
|
||||
}
|
||||
|
||||
double groupTarget(const Group::InjectionControls ctrl) const
|
||||
double groupTarget(const Group::InjectionControls& ctrl, Opm::DeferredLogger& deferred_logger) const
|
||||
{
|
||||
switch (cmode_) {
|
||||
case Group::InjectionCMode::RATE:
|
||||
@ -253,8 +256,9 @@ namespace WellGroupHelpers
|
||||
return inj_rate;
|
||||
}
|
||||
default:
|
||||
// Should never be here.
|
||||
assert(false);
|
||||
OPM_DEFLOG_THROW(std::logic_error,
|
||||
"Invalid Group::InjectionCMode in InjectionTargetCalculator",
|
||||
deferred_logger);
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <opm/simulators/wells/TargetCalculator.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
@ -233,12 +232,13 @@ namespace WellGroupHelpers
|
||||
const Opm::PhaseUsage& pu,
|
||||
const int reportStepIdx,
|
||||
const WellStateFullyImplicitBlackoil& wellState,
|
||||
GuideRate* guideRate)
|
||||
GuideRate* guideRate,
|
||||
Opm::DeferredLogger& deferred_logger)
|
||||
{
|
||||
for (const std::string& groupName : group.groups()) {
|
||||
const Group& groupTmp = schedule.getGroup(groupName, reportStepIdx);
|
||||
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};
|
||||
for (Phase phase : all) {
|
||||
@ -269,13 +269,15 @@ namespace WellGroupHelpers
|
||||
break;
|
||||
}
|
||||
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:
|
||||
break;
|
||||
case Group::GuideRateInjTarget::NO_GUIDE_RATE:
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
OPM_DEFLOG_THROW(std::logic_error,
|
||||
"Invalid GuideRateInjTarget in updateGuideRatesForInjectionGroups",
|
||||
deferred_logger);
|
||||
}
|
||||
guideRate->compute(group.name(), phase, reportStepIdx, guideRateValue);
|
||||
}
|
||||
@ -1136,7 +1138,7 @@ namespace WellGroupHelpers
|
||||
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, 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);
|
||||
|
||||
auto localFraction = [&](const std::string& child) { return fcalc.localFraction(child, name); };
|
||||
@ -1147,7 +1149,7 @@ namespace WellGroupHelpers
|
||||
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.
|
||||
// Then ...
|
||||
// TODO finish explanation.
|
||||
|
@ -223,7 +223,8 @@ namespace WellGroupHelpers
|
||||
const Opm::PhaseUsage& pu,
|
||||
const int reportStepIdx,
|
||||
const WellStateFullyImplicitBlackoil& wellState,
|
||||
GuideRate* guideRate);
|
||||
GuideRate* guideRate,
|
||||
Opm::DeferredLogger& deferred_logger);
|
||||
|
||||
void updateVREPForGroups(const Group& group,
|
||||
const Schedule& schedule,
|
||||
|
@ -597,7 +597,8 @@ namespace Opm
|
||||
const EvalWell& bhp,
|
||||
const EvalWell& injection_rate,
|
||||
EvalWell& control_eq,
|
||||
double efficiencyFactor);
|
||||
double efficiencyFactor,
|
||||
Opm::DeferredLogger& deferred_logger);
|
||||
|
||||
template <class EvalWell>
|
||||
void getGroupProductionControl(const Group& group,
|
||||
|
@ -2016,7 +2016,8 @@ namespace Opm
|
||||
bhp,
|
||||
injection_rate,
|
||||
control_eq,
|
||||
efficiencyFactor);
|
||||
efficiencyFactor,
|
||||
deferred_logger);
|
||||
break;
|
||||
}
|
||||
case Well::InjectorCMode::CMODE_UNDEFINED: {
|
||||
@ -2153,7 +2154,8 @@ namespace Opm
|
||||
const EvalWell& bhp,
|
||||
const EvalWell& injection_rate,
|
||||
EvalWell& control_eq,
|
||||
double efficiencyFactor)
|
||||
double efficiencyFactor,
|
||||
Opm::DeferredLogger& deferred_logger)
|
||||
{
|
||||
// Setting some defaults to silence warnings below.
|
||||
// Will be overwritten in the switch statement.
|
||||
@ -2198,7 +2200,7 @@ namespace Opm
|
||||
// Inject share of parents control
|
||||
const auto& parent = schedule.getGroup( group.parent(), current_step_ );
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -2226,7 +2228,7 @@ namespace Opm
|
||||
const auto& gconsale = schedule[current_step_].gconsale().get(group.name(), summaryState);
|
||||
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);
|
||||
|
||||
auto localFraction = [&](const std::string& child) {
|
||||
@ -2238,7 +2240,7 @@ namespace Opm
|
||||
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_);
|
||||
// Because 'name' is the last of the elements, and not an ancestor, we subtract one below.
|
||||
const size_t num_ancestors = chain.size() - 1;
|
||||
|
Loading…
Reference in New Issue
Block a user