Implements a Python step_cleanup() method.

Continues the work in #2735 on implementing Python bindings for the flow
simulator.
This commit is contained in:
Håkon Hægland
2020-11-03 16:12:12 +01:00
parent 4f1bed2890
commit 0403d4e6e7
3 changed files with 33 additions and 7 deletions
+19 -5
View File
@@ -18,7 +18,7 @@ namespace py = pybind11;
namespace Opm::Pybind {
BlackOilSimulator::BlackOilSimulator( const std::string &deckFilename)
: deckFilename_(deckFilename), hasRunInit_(false)
: deckFilename_{deckFilename}, hasRunInit_{false}, hasRunCleanup_{false}
{
}
@@ -33,16 +33,29 @@ int BlackOilSimulator::step()
if (!hasRunInit_) {
throw std::logic_error("step() called before step_init()");
}
if (hasRunCleanup_) {
throw std::logic_error("step() called after step_cleanup()");
}
return mainEbos_->executeStep();
}
int BlackOilSimulator::step_init()
int BlackOilSimulator::stepCleanup()
{
hasRunCleanup_ = true;
return mainEbos_->executeStepsCleanup();
}
int BlackOilSimulator::stepInit()
{
if (hasRunInit_) {
// Running step_init() multiple times is not implemented yet,
// currently we just do nothing and return
return EXIT_SUCCESS;
if (hasRunCleanup_) {
throw std::logic_error("step_init() called again");
}
else {
return EXIT_SUCCESS;
}
}
main_ = std::make_unique<Opm::Main>( deckFilename_ );
int exitCode = EXIT_SUCCESS;
@@ -65,5 +78,6 @@ PYBIND11_MODULE(simulators, m)
.def(py::init< const std::string& >())
.def("run", &Opm::Pybind::BlackOilSimulator::run)
.def("step", &Opm::Pybind::BlackOilSimulator::step)
.def("step_init", &Opm::Pybind::BlackOilSimulator::step_init);
.def("step_init", &Opm::Pybind::BlackOilSimulator::stepInit)
.def("step_cleanup", &Opm::Pybind::BlackOilSimulator::stepCleanup);
}