Implement Python step() method.

The Python step() method advances the simulator one report step. Before
calling step() for the first time, step_init() must have been called.
This commit is contained in:
Håkon Hægland 2020-03-04 10:25:15 +01:00
parent f94f6dcbb0
commit 8e4f748372
2 changed files with 18 additions and 3 deletions

View File

@ -252,7 +252,13 @@ namespace Opm
int executeInitStep(int argc, char** argv, bool outputCout, bool outputToFiles) int executeInitStep(int argc, char** argv, bool outputCout, bool outputToFiles)
{ {
return execute_(argc, argv, outputCout, outputToFiles, return execute_(argc, argv, outputCout, outputToFiles,
&FlowMainEbos::runSimulatorInit); &FlowMainEbos::runSimulatorInit, /*cleanup=*/false);
}
int executeStep()
{
simulator_->runStep(*simtimer_);
return EXIT_SUCCESS;
} }
// Print an ASCII-art header to the PRT and DEBUG files. // Print an ASCII-art header to the PRT and DEBUG files.
@ -342,9 +348,9 @@ namespace Opm
} }
} }
void executeCleanup_(bool output_to_files) { void executeCleanup_(bool outputToFiles) {
// clean up // clean up
mergeParallelLogFiles(output_to_files); mergeParallelLogFiles(outputToFiles);
} }
protected: protected:

View File

@ -295,6 +295,14 @@ public:
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} }
int step()
{
if (!hasRunInit_) {
throw std::logic_error("step() called before step_init()");
}
return mainfunc_->executeStep();
}
private: private:
bool prepareRun_() bool prepareRun_()
@ -472,5 +480,6 @@ PYBIND11_MODULE(simulators, m)
.def("set_eclipse_state", &BlackOilSimulator::setEclipseState) .def("set_eclipse_state", &BlackOilSimulator::setEclipseState)
.def("set_schedule", &BlackOilSimulator::setSchedule) .def("set_schedule", &BlackOilSimulator::setSchedule)
.def("set_summary_config", &BlackOilSimulator::setSummaryConfig) .def("set_summary_config", &BlackOilSimulator::setSummaryConfig)
.def("step", &BlackOilSimulator::step)
.def("step_init", &BlackOilSimulator::step_init); .def("step_init", &BlackOilSimulator::step_init);
} }