Merge pull request #1671 from atgeirr/fix-infinite-loop

Fix potential infinite loop
This commit is contained in:
Tor Harald Sandve
2018-12-07 12:41:37 +01:00
committed by GitHub
3 changed files with 46 additions and 30 deletions

View File

@@ -133,30 +133,37 @@ namespace Opm {
/// Return true if any well has a THP constraint.
/// Return true if the well was found and shut.
template<typename TypeTag>
void
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) {
if (well->underPredictionMode()) {
wellTestState_.addClosedWell(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_) {
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);
}