Merge pull request #5423 from blattms/bugfix/mswell-exceptions-are-problems

Only indicate problems for exceptions whem updating well potentials,
This commit is contained in:
Markus Blatt 2024-06-20 14:33:17 +02:00 committed by GitHub
commit 9dbaad2b3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 3 deletions

View File

@ -130,7 +130,27 @@ inline void logAndCheckForExceptionsAndThrow(Opm::DeferredLogger& deferred_logge
_throw(exc_type, message, comm); _throw(exc_type, message, comm);
} }
inline void logAndCheckForProblemsAndThrow(Opm::DeferredLogger& deferred_logger,
Opm::ExceptionType::ExcEnum exc_type,
const std::string& message,
const bool terminal_output,
Opm::Parallel::Communication comm)
{
// add exception message to logger in order to display message from all ranks
if (exc_type != Opm::ExceptionType::NONE && comm.size() > 1) {
deferred_logger.problem("[Exception on rank " + std::to_string(comm.rank()) + "]: " + message);
}
Opm::DeferredLogger global_deferredLogger = gatherDeferredLogger(deferred_logger, comm);
if (terminal_output) {
global_deferredLogger.logMessages();
}
// Now that all messages have been logged, they are automatically
// cleared from the global logger, but we must also clear them
// from the local logger.
deferred_logger.clearMessages();
_throw(exc_type, message, comm);
}
/// \brief Macro to setup the try of a parallel try-catch /// \brief Macro to setup the try of a parallel try-catch
/// ///
/// Use OPM_END_PARALLEL_TRY_CATCH or OPM_END_PARALLEL_TRY_CATCH_LOG /// Use OPM_END_PARALLEL_TRY_CATCH or OPM_END_PARALLEL_TRY_CATCH_LOG

View File

@ -1542,9 +1542,9 @@ updateWellPotentials(const int reportStepIdx,
} }
++widx; ++widx;
} }
logAndCheckForExceptionsAndThrow(deferred_logger, exc_type, logAndCheckForProblemsAndThrow(deferred_logger, exc_type,
"computeWellPotentials() failed: " + exc_msg, "updateWellPotentials() failed: " + exc_msg,
terminal_output_, comm_); terminal_output_, comm_);
} }
template<class Scalar> template<class Scalar>