mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-26 21:46:26 -06:00
Stop simulating if the schedule has set an exit condition.
The program will return the value set in the EXIT keyword.
This commit is contained in:
parent
88525f7c39
commit
a1091bd718
@ -258,12 +258,12 @@ namespace Opm
|
||||
createSimulator();
|
||||
|
||||
// do the actual work
|
||||
runSimulator(output_cout);
|
||||
int retval = runSimulator(output_cout);
|
||||
|
||||
// clean up
|
||||
mergeParallelLogFiles(output_to_files);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return retval;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::ostringstream message;
|
||||
@ -463,7 +463,7 @@ namespace Opm
|
||||
}
|
||||
|
||||
// Run the simulator.
|
||||
void runSimulator(bool output_cout)
|
||||
int runSimulator(bool output_cout)
|
||||
{
|
||||
const auto& schedule = this->schedule();
|
||||
const auto& timeMap = schedule.getTimeMap();
|
||||
@ -508,12 +508,12 @@ namespace Opm
|
||||
successReport.reportFullyImplicit(ss, &failureReport);
|
||||
OpmLog::info(ss.str());
|
||||
}
|
||||
|
||||
return successReport.exit_status;
|
||||
} else {
|
||||
if (output_cout) {
|
||||
std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,6 +164,14 @@ public:
|
||||
|
||||
// Main simulation loop.
|
||||
while (!timer.done()) {
|
||||
if (schedule().exitStatus().has_value()) {
|
||||
if (terminalOutput_) {
|
||||
OpmLog::info("Stopping simulation since EXIT was triggered by an action keyword.");
|
||||
}
|
||||
report.exit_status = schedule().exitStatus().value();
|
||||
break;
|
||||
}
|
||||
|
||||
// Report timestep.
|
||||
if (terminalOutput_) {
|
||||
std::ostringstream ss;
|
||||
|
@ -42,6 +42,7 @@ namespace Opm
|
||||
total_newton_iterations( 0 ),
|
||||
total_linear_iterations( 0 ),
|
||||
converged(false),
|
||||
exit_status(EXIT_SUCCESS),
|
||||
verbose_(verbose)
|
||||
{
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ namespace Opm
|
||||
unsigned int total_linear_iterations;
|
||||
|
||||
bool converged;
|
||||
int exit_status;
|
||||
|
||||
/// Default constructor initializing all times to 0.0.
|
||||
explicit SimulatorReport(bool verbose=true);
|
||||
|
Loading…
Reference in New Issue
Block a user