From ad4b34dc305ecec56599d2f1932b260446cbdba9 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 7 Jun 2021 12:20:49 +0200 Subject: [PATCH] BlackoilWellModel: move forceShutWellByNameIfPredictionMode to generic class --- opm/simulators/wells/BlackoilWellModel.hpp | 4 --- .../wells/BlackoilWellModelGeneric.cpp | 31 ++++++++++++++++ .../wells/BlackoilWellModelGeneric.hpp | 5 +++ .../wells/BlackoilWellModel_impl.hpp | 35 ------------------- 4 files changed, 36 insertions(+), 39 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModel.hpp b/opm/simulators/wells/BlackoilWellModel.hpp index adfbfc3d8..d17f47fd2 100644 --- a/opm/simulators/wells/BlackoilWellModel.hpp +++ b/opm/simulators/wells/BlackoilWellModel.hpp @@ -261,10 +261,6 @@ namespace Opm { // called at the beginning of a report step void beginReportStep(const int time_step); - /// Shut down any single well, but only if it is in prediction mode. - /// Returns true if the well was actually found and shut. - bool forceShutWellByNameIfPredictionMode(const std::string& wellname, const double simulation_time); - void updatePerforationIntensiveQuantities(); // it should be able to go to prepareTimeStep(), however, the updateWellControls() and initPrimaryVariablesEvaluation() // makes it a little more difficult. unless we introduce if (iterationIdx != 0) to avoid doing the above functions diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index e47f92f9d..2d2a35c11 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -1521,4 +1521,35 @@ hasTHPConstraints() const return comm_.max(local_result); } +bool +BlackoilWellModelGeneric:: +forceShutWellByNameIfPredictionMode(const std::string& wellname, + const double simulation_time) +{ + // Only add the well to the closed list on the + // process that owns it. + int well_was_shut = 0; + for (const auto& well : well_container_generic_) { + if (well->name() == wellname && !well->wellIsStopped()) { + if (well->underPredictionMode()) { + wellTestState_.closeWell(wellname, WellTestConfig::Reason::PHYSICAL, simulation_time); + well_was_shut = 1; + } + break; + } + } + + // Communicate across processes if a well was shut. + well_was_shut = comm_.max(well_was_shut); + + // Only log a message on the output rank. + if (terminal_output_ && well_was_shut) { + const std::string msg = "Well " + wellname + + " will be shut because it cannot get converged."; + OpmLog::info(msg); + } + + return (well_was_shut == 1); +} + } diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index 2f66e104a..8a4d6b669 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -141,6 +141,11 @@ public: /// Return true if any well has a THP constraint. bool hasTHPConstraints() const; + /// Shut down any single well, but only if it is in prediction mode. + /// Returns true if the well was actually found and shut. + bool forceShutWellByNameIfPredictionMode(const std::string& wellname, + const double simulation_time); + protected: GroupState& groupState() { return this->active_wgstate_.group_state; } diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 8d466c769..c945eedfa 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -156,41 +156,6 @@ namespace Opm { } - /// Return true if the well was found and shut. - template - bool - BlackoilWellModel:: - forceShutWellByNameIfPredictionMode(const std::string& wellname, - const double simulation_time) - { - // Only add the well to the closed list on the - // process that owns it. - int well_was_shut = 0; - for (const auto& well : well_container_) { - if (well->name() == wellname && !well->wellIsStopped()) { - if (well->underPredictionMode()) { - wellTestState_.closeWell(wellname, WellTestConfig::Reason::PHYSICAL, simulation_time); - well_was_shut = 1; - } - break; - } - } - - // Communicate across processes if a well was shut. - well_was_shut = ebosSimulator_.vanguard().grid().comm().max(well_was_shut); - - // Only log a message on the output rank. - if (terminal_output_ && well_was_shut) { - const std::string msg = "Well " + wellname - + " will be shut because it cannot get converged."; - OpmLog::info(msg); - } - - return (well_was_shut == 1); - } - - - template void BlackoilWellModel::