mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4746 from blattms/better-message-timestep-breakdown
Improve error message when time step is cut too often/much.
This commit is contained in:
commit
81eee81291
@ -324,6 +324,27 @@ void handleExtraConvergenceOutput(SimulatorReport& report,
|
|||||||
// called by execute() or executeInitStep()
|
// called by execute() or executeInitStep()
|
||||||
int execute_(int (FlowMainEbos::* runOrInitFunc)(), bool cleanup)
|
int execute_(int (FlowMainEbos::* runOrInitFunc)(), bool cleanup)
|
||||||
{
|
{
|
||||||
|
auto logger = [this](const std::exception& e, const std::string& message_start) {
|
||||||
|
std::ostringstream message;
|
||||||
|
message << message_start << e.what();
|
||||||
|
|
||||||
|
if (this->output_cout_) {
|
||||||
|
// in some cases exceptions are thrown before the logging system is set
|
||||||
|
// up.
|
||||||
|
if (OpmLog::hasBackend("STREAMLOG")) {
|
||||||
|
OpmLog::error(message.str());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << message.str() << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if HAVE_MPI
|
||||||
|
if (this->mpi_size_ > 1)
|
||||||
|
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
|
||||||
|
#endif
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// deal with some administrative boilerplate
|
// deal with some administrative boilerplate
|
||||||
|
|
||||||
@ -342,25 +363,11 @@ void handleExtraConvergenceOutput(SimulatorReport& report,
|
|||||||
}
|
}
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
catch (const LinearTimeSteppingBreakdown& e) {
|
||||||
|
return logger(e, "Simulation aborted: ");
|
||||||
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
std::ostringstream message;
|
return logger(e, "Simulation aborted as program threw an unexpected exception: ");
|
||||||
message << "Program threw an exception: " << e.what();
|
|
||||||
|
|
||||||
if (this->output_cout_) {
|
|
||||||
// in some cases exceptions are thrown before the logging system is set
|
|
||||||
// up.
|
|
||||||
if (OpmLog::hasBackend("STREAMLOG")) {
|
|
||||||
OpmLog::error(message.str());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
std::cout << message.str() << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if HAVE_MPI
|
|
||||||
if (this->mpi_size_ > 1)
|
|
||||||
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
|
|
||||||
#endif
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,6 +446,7 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
|
|||||||
std::string causeOfFailure;
|
std::string causeOfFailure;
|
||||||
try {
|
try {
|
||||||
substepReport = solver.step(substepTimer);
|
substepReport = solver.step(substepTimer);
|
||||||
|
|
||||||
if (solverVerbose_) {
|
if (solverVerbose_) {
|
||||||
// report number of linear iterations
|
// report number of linear iterations
|
||||||
OpmLog::debug("Overall linear iterations used: " + std::to_string(substepReport.total_linear_iterations));
|
OpmLog::debug("Overall linear iterations used: " + std::to_string(substepReport.total_linear_iterations));
|
||||||
@ -580,7 +581,8 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
|
|||||||
if (solverVerbose_) {
|
if (solverVerbose_) {
|
||||||
OpmLog::error(msg);
|
OpmLog::error(msg);
|
||||||
}
|
}
|
||||||
OPM_THROW_NOLOG(NumericalProblem, msg);
|
// Use throw directly to prevent file and line
|
||||||
|
throw LinearTimeSteppingBreakdown{msg};
|
||||||
}
|
}
|
||||||
|
|
||||||
// The new, chopped timestep.
|
// The new, chopped timestep.
|
||||||
@ -596,7 +598,8 @@ std::set<std::string> consistentlyFailingWells(const std::vector<StepReport>& sr
|
|||||||
if (solverVerbose_) {
|
if (solverVerbose_) {
|
||||||
OpmLog::error(msg);
|
OpmLog::error(msg);
|
||||||
}
|
}
|
||||||
OPM_THROW_NOLOG(NumericalProblem, msg);
|
// Use throw directly to prevent file and line
|
||||||
|
throw LinearTimeSteppingBreakdown{msg};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define utility function for chopping timestep.
|
// Define utility function for chopping timestep.
|
||||||
|
Loading…
Reference in New Issue
Block a user