diff --git a/opm/core/wells/DynamicListEconLimited.hpp b/opm/core/wells/DynamicListEconLimited.hpp index 7d6e4b11d..9cde3c6c9 100644 --- a/opm/core/wells/DynamicListEconLimited.hpp +++ b/opm/core/wells/DynamicListEconLimited.hpp @@ -33,23 +33,29 @@ namespace Opm { public: - bool anyWellEconLimited() const { - return !(m_shut_wells.empty()); - }; - - bool wellEconLimited(const std::string& well_name) const { - return std::find(m_shut_wells.begin(), m_shut_wells.end(), well_name) != m_shut_wells.end(); + bool wellShuttedEconLimited(const std::string& well_name) const { + return std::find(m_shutted_wells.begin(), m_shutted_wells.end(), well_name) != m_shutted_wells.end(); }; void addShuttedWell(const std::string& well_name) { - // the well should not be in the list - // TODO: not sure wheter a shutted well can - // still be running through some other mechanism. - assert( !wellEconLimited(well_name) ); + assert( !wellShuttedEconLimited(well_name) ); + assert( !wellStoppedEconLimited(well_name) ); - m_shut_wells.push_back(well_name); + m_shutted_wells.push_back(well_name); }; + bool wellStoppedEconLimited(const std::string& well_name) const { + return std::find(m_stopped_wells.begin(), m_stopped_wells.end(), well_name) != m_stopped_wells.end(); + }; + + void addStoppedWell(const std::string& well_name) { + assert( !wellShuttedEconLimited(well_name) ); + assert( !wellStoppedEconLimited(well_name) ); + + m_stopped_wells.push_back(well_name); + } + + // TODO: maybe completion better here bool connectionClosedForWell(const std::string& well_name) const { return (m_cells_closed_connections.find(well_name) != m_cells_closed_connections.end()); @@ -65,7 +71,8 @@ namespace Opm void addClosedConnectionsForWell(const std::string& well_name, const int cell_closed_connection) { - if (connectionClosedForWell(well_name)) { + if (!connectionClosedForWell(well_name)) { + // first time adding a connection for the well std::vector vector_cells = {cell_closed_connection}; m_cells_closed_connections[well_name] = vector_cells; } else { @@ -74,7 +81,8 @@ namespace Opm } private: - std::vector m_shut_wells; + std::vector m_shutted_wells; + std::vector m_stopped_wells; // using grid cell number to indicate the location of the connections std::map> m_cells_closed_connections; }; diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 3d1b9f807..072113b1d 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -431,22 +431,23 @@ namespace Opm continue; } - const auto* well = (*wellIter); - - if (well->getStatus(timeStep) == WellCommon::STOP) { - // STOPed wells are kept in the well list but marked as stopped. - well_controls_stop_well(w_->ctrls[well_index]); - } + const auto* well = (*wellIter); if (well->getStatus(timeStep) == WellCommon::SHUT) { //SHUT wells are not added to the well list continue; } - if (list_econ_limited.wellEconLimited(well->name())) { + if (list_econ_limited.wellShuttedEconLimited(well->name())) { continue; } + if (well->getStatus(timeStep) == WellCommon::STOP || list_econ_limited.wellStoppedEconLimited(well->name())) { + // Stopped wells are kept in the well list but marked as stopped. + well_controls_stop_well(w_->ctrls[well_index]); + } + + if (well->isInjector(timeStep)) { const WellInjectionProperties& injectionProperties = well->getInjectionProperties(timeStep); int ok = 1; diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 960b33b68..08d10f790 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -145,8 +145,7 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t continue; } - if (list_econ_limited.wellEconLimited(well->name())) { - // std::cout << " the well " << well->name() << " was closed " << std::endl; + if (list_econ_limited.wellShuttedEconLimited(well->name())) { continue; }