diff --git a/opm/core/wells/DynamicListEconLimited.hpp b/opm/core/wells/DynamicListEconLimited.hpp index 22123e1cb..7d6e4b11d 100644 --- a/opm/core/wells/DynamicListEconLimited.hpp +++ b/opm/core/wells/DynamicListEconLimited.hpp @@ -21,6 +21,7 @@ #include #include +#include #include @@ -31,6 +32,7 @@ namespace Opm class DynamicListEconLimited { public: + bool anyWellEconLimited() const { return !(m_shut_wells.empty()); }; @@ -48,8 +50,33 @@ namespace Opm m_shut_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()); + } + + const std::vector& getClosedConnectionsForWell(const std::string& well_name) const { + return (m_cells_closed_connections.find(well_name)->second); + } + + std::vector& closedConnectionsForWell(const std::string& well_name) { + return (m_cells_closed_connections.find(well_name)->second); + } + + void addClosedConnectionsForWell(const std::string& well_name, + const int cell_closed_connection) { + if (connectionClosedForWell(well_name)) { + std::vector vector_cells = {cell_closed_connection}; + m_cells_closed_connections[well_name] = vector_cells; + } else { + closedConnectionsForWell(well_name).push_back(cell_closed_connection); + } + } + private: std::vector m_shut_wells; + // using grid cell number to indicate the location of the connections + std::map> m_cells_closed_connections; }; } // namespace Opm diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 12f6ac011..960b33b68 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -150,6 +150,11 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t continue; } + std::vector cells_connection_closed; + if (list_econ_limited.connectionClosedForWell(well->name())) { + cells_connection_closed = list_econ_limited.getClosedConnectionsForWell(well->name()); + } + { // COMPDAT handling auto completionSet = well->getCompletions(timeStep); // shut completions and open ones stored in this process will have 1 others 0. @@ -181,6 +186,15 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t else { int cell = cgit->second; + // check if the connection is closed due to economic limits + if (!cells_connection_closed.empty()) { + const bool connection_found = std::find(cells_connection_closed.begin(), cells_connection_closed.end(), cell) + != cells_connection_closed.end(); + if (connection_found) { + continue; + } + } + PerfData pd; pd.cell = cell; {