Skip to content

Commit

Permalink
Merge pull request #4049 from OPM/backport-of-pr-4047
Browse files Browse the repository at this point in the history
Backport of pr 4047
  • Loading branch information
lisajulia authored May 3, 2024
2 parents 4cb58a0 + 89c9069 commit 95ae876
Show file tree
Hide file tree
Showing 6 changed files with 1,260 additions and 1,233 deletions.
2 changes: 1 addition & 1 deletion python/cxx/eclipse_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void python::common::export_EclipseState(py::module& module) {
.def( "simulation", &EclipseState::getSimulationConfig, ref_internal)
.def( "input_nnc", &getNNC )
.def( "faultNames", &faultNames )
.def( "faultFaces", &faultFaces )
.def( "faultFaces", &faultFaces, py::arg("fault_name"))
.def( "jfunc", &jfunc )
;

Expand Down
29 changes: 19 additions & 10 deletions python/cxx/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,36 @@
#include <opm/input/eclipse/Schedule/SummaryState.hpp>

void python::common::export_all(py::module& module) {

// Please do not change the order of the export statements below, since
// the classes exported earlier are used in the classes exported later.
// If you change the order, compilation works, but the function signature is
// not correct in the .pyi file created from the Python module opmcommon_python.

export_Log(module);
export_IO(module);

export_ParseContext(module);
export_Parser(module);
export_Deck(module);
export_ParserKeywords(module);
export_DeckKeyword(module);
export_Schedule(module);
export_ScheduleState(module);
export_Deck(module);
export_Parser(module);

export_UnitSystem(module);
export_Connection(module);
export_Well(module);
export_Group(module);
export_Connection(module);
export_EclipseConfig(module);
export_SimulationConfig(module);
export_FieldProperties(module);
export_EclipseState(module);
export_TableManager(module);
export_EclipseGrid(module);
export_UnitSystem(module);
export_Log(module);
export_IO(module);
export_EModel(module);

export_ScheduleState(module);
export_Schedule(module);
export_EclipseState(module);
export_SummaryState(module);
export_ParserKeywords(module);
}


Expand Down
14 changes: 7 additions & 7 deletions python/cxx/schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ void python::common::export_Schedule(py::module& module) {
The Opm::Schedule class - this is a representation of all the content from
the SCHEDULE section, notably all well and group information and the timestepping.
)pbdoc")
.def(py::init<const Deck&, const EclipseState& >())
.def("_groups", &get_groups )
.def(py::init<const Deck&, const EclipseState& >(), py::arg("deck"), py::arg("eclipse_state"))
.def("_groups", &get_groups, py::arg("report_step"))
.def_property_readonly( "start", &get_start_time )
.def_property_readonly( "end", &get_end_time )
.def_property_readonly( "timesteps", &get_timesteps )
Expand Down Expand Up @@ -276,15 +276,15 @@ void python::common::export_Schedule(py::module& module) {
Returns:
None
)")
.def( "get_wells", &Schedule::getWells)
.def( "get_wells", &Schedule::getWells, py::arg("well_name_pattern"))
.def( "get_injection_properties", &get_injection_properties, py::arg("well_name"), py::arg("report_step"))
.def( "get_production_properties", &get_production_properties, py::arg("well_name"), py::arg("report_step"))
.def("well_names", py::overload_cast<const std::string&>(&Schedule::wellNames, py::const_))
.def( "get_well", &get_well)
.def("well_names", py::overload_cast<const std::string&>(&Schedule::wellNames, py::const_), py::arg("well_name_pattern"))
.def( "get_well", &get_well, py::arg("well_name"), py::arg("report_step"))
.def( "insert_keywords", py::overload_cast<Schedule&, py::list&, std::size_t>(&insert_keywords), py::arg("keywords"), py::arg("step"))
.def( "insert_keywords", py::overload_cast<Schedule&, const std::string&, std::size_t, const UnitSystem&>(&insert_keywords), py::arg("data"), py::arg("step"), py::arg("unit_system"))
.def( "insert_keywords", py::overload_cast<Schedule&, const std::string&, std::size_t>(&insert_keywords), py::arg("data"), py::arg("step"))
.def( "insert_keywords", py::overload_cast<Schedule&, const std::string&>(&insert_keywords),py::arg("data"))
.def( "__contains__", &has_well );

.def("__contains__", &has_well, py::arg("well_name"))
;
}
2 changes: 1 addition & 1 deletion python/cxx/schedule_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ void python::common::export_ScheduleState(py::module& module) {

py::class_<ScheduleState>(module, "ScheduleState")
.def_property_readonly("nupcol", py::overload_cast<>(&ScheduleState::nupcol, py::const_))
.def("group", &get_group, ref_internal)
.def("group", &get_group, ref_internal, py::arg("group_name"))
;
}
15 changes: 8 additions & 7 deletions python/cxx/summary_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ void python::common::export_SummaryState(py::module& module) {
)pbdoc")
.def(py::init<std::time_t>())
.def("update", &SummaryState::update)
.def("update_well_var", &SummaryState::update_well_var)
.def("update_group_var", &SummaryState::update_group_var)
.def("well_var", py::overload_cast<const std::string&, const std::string&>(&SummaryState::get_well_var, py::const_))
.def("group_var", py::overload_cast<const std::string&, const std::string&>(&SummaryState::get_group_var, py::const_))
.def("update_well_var", &SummaryState::update_well_var, py::arg("well_name"), py::arg("variable_name"), py::arg("new_value"))
.def("update_group_var", &SummaryState::update_group_var, py::arg("group_name"), py::arg("variable_name"), py::arg("new_value"))
.def("well_var", py::overload_cast<const std::string&, const std::string&>(&SummaryState::get_well_var, py::const_), py::arg("well_name"), py::arg("variable_name"))
.def("group_var", py::overload_cast<const std::string&, const std::string&>(&SummaryState::get_group_var, py::const_), py::arg("group_name"), py::arg("variable_name"))
.def("elapsed", &SummaryState::get_elapsed)
.def_property_readonly("groups", groups)
.def_property_readonly("wells", wells)
.def("__contains__", &SummaryState::has)
.def("has_well_var", py::overload_cast<const std::string&, const std::string&>(&SummaryState::has_well_var, py::const_))
.def("has_group_var", py::overload_cast<const std::string&, const std::string&>(&SummaryState::has_group_var, py::const_))
.def("has_well_var", py::overload_cast<const std::string&, const std::string&>(&SummaryState::has_well_var, py::const_), py::arg("well_name"), py::arg("variable_name"))
.def("has_group_var", py::overload_cast<const std::string&, const std::string&>(&SummaryState::has_group_var, py::const_), py::arg("group_name"), py::arg("variable_name"))
.def("__setitem__", &SummaryState::set)
.def("__getitem__", py::overload_cast<const std::string&>(&SummaryState::get, py::const_));
.def("__getitem__", py::overload_cast<const std::string&>(&SummaryState::get, py::const_))
;
}
Loading

0 comments on commit 95ae876

Please sign in to comment.