diff --git a/opm/core/io/eclipse/EclipseWriter.cpp b/opm/core/io/eclipse/EclipseWriter.cpp index 93f17ff5..874c2548 100644 --- a/opm/core/io/eclipse/EclipseWriter.cpp +++ b/opm/core/io/eclipse/EclipseWriter.cpp @@ -655,7 +655,7 @@ public: "SM3/DAY" /* surf. cub. m. per day */) { } - virtual double retrieveValue(const SimulatorTimer& /*timer*/, + virtual double retrieveValue(const SimulatorTimer& timer, const WellState& wellState, const std::map& wellNameToIdxMap) { @@ -666,6 +666,11 @@ public: return 0.0; } + if (well_->getStatus(timer.currentStepNum()) == WellCommon::SHUT) { + // well is shut in the current time step + return 0.0; + } + // TODO: Why only positive rates? using namespace Opm::unit; return convert::to(std::max(0., rate(wellState)), @@ -705,6 +710,11 @@ public: return 0.0; } + if (well_->getStatus(timer.currentStepNum()) == WellCommon::SHUT) { + // well is shut in the current time step + return 0.0; + } + // find the index for the quantity in the wellState this->updateTimeStepWellIndex_(wellNameToIdxMap); if (this->flatIdx_ < 0) { @@ -748,7 +758,7 @@ public: "Pascal") { } - virtual double retrieveValue(const SimulatorTimer& /*timer*/, + virtual double retrieveValue(const SimulatorTimer& timer, const WellState& wellState, const std::map& wellNameToIdxMap) { @@ -758,6 +768,10 @@ public: // well not active in current time step return 0.0; } + if (well_->getStatus(timer.currentStepNum()) == WellCommon::SHUT) { + // well is shut in the current time step + return 0.0; + } return bhp(wellState); } diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index aa9ff929..7a59f094 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -412,7 +412,7 @@ namespace Opm } if (well->getStatus(timeStep) == WellCommon::SHUT) { - well_controls_shut_well( w_->ctrls[well_index] ); + //well_controls_shut_well( w_->ctrls[well_index] ); well_index++; continue; } diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index d2453a87..cc317428 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -127,6 +127,11 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t int well_index = 0; for (auto wellIter= wells.begin(); wellIter != wells.end(); ++wellIter) { WellConstPtr well = (*wellIter); + + if (well->getStatus(timeStep) == WellCommon::SHUT) { + continue; + } + { // WELSPECS handling well_names_to_index[well->name()] = well_index; well_names.push_back(well->name()); diff --git a/tests/test_wellsmanager.cpp b/tests/test_wellsmanager.cpp index 9b0a8718..70cc0c23 100644 --- a/tests/test_wellsmanager.cpp +++ b/tests/test_wellsmanager.cpp @@ -275,7 +275,12 @@ BOOST_AUTO_TEST_CASE(WellShutOK) { Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(deck)); Opm::GridManager gridManager(deck); - BOOST_CHECK_NO_THROW( Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL)); + Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL); + + // Shut wells are not added to the deck. i.e number of wells should be 2-1 + BOOST_CHECK( wellsManager2.c_wells()->number_of_wells == 1); + + //BOOST_CHECK_NO_THROW( Opm::WellsManager wellsManager2(eclipseState , 2 , *gridManager.c_grid(), NULL)); }