mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-25 07:07:42 -05:00
Move throw for a perforation mismatch to the end of the loop over all wells
Instead of throwing inside the loop over all wells, collect the findings and throw at the end. Throwing inside of the loop over all wells leads to a deadlock in some cases.
This commit is contained in:
1 parent
ae8f51e45e
commit
5746bf9123
1 file changed
+11
-1
@@ -672,6 +672,7 @@ void WellState<Scalar>::initWellStateMSWell(const std::vector<Well>& wells_ecl,
|
||||
|
||||
std::optional<std::string> distributedMSWellLocalErrorMessage;
|
||||
std::optional<std::string> connectionWithoutAssociatedSegmentsLocalErrorMessage;
|
||||
std::optional<std::string> initializePerforationMismatchLocalErrorMessage;
|
||||
|
||||
// in the init function, the well rates and perforation rates have been initialized or copied from prevState
|
||||
// what we do here, is to set the segment rates and perforation rates
|
||||
@@ -799,7 +800,12 @@ void WellState<Scalar>::initWellStateMSWell(const std::vector<Well>& wells_ecl,
|
||||
perforation_rates[global_active_perf_index * np + i] = perf_rates[perf * np + i];
|
||||
}
|
||||
} else {
|
||||
OPM_THROW(std::logic_error,fmt::format("Error when initializing MS Well state, there is no active perforation index for the local index {}", perf));
|
||||
if (!initializePerforationMismatchLocalErrorMessage) {
|
||||
initializePerforationMismatchLocalErrorMessage = ""; // First well with error: initialize the string
|
||||
}
|
||||
|
||||
// Append to the existing error message for errors in further wells
|
||||
*initializePerforationMismatchLocalErrorMessage += fmt::format("Error when initializing MS Well state of well {}, there is no active perforation index for the local index {}.\n", well_ecl.name(), perf);
|
||||
}
|
||||
}
|
||||
if (ws.parallel_info.get().communication().size() > 1) {
|
||||
@@ -851,6 +857,10 @@ void WellState<Scalar>::initWellStateMSWell(const std::vector<Well>& wells_ecl,
|
||||
fullErrorMessage += *connectionWithoutAssociatedSegmentsLocalErrorMessage;
|
||||
}
|
||||
|
||||
if (initializePerforationMismatchLocalErrorMessage) {
|
||||
fullErrorMessage += *initializePerforationMismatchLocalErrorMessage;
|
||||
}
|
||||
|
||||
if (!fullErrorMessage.empty()) {
|
||||
throw std::logic_error(fullErrorMessage);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user