mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Allow Python bindings to setup MPI
Allows the Python bindings to control whether MPI_Init() and MPI_Finalize() will be called when creating an OPM::Main object.
This commit is contained in:
@@ -171,6 +171,15 @@ setPrimaryVariable(
|
||||
getFluidState().setPrimaryVariable(variable, data, size_);
|
||||
}
|
||||
|
||||
void PyBlackOilSimulator::setupMpi(bool mpi_init, bool mpi_finalize)
|
||||
{
|
||||
if (this->has_run_init_) {
|
||||
throw std::logic_error("mpi_init() called after step_init()");
|
||||
}
|
||||
this->mpi_init_ = mpi_init;
|
||||
this->mpi_finalize_ = mpi_finalize;
|
||||
}
|
||||
|
||||
int PyBlackOilSimulator::step()
|
||||
{
|
||||
if (!this->has_run_init_) {
|
||||
@@ -211,11 +220,17 @@ int PyBlackOilSimulator::stepInit()
|
||||
this->deck_->getDataFile(),
|
||||
this->eclipse_state_,
|
||||
this->schedule_,
|
||||
this->summary_config_
|
||||
this->summary_config_,
|
||||
this->mpi_init_,
|
||||
this->mpi_finalize_
|
||||
);
|
||||
}
|
||||
else {
|
||||
this->main_ = std::make_unique<Opm::Main>( this->deck_filename_ );
|
||||
this->main_ = std::make_unique<Opm::Main>(
|
||||
this->deck_filename_,
|
||||
this->mpi_init_,
|
||||
this->mpi_finalize_
|
||||
);
|
||||
}
|
||||
int exit_code = EXIT_SUCCESS;
|
||||
this->flow_main_ = this->main_->initFlowBlackoil(exit_code);
|
||||
@@ -305,6 +320,7 @@ void export_PyBlackOilSimulator(py::module& m)
|
||||
.def("set_porosity", &PyBlackOilSimulator::setPorosity, setPorosity_docstring, py::arg("array"))
|
||||
.def("set_primary_variable", &PyBlackOilSimulator::setPrimaryVariable,
|
||||
py::arg("variable"), py::arg("value"))
|
||||
.def("setup_mpi", &PyBlackOilSimulator::setupMpi, setupMpi_docstring, py::arg("init"), py::arg("finalize"))
|
||||
.def("step", &PyBlackOilSimulator::step, step_docstring)
|
||||
.def("step_cleanup", &PyBlackOilSimulator::stepCleanup, stepCleanup_docstring)
|
||||
.def("step_init", &PyBlackOilSimulator::stepInit, stepInit_docstring);
|
||||
|
||||
Reference in New Issue
Block a user