mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #2538 from atgeirr/support-schedule-exit
Stop simulating if the schedule has set an exit condition.
This commit is contained in:
commit
c39c6b05eb
@ -258,12 +258,12 @@ namespace Opm
|
|||||||
createSimulator();
|
createSimulator();
|
||||||
|
|
||||||
// do the actual work
|
// do the actual work
|
||||||
runSimulator(output_cout);
|
int retval = runSimulator(output_cout);
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
mergeParallelLogFiles(output_to_files);
|
mergeParallelLogFiles(output_to_files);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return retval;
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
@ -463,7 +463,7 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run the simulator.
|
// Run the simulator.
|
||||||
void runSimulator(bool output_cout)
|
int runSimulator(bool output_cout)
|
||||||
{
|
{
|
||||||
const auto& schedule = this->schedule();
|
const auto& schedule = this->schedule();
|
||||||
const auto& timeMap = schedule.getTimeMap();
|
const auto& timeMap = schedule.getTimeMap();
|
||||||
@ -508,12 +508,12 @@ namespace Opm
|
|||||||
successReport.reportFullyImplicit(ss, &failureReport);
|
successReport.reportFullyImplicit(ss, &failureReport);
|
||||||
OpmLog::info(ss.str());
|
OpmLog::info(ss.str());
|
||||||
}
|
}
|
||||||
|
return successReport.exit_status;
|
||||||
} else {
|
} else {
|
||||||
if (output_cout) {
|
if (output_cout) {
|
||||||
std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush;
|
std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush;
|
||||||
}
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +164,14 @@ public:
|
|||||||
|
|
||||||
// Main simulation loop.
|
// Main simulation loop.
|
||||||
while (!timer.done()) {
|
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.
|
// Report timestep.
|
||||||
if (terminalOutput_) {
|
if (terminalOutput_) {
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
|
@ -42,6 +42,7 @@ namespace Opm
|
|||||||
total_newton_iterations( 0 ),
|
total_newton_iterations( 0 ),
|
||||||
total_linear_iterations( 0 ),
|
total_linear_iterations( 0 ),
|
||||||
converged(false),
|
converged(false),
|
||||||
|
exit_status(EXIT_SUCCESS),
|
||||||
verbose_(verbose)
|
verbose_(verbose)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ namespace Opm
|
|||||||
unsigned int total_linear_iterations;
|
unsigned int total_linear_iterations;
|
||||||
|
|
||||||
bool converged;
|
bool converged;
|
||||||
|
int exit_status;
|
||||||
|
|
||||||
/// Default constructor initializing all times to 0.0.
|
/// Default constructor initializing all times to 0.0.
|
||||||
explicit SimulatorReport(bool verbose=true);
|
explicit SimulatorReport(bool verbose=true);
|
||||||
|
Loading…
Reference in New Issue
Block a user