BlackoilWellModel: move forceShutWellByNameIfPredictionMode to generic class

This commit is contained in:
Arne Morten Kvarving 2021-06-07 12:20:49 +02:00
parent 54ff1c4c45
commit ad4b34dc30
4 changed files with 36 additions and 39 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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; }

View File

@ -156,41 +156,6 @@ namespace Opm {
}
/// Return true if the well was found and shut.
template<typename TypeTag>
bool
BlackoilWellModel<TypeTag>::
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<typename TypeTag>
void
BlackoilWellModel<TypeTag>::