Merge pull request #5025 from blattms/expect-singular-matrices-upate-WellControl

[bugfix] Expect singular matrices, terminate updateWellControls/nonlinear and cut timestep
This commit is contained in:
Atgeirr Flø Rasmussen 2023-11-27 08:42:11 +01:00 committed by GitHub
commit cb3ab14a71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1916,6 +1916,10 @@ namespace Opm {
} }
// Check wells' group constraints and communicate. // Check wells' group constraints and communicate.
bool changed_well_to_group = false; bool changed_well_to_group = false;
{
// For MS Wells a linear solve is performed below and the matrix might be singular.
// We need to communicate the exception thrown to the others and rethrow.
OPM_BEGIN_PARALLEL_TRY_CATCH()
for (const auto& well : well_container_) { for (const auto& well : well_container_) {
const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Group; const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Group;
const bool changed_well = well->updateWellControl(ebosSimulator_, mode, this->wellState(), this->groupState(), deferred_logger); const bool changed_well = well->updateWellControl(ebosSimulator_, mode, this->wellState(), this->groupState(), deferred_logger);
@ -1923,6 +1927,9 @@ namespace Opm {
changed_well_to_group = changed_well || changed_well_to_group; changed_well_to_group = changed_well || changed_well_to_group;
} }
} }
OPM_END_PARALLEL_TRY_CATCH("BlackoilWellModel: updating well controls failed: ",
ebosSimulator_.gridView().comm());
}
changed_well_to_group = comm.sum(static_cast<int>(changed_well_to_group)); changed_well_to_group = comm.sum(static_cast<int>(changed_well_to_group));
if (changed_well_to_group) { if (changed_well_to_group) {
@ -1932,6 +1939,10 @@ namespace Opm {
// Check individual well constraints and communicate. // Check individual well constraints and communicate.
bool changed_well_individual = false; bool changed_well_individual = false;
{
// For MS Wells a linear solve is performed below and the matrix might be singular.
// We need to communicate the exception thrown to the others and rethrow.
OPM_BEGIN_PARALLEL_TRY_CATCH()
for (const auto& well : well_container_) { for (const auto& well : well_container_) {
const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Individual; const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Individual;
const bool changed_well = well->updateWellControl(ebosSimulator_, mode, this->wellState(), this->groupState(), deferred_logger); const bool changed_well = well->updateWellControl(ebosSimulator_, mode, this->wellState(), this->groupState(), deferred_logger);
@ -1939,6 +1950,10 @@ namespace Opm {
changed_well_individual = changed_well || changed_well_individual; changed_well_individual = changed_well || changed_well_individual;
} }
} }
OPM_END_PARALLEL_TRY_CATCH("BlackoilWellModel: updating well controls failed: ",
ebosSimulator_.gridView().comm());
}
changed_well_individual = comm.sum(static_cast<int>(changed_well_individual)); changed_well_individual = comm.sum(static_cast<int>(changed_well_individual));
if (changed_well_individual) { if (changed_well_individual) {
updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger); updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);