diff --git a/opm/input/eclipse/Schedule/Well/WellTestConfig.hpp b/opm/input/eclipse/Schedule/Well/WellTestConfig.hpp index 731d51b260a..3fe7478a52f 100644 --- a/opm/input/eclipse/Schedule/Well/WellTestConfig.hpp +++ b/opm/input/eclipse/Schedule/Well/WellTestConfig.hpp @@ -60,6 +60,7 @@ enum class Reason { GROUP = 4, THP_DESIGN=8, COMPLETION=16, + CONVERGENCE=32, }; } diff --git a/opm/input/eclipse/Schedule/Well/WellTestState.cpp b/opm/input/eclipse/Schedule/Well/WellTestState.cpp index e4c2df97247..fd7a77e0c17 100644 --- a/opm/input/eclipse/Schedule/Well/WellTestState.cpp +++ b/opm/input/eclipse/Schedule/Well/WellTestState.cpp @@ -119,6 +119,13 @@ namespace Opm { return iter->second.closed; } + bool WellTestState::well_is_closed_due_to_convergence_issues(const std::string& well_name) const { + auto iter = this->wells.find(well_name); + if (iter == this->wells.end()) + return false; + + return iter->second.closed && iter->second.reason == WellTestConfig::Reason::CONVERGENCE; + } void WellTestState::filter_wells(const std::vector& existing_wells) { std::unordered_set well_set{ existing_wells.begin(), existing_wells.end() }; @@ -135,13 +142,20 @@ namespace Opm { std::vector WellTestState::test_wells(const WellTestConfig& config, - double sim_time) { + double sim_time) { std::vector output; for (auto& [wname, well] : this->wells) { if (!well.closed) continue; + // we always try to open well shut due to convergence issues + if (well.reason == WellTestConfig::Reason::CONVERGENCE) + output.push_back(well.name); + + if (config.empty()) + continue; + if (config.has(wname, well.reason)) { const auto& well_config = config.get(wname); const double elapsed = sim_time - well.last_test; diff --git a/opm/input/eclipse/Schedule/Well/WellTestState.hpp b/opm/input/eclipse/Schedule/Well/WellTestState.hpp index 4ddd806c522..b80a88d60b3 100644 --- a/opm/input/eclipse/Schedule/Well/WellTestState.hpp +++ b/opm/input/eclipse/Schedule/Well/WellTestState.hpp @@ -217,6 +217,7 @@ class WellTestState { */ void close_well(const std::string& well_name, WTest::Reason reason, double sim_time); bool well_is_closed(const std::string& well_name) const; + bool well_is_closed_due_to_convergence_issues(const std::string& well_name) const; void open_well(const std::string& well_name); std::size_t num_closed_wells() const; double lastTestTime(const std::string& well_name) const;