Remove local variable

This commit is contained in:
Joakim Hove 2021-10-31 08:55:48 +01:00
parent 807ac101d8
commit 029d1794f8

View File

@ -86,10 +86,7 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
: (prod_controls.cmode == Well::ProducerCMode::GRUP); : (prod_controls.cmode == Well::ProducerCMode::GRUP);
const double inj_surf_rate = well.isInjector() ? inj_controls.surface_rate : 0.0; // To avoid a "maybe-uninitialized" warning. const double inj_surf_rate = well.isInjector() ? inj_controls.surface_rate : 0.0; // To avoid a "maybe-uninitialized" warning.
const double global_pressure = well_info.broadcastFirstPerforationValue(cellPressures[well_perf_data[0].cell_index]);
const double local_pressure = well_perf_data.empty() ?
0 : cellPressures[well_perf_data[0].cell_index];
const double global_pressure = well_info.broadcastFirstPerforationValue(local_pressure);
if (well.getStatus() == Well::Status::OPEN) { if (well.getStatus() == Well::Status::OPEN) {
ws.status = Well::Status::OPEN; ws.status = Well::Status::OPEN;
@ -122,21 +119,20 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
// (producer) or RATE (injector). // (producer) or RATE (injector).
// Otherwise, we cannot set the correct // Otherwise, we cannot set the correct
// value here and initialize to zero rate. // value here and initialize to zero rate.
auto& rates = ws.surface_rates;
if (well.isInjector()) { if (well.isInjector()) {
if (inj_controls.cmode == Well::InjectorCMode::RATE) { if (inj_controls.cmode == Well::InjectorCMode::RATE) {
switch (inj_controls.injector_type) { switch (inj_controls.injector_type) {
case InjectorType::WATER: case InjectorType::WATER:
assert(pu.phase_used[BlackoilPhases::Aqua]); assert(pu.phase_used[BlackoilPhases::Aqua]);
rates[pu.phase_pos[BlackoilPhases::Aqua]] = inj_surf_rate; ws.surface_rates[pu.phase_pos[BlackoilPhases::Aqua]] = inj_surf_rate;
break; break;
case InjectorType::GAS: case InjectorType::GAS:
assert(pu.phase_used[BlackoilPhases::Vapour]); assert(pu.phase_used[BlackoilPhases::Vapour]);
rates[pu.phase_pos[BlackoilPhases::Vapour]] = inj_surf_rate; ws.surface_rates[pu.phase_pos[BlackoilPhases::Vapour]] = inj_surf_rate;
break; break;
case InjectorType::OIL: case InjectorType::OIL:
assert(pu.phase_used[BlackoilPhases::Liquid]); assert(pu.phase_used[BlackoilPhases::Liquid]);
rates[pu.phase_pos[BlackoilPhases::Liquid]] = inj_surf_rate; ws.surface_rates[pu.phase_pos[BlackoilPhases::Liquid]] = inj_surf_rate;
break; break;
case InjectorType::MULTI: case InjectorType::MULTI:
// Not currently handled, keep zero init. // Not currently handled, keep zero init.
@ -151,15 +147,15 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
switch (prod_controls.cmode) { switch (prod_controls.cmode) {
case Well::ProducerCMode::ORAT: case Well::ProducerCMode::ORAT:
assert(pu.phase_used[BlackoilPhases::Liquid]); assert(pu.phase_used[BlackoilPhases::Liquid]);
rates[pu.phase_pos[BlackoilPhases::Liquid]] = -prod_controls.oil_rate; ws.surface_rates[pu.phase_pos[BlackoilPhases::Liquid]] = -prod_controls.oil_rate;
break; break;
case Well::ProducerCMode::WRAT: case Well::ProducerCMode::WRAT:
assert(pu.phase_used[BlackoilPhases::Aqua]); assert(pu.phase_used[BlackoilPhases::Aqua]);
rates[pu.phase_pos[BlackoilPhases::Aqua]] = -prod_controls.water_rate; ws.surface_rates[pu.phase_pos[BlackoilPhases::Aqua]] = -prod_controls.water_rate;
break; break;
case Well::ProducerCMode::GRAT: case Well::ProducerCMode::GRAT:
assert(pu.phase_used[BlackoilPhases::Vapour]); assert(pu.phase_used[BlackoilPhases::Vapour]);
rates[pu.phase_pos[BlackoilPhases::Vapour]] = -prod_controls.gas_rate; ws.surface_rates[pu.phase_pos[BlackoilPhases::Vapour]] = -prod_controls.gas_rate;
break; break;
default: default:
// Keep zero init. // Keep zero init.