diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 20aa5d91..0ae45ca3 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -411,6 +411,11 @@ namespace Opm OPM_THROW(std::runtime_error, "Currently we do not support well status " << WellCommon::Status2String(well->getStatus( timeStep ))); } + if (well->getStatus(timeStep) == WellCommon::SHUT) { + well_controls_shut_well( w_->ctrls[well_index] ); + continue; + } + if (well->isInjector(timeStep)) { const WellInjectionProperties& injectionProperties = well->getInjectionProperties(timeStep); int ok = 1; @@ -484,10 +489,6 @@ namespace Opm OPM_THROW(std::runtime_error, "Control not specified in well " << well_names[well_index]); } - // We need to check if the well is shut or not - if (well->getStatus( timeStep ) == WellCommon::SHUT) { - well_controls_shut_well( w_->ctrls[well_index] ); - } set_current_control(well_index, cpos, w_); } @@ -619,13 +620,12 @@ namespace Opm if (cpos == -1 && mode != WellsManagerDetail::ProductionControl::GRUP) { OPM_THROW(std::runtime_error, "Control mode type " << mode << " not present in well " << well_names[well_index]); } - // If it's shut, we complement the cpos - if (well->getStatus(timeStep) == WellCommon::SHUT) { - well_controls_shut_well( w_->ctrls[well_index] ); - } else if (cpos == -1 && mode != WellsManagerDetail::ProductionControl::GRUP) { + if (cpos == -1 && mode != WellsManagerDetail::ProductionControl::GRUP) { OPM_THROW(std::runtime_error, "Control mode type " << mode << " not present in well " << well_names[well_index]); } - set_current_control(well_index, cpos, w_); + else { + set_current_control(well_index, cpos, w_); + } // Set well component fraction to match preferred phase for the well. double cf[3] = { 0.0, 0.0, 0.0 }; diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index 7ddf9f29..ff1d2100 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -236,6 +236,19 @@ BOOST_AUTO_TEST_CASE(ControlsEqual) { +BOOST_AUTO_TEST_CASE(WellShutOK) { + const std::string filename = "wells_manager_data.data"; + Opm::ParserPtr parser(new Opm::Parser()); + Opm::DeckConstPtr deck(parser->parseFile(filename)); + + Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck)); + Opm::GridManager gridManager(deck); + + BOOST_CHECK_NO_THROW( Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL)); +} + + + BOOST_AUTO_TEST_CASE(WellHasSTOP_ExceptionIsThrown) { const std::string filename = "wells_manager_data_wellSTOP.data"; Opm::ParserPtr parser(new Opm::Parser()); diff --git a/tests/wells_manager_data.data b/tests/wells_manager_data.data index abb19c4a..3eb03594 100755 --- a/tests/wells_manager_data.data +++ b/tests/wells_manager_data.data @@ -55,26 +55,16 @@ WCONINJE 'INJ1' 'WATER' 'OPEN' 'RESV' 10 20 40 / / -END -TSTEP - 14.0 / +DATES + 1 'MAR' 2000 / / -WELSPECS - 'TEST1' 'G1' 1 1 8335 'GAS' / - 'TEST2' 'G2' 10 10 8400 'OIL' / -/ - -GRUPTREE - 'G1' 'SHIP' / - 'G2' 'SHIP' / -/ - -TSTEP - 3 / +WCONPROD + 'PROD1' 'SHUT' 15* / / END +