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,12 +1916,19 @@ namespace Opm {
}
// Check wells' group constraints and communicate.
bool changed_well_to_group = false;
for (const auto& well : well_container_) {
const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Group;
const bool changed_well = well->updateWellControl(ebosSimulator_, mode, this->wellState(), this->groupState(), deferred_logger);
if (changed_well) {
changed_well_to_group = changed_well || changed_well_to_group;
}
{
// 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_) {
const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Group;
const bool changed_well = well->updateWellControl(ebosSimulator_, mode, this->wellState(), this->groupState(), deferred_logger);
if (changed_well) {
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));
@ -1932,13 +1939,21 @@ namespace Opm {
// Check individual well constraints and communicate.
bool changed_well_individual = false;
for (const auto& well : well_container_) {
const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Individual;
const bool changed_well = well->updateWellControl(ebosSimulator_, mode, this->wellState(), this->groupState(), deferred_logger);
if (changed_well) {
changed_well_individual = changed_well || changed_well_individual;
}
{
// 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_) {
const auto mode = WellInterface<TypeTag>::IndividualOrGroup::Individual;
const bool changed_well = well->updateWellControl(ebosSimulator_, mode, this->wellState(), this->groupState(), deferred_logger);
if (changed_well) {
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));
if (changed_well_individual) {
updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);