From 6fe5742145806812bdf9f4342b5b926ff58875a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Fri, 22 Aug 2025 14:03:11 +0200 Subject: [PATCH 1/3] Convert docstrings to template format with simulator configurations - Create unified template structure with 'simulators', 'constructors', and 'common_methods' sections - Add support for both BlackOil and GasWater simulators - Use {{name}} and {{class}} placeholders for template expansion - Eliminates need for duplicate JSON files --- python/docstrings_simulators.json | 172 ++++++++++++++++-------------- 1 file changed, 92 insertions(+), 80 deletions(-) diff --git a/python/docstrings_simulators.json b/python/docstrings_simulators.json index 458f24a9bfb..c5c7207172f 100644 --- a/python/docstrings_simulators.json +++ b/python/docstrings_simulators.json @@ -1,83 +1,95 @@ { - "PyBlackOilSimulator":{ - "type": "class", - "signature": "opm.simulators.BlackOilSimulator", - "doc": "The BlackOilSimulator class to run simulations using a given Deck." - }, - "PyBlackOilSimulator_filename_constructor": { - "signature": "opm.simulators.BlackOilSimulator.__init__(deck_filename: str, args: list[str] = []) -> BlackOilSimulator", - "doc": "Constructor using a deck file name.\n\n:param deck_filename: The file name of the deck to be used for the simulation.\n:type deck_filename: str\n:param args: Simulator options.\n:type args: list[str]\n:return: The BlackOilSimulator.\n:type return: BlackOilSimulator" - }, - "PyBlackOilSimulator_objects_constructor": { - "signature": "opm.simulators.BlackOilSimulator.__init__(deck: Deck, state: EclipseState, schedule: Schedule, summary_config: SummaryConfig, args: list[str] = []) -> BlackOilSimulator", - "doc": "Constructor using Deck, EclipseState, Schedule, and SummaryConfig objects.\n\n:param deck: Deck object.\n:type deck: Deck\n:param state: EclipseState object.\n:type state: EclipseState\n:param schedule: Schedule object.\n:type schedule: Schedule\n:param summary_config: SummaryConfig object.\n:type summary_config: SummaryConfig\n:param args: Simulator options.\n:type args: list[str]\n:return: The BlackOilSimulator.\n:type return: BlackOilSimulator" - }, - "advance": { - "signature": "opm.simulators.BlackOilSimulator.advance(report_step: int) -> None", - "doc": "Advances the simulation to a specific report step.\n\n:param report_step: Target report step to advance to.\n:type report_step: int" - }, - "checkSimulationFinished": { - "signature": "opm.simulators.BlackOilSimulator.check_simulation_finished() -> bool", - "doc": "Checks if the simulation has finished.\n\n:return: True if the simulation is finished, False otherwise.\n:type return: bool" - }, - "currentStep": { - "signature": "opm.simulators.BlackOilSimulator.current_step() -> int", - "doc": "Gets the current simulation step.\n\n:return: The current step number." - }, - "getCellVolumes": { - "signature": "opm.simulators.BlackOilSimulator.get_cell_volumes() -> NDArray[float]", - "doc": "Retrieves the cell volumes of the simulation grid.\n\n:return: An array of cell volumes.\n:type return: NDArray[float]" - }, - "getDT": { - "signature": "opm.simulators.BlackOilSimulator.get_dt() -> float", - "doc": "Gets the timestep size of the last completed step.\n\n:return: Timestep size in days.\n:type return: float" - }, - "getFluidStateVariable": { - "signature": "opm.simulators.BlackOilSimulator.get_fluid_state_variable(name: str) -> NDArray[float]", - "doc": "Retrieves a fluid state variable for the simulation grid.\n\n:param name: The name of the variable. Valid names are 'pw' (pressure water), 'pg' (pressure gas), 'po' (pressure oil), 'rho_w' (density water), 'rho_g' (density gas), 'rho_o' (density oil)'Rs' (soultion gas-oil ratio), 'Rv' (volatile gas-oil ratio), 'Sw' (water saturation), 'Sg' (gas saturation), 'So' (oil saturation), and 'T' (temperature).\n:type name: str\n\n:return: An array of fluid state variables.\n:type return: NDArray[float]" - }, - "getPorosity": { - "signature": "opm.simulators.BlackOilSimulator.get_porosity() -> NDArray[float]", - "doc": "Retrieves the porosity values of the simulation grid.\n\n:return: An array of porosity values.\n:type return: numpy.ndarray" - }, - "getPrimaryVarMeaning": { - "signature": "opm.simulators.BlackOilSimulator.get_primary_var_meaning(variable: str) -> NDArray[int]", - "doc": "Retrieves the primary variable meaning of the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: An array of primary variable meanings. See ``get_primary_variable_meaning_map()`` for more information.\n:type return: NDArray[int]" - }, - "getPrimaryVarMeaningMap": { - "signature": "opm.simulators.BlackOilSimulator.get_primary_var_meaning_map(variable: str) -> dict[str, int]", - "doc": "Retrieves the primary variable meaning map for each primary variable.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: A dictionary of primary variable meanings. The keys are the primary variable meanings and the values are the corresponding integer codes. The integer codes are used to represent the primary variable meanings in the simulation grid. For variable name 'pressure', the valid keys are: 'Po', 'Pg', and 'Pw', for variable name 'water', the valid keys are: 'Sw', 'Rvw', 'Rsw', and 'Disabled', for variable name 'gas', the valid keys are: 'Sg', 'Rs', 'Rv', and 'Disabled', for variable name 'brine', the valid keys are: 'Cs', 'Sp', and 'Disabled'.\n:type return: dict[str, int]" - }, - "getPrimaryVariable": { - "signature": "opm.simulators.BlackOilSimulator.get_primary_variable(variable: str) -> NDArray[float]", - "doc": "Retrieves the primary variable's values for the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: An array of primary variable values. See ``get_primary_variable_meaning()`` for more information.\n:type return: NDArray[float]" - }, - "run": { - "signature": "opm.simulators.BlackOilSimulator.run() -> int", - "doc": "Runs the simulation to completion with the provided deck file or previously set deck.\n\n:return: EXIT_SUCCESS if the simulation completes successfully." - }, - "setPorosity": { - "signature": "opm.simulators.BlackOilSimulator.set_porosity(array: NDArray[float]) -> None", - "doc": "Sets the porosity values for the simulation grid.\n\n:param array: An array of porosity values to be set.\n:type array: NDArray[float]" - }, - "setPrimaryVariable": { - "signature": "opm.simulators.BlackOilSimulator.set_primary_variable(variable: str, value: NDArray[float]) -> None", - "doc": "Sets the primary variable's values for the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n:param value: An array of primary variable values to be set. See ``get_primary_variable()`` for more information.\n:type value: NDArray[float]" - }, - "setupMpi": { - "signature": "opm.simulators.BlackOilSimulator.mpi_init(init: bool, finalize: bool) -> None", - "doc": "Sets MPI up for parallel simulation. This method should be called before any other method.\n\n:param init: Whether to call ``MPI_Init()`` or not.\n:param finalize: Whether to call ``MPI_Finalize()```when the simulator object goes out of scope.\n\n:return: None" - }, - "step": { - "signature": "opm.simulators.BlackOilSimulator.step() -> int", - "doc": "Executes the next simulation report step.\n\n:return: Result of the simulation step." - }, - "stepCleanup": { - "signature": "opm.simulators.BlackOilSimulator.step_cleanup() -> int", - "doc": "Performs cleanup after the last simulation step.\n\n:return: EXIT_SUCCESS if cleanup is successful." - }, - "stepInit": { - "signature": "opm.simulators.BlackOilSimulator.step_init() -> int", - "doc": "Initializes the simulation before taking the first report step. This method should be called before the first call to ``step()``\n\n:return: EXIT_SUCCESS if the initialization is successful." + "_usage_information": "This file defines documentation for OPM Python simulator bindings. It uses a template format where {{name}} is replaced with the simulator name (e.g., BlackOilSimulator) and {{class}} with the internal class name (e.g., PyBlackOilSimulator). The 'simulators' section defines available simulators, 'constructors' defines shared constructor documentation, and 'common_methods' defines documentation for methods shared by all simulators. This file is processed by: (1) opm-common/python/generate_docstring_hpp.py to generate C++ header files with docstrings, (2) opm-python-documentation/.../sphinx_ext_docstrings.py to generate Sphinx documentation. To add a new simulator, add an entry to the 'simulators' section with 'class', 'name', and 'doc' fields.", + "simulators": { + "BlackOil": { + "class": "PyBlackOilSimulator", + "name": "BlackOilSimulator", + "doc": "The BlackOilSimulator class to run simulations using a given Deck." + }, + "GasWater": { + "class": "PyGasWaterSimulator", + "name": "GasWaterSimulator", + "doc": "The GasWaterSimulator class to run simulations using a given Deck." + } + }, + "constructors": { + "filename_constructor": { + "signature_template": "opm.simulators.{{name}}.__init__(deck_filename: str) -> {{name}}", + "doc": "Constructor using a deck file name.\n\n:param deck_filename: The file name of the deck to be used for the simulation.\n:type deck_filename: str\n:return: The {{name}}.\n:type return: {{name}}" + }, + "objects_constructor": { + "signature_template": "opm.simulators.{{name}}.__init__(deck: Deck, state: EclipseState, schedule: Schedule, summary_config: SummaryConfig) -> {{name}}", + "doc": "Constructor using Deck, EclipseState, Schedule, and SummaryConfig objects.\n\n:param deck: Deck object.\n:type deck: Deck\n:param state: EclipseState object.\n:type state: EclipseState\n:param schedule: Schedule object.\n:type schedule: Schedule\n:param summary_config: SummaryConfig object.\n:type summary_config: SummaryConfig\n:return: The {{name}}.\n:type return: {{name}}" + } + }, + "common_methods": { + "advance": { + "signature_template": "opm.simulators.{{name}}.advance(report_step: int) -> None", + "doc": "Advances the simulation to a specific report step.\n\n:param report_step: Target report step to advance to.\n:type report_step: int" + }, + "checkSimulationFinished": { + "signature_template": "opm.simulators.{{name}}.check_simulation_finished() -> bool", + "doc": "Checks if the simulation has finished.\n\n:return: True if the simulation is finished, False otherwise.\n:type return: bool" + }, + "currentStep": { + "signature_template": "opm.simulators.{{name}}.current_step() -> int", + "doc": "Gets the current simulation step.\n\n:return: The current step number." + }, + "getCellVolumes": { + "signature_template": "opm.simulators.{{name}}.get_cell_volumes() -> NDArray[float]", + "doc": "Retrieves the cell volumes of the simulation grid.\n\n:return: An array of cell volumes.\n:type return: NDArray[float]" + }, + "getDT": { + "signature_template": "opm.simulators.{{name}}.get_dt() -> float", + "doc": "Gets the timestep size of the last completed step.\n\n:return: Timestep size in days.\n:type return: float" + }, + "getFluidStateVariable": { + "signature_template": "opm.simulators.{{name}}.get_fluid_state_variable(name: str) -> NDArray[float]", + "doc": "Retrieves a fluid state variable for the simulation grid.\n\n:param name: The name of the variable. Valid names are 'pw' (pressure water), 'pg' (pressure gas), 'po' (pressure oil), 'rho_w' (density water), 'rho_g' (density gas), 'rho_o' (density oil)'Rs' (soultion gas-oil ratio), 'Rv' (volatile gas-oil ratio), 'Sw' (water saturation), 'Sg' (gas saturation), 'So' (oil saturation), and 'T' (temperature).\n:type name: str\n\n:return: An array of fluid state variables.\n:type return: NDArray[float]" + }, + "getPorosity": { + "signature_template": "opm.simulators.{{name}}.get_porosity() -> NDArray[float]", + "doc": "Retrieves the porosity values of the simulation grid.\n\n:return: An array of porosity values.\n:type return: numpy.ndarray" + }, + "getPrimaryVarMeaning": { + "signature_template": "opm.simulators.{{name}}.get_primary_var_meaning(variable: str) -> NDArray[int]", + "doc": "Retrieves the primary variable meaning of the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: An array of primary variable meanings. See ``get_primary_variable_meaning_map()`` for more information.\n:type return: NDArray[int]" + }, + "getPrimaryVarMeaningMap": { + "signature_template": "opm.simulators.{{name}}.get_primary_var_meaning_map(variable: str) -> dict[str, int]", + "doc": "Retrieves the primary variable meaning map for each primary variable.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: A dictionary of primary variable meanings. The keys are the primary variable meanings and the values are the corresponding integer codes. The integer codes are used to represent the primary variable meanings in the simulation grid. For variable name 'pressure', the valid keys are: 'Po', 'Pg', and 'Pw', for variable name 'water', the valid keys are: 'Sw', 'Rvw', 'Rsw', and 'Disabled', for variable name 'gas', the valid keys are: 'Sg', 'Rs', 'Rv', and 'Disabled', for variable name 'brine', the valid keys are: 'Cs', 'Sp', and 'Disabled'.\n:type return: dict[str, int]" + }, + "getPrimaryVariable": { + "signature_template": "opm.simulators.{{name}}.get_primary_variable(variable: str) -> NDArray[float]", + "doc": "Retrieves the primary variable's values for the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: An array of primary variable values. See ``get_primary_variable_meaning()`` for more information.\n:type return: NDArray[float]" + }, + "run": { + "signature_template": "opm.simulators.{{name}}.run() -> int", + "doc": "Runs the simulation to completion with the provided deck file or previously set deck.\n\n:return: EXIT_SUCCESS if the simulation completes successfully." + }, + "setPorosity": { + "signature_template": "opm.simulators.{{name}}.set_porosity(array: NDArray[float]) -> None", + "doc": "Sets the porosity values for the simulation grid.\n\n:param array: An array of porosity values to be set.\n:type array: NDArray[float]" + }, + "setPrimaryVariable": { + "signature_template": "opm.simulators.{{name}}.set_primary_variable(variable: str, value: NDArray[float]) -> None", + "doc": "Sets the primary variable's values for the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n:param value: An array of primary variable values to be set. See ``get_primary_variable()`` for more information.\n:type value: NDArray[float]" + }, + "setupMpi": { + "signature_template": "opm.simulators.{{name}}.mpi_init(init: bool, finalize: bool) -> None", + "doc": "Sets MPI up for parallel simulation. This method should be called before any other method.\n\n:param init: Whether to call ``MPI_Init()`` or not.\n:param finalize: Whether to call ``MPI_Finalize()```when the simulator object goes out of scope.\n\n:return: None" + }, + "step": { + "signature_template": "opm.simulators.{{name}}.step() -> int", + "doc": "Executes the next simulation report step.\n\n:return: Result of the simulation step." + }, + "stepCleanup": { + "signature_template": "opm.simulators.{{name}}.step_cleanup() -> int", + "doc": "Performs cleanup after the last simulation step.\n\n:return: EXIT_SUCCESS if cleanup is successful." + }, + "stepInit": { + "signature_template": "opm.simulators.{{name}}.step_init() -> int", + "doc": "Initializes the simulation before taking the first report step. This method should be called before the first call to ``step()``\n\n:return: EXIT_SUCCESS if the initialization is successful." + } } } From 7552aec2c04c5c180b8a4272ff214c9cc385023c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Fri, 22 Aug 2025 14:07:50 +0200 Subject: [PATCH 2/3] Update CMakeLists.txt to pass simulator type to docstring generator - Add 'BlackOil' as 5th parameter to generate_docstring_hpp.py - Prepares for template-based docstring generation - Will work with updated opm-common generate_docstring_hpp.py script --- python/simulators/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/simulators/CMakeLists.txt b/python/simulators/CMakeLists.txt index af02e356b28..6689fc2ec94 100644 --- a/python/simulators/CMakeLists.txt +++ b/python/simulators/CMakeLists.txt @@ -18,7 +18,7 @@ add_custom_command( OUTPUT ${PYTHON_DOCSTRINGS_GENERATED_HPP} COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_SOURCE_DIR} ${PYTHON_EXECUTABLE} ${PYTHON_GENERATE_DOCSTRINGS_PY} - ${PYTHON_DOCSTRINGS_FILE} ${PYTHON_DOCSTRINGS_GENERATED_HPP} PYBLACKOILSIMULATORDOC_HPP "Opm::Pybind::DocStrings" + ${PYTHON_DOCSTRINGS_FILE} ${PYTHON_DOCSTRINGS_GENERATED_HPP} PYBLACKOILSIMULATORDOC_HPP "Opm::Pybind::DocStrings" "BlackOil" DEPENDS ${PYTHON_DOCSTRINGS_FILE} COMMENT "Generating PyBlackOilSimulatorDoc.hpp from JSON file" ) From 2f6bf952e16d7a3bf625db8a4e5b14c2f1b14266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Wed, 17 Sep 2025 15:35:17 +0200 Subject: [PATCH 3/3] Use new docstring format for python modules --- python/docstrings_gw_simulators.json | 83 ---------------------------- python/simulators/CMakeLists.txt | 7 +-- 2 files changed, 3 insertions(+), 87 deletions(-) delete mode 100644 python/docstrings_gw_simulators.json diff --git a/python/docstrings_gw_simulators.json b/python/docstrings_gw_simulators.json deleted file mode 100644 index 22bb96f0323..00000000000 --- a/python/docstrings_gw_simulators.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "PyGasWaterSimulator":{ - "type": "class", - "signature": "opm.simulators.GasWaterSimulator", - "doc": "The GasWaterSimulator class to run simulations using a given Deck." - }, - "PyGasWaterSimulator_filename_constructor": { - "signature": "opm.simulators.GasWaterSimulator.__init__(deck_filename: str, args: list[str] = []) -> GasWaterSimulator", - "doc": "Constructor using a deck file name.\n\n:param deck_filename: The file name of the deck to be used for the simulation.\n:type deck_filename: str\n:param args: Simulator options.\n:type args: list[str]\n:return: The GasWaterSimulator.\n:type return: GasWaterSimulator" - }, - "PyGasWaterSimulator_objects_constructor": { - "signature": "opm.simulators.GasWaterSimulator.__init__(deck: Deck, state: EclipseState, schedule: Schedule, summary_config: SummaryConfig, args: list[str] = []) -> GasWaterSimulator", - "doc": "Constructor using Deck, EclipseState, Schedule, and SummaryConfig objects.\n\n:param deck: Deck object.\n:type deck: Deck\n:param state: EclipseState object.\n:type state: EclipseState\n:param schedule: Schedule object.\n:type schedule: Schedule\n:param summary_config: SummaryConfig object.\n:type summary_config: SummaryConfig\n:param args: Simulator options.\n:type args: list[str]\n:return: The GasWaterSimulator.\n:type return: GasWaterSimulator" - }, - "advance": { - "signature": "opm.simulators.GasWaterSimulator.advance(report_step: int) -> None", - "doc": "Advances the simulation to a specific report step.\n\n:param report_step: Target report step to advance to.\n:type report_step: int" - }, - "checkSimulationFinished": { - "signature": "opm.simulators.GasWaterSimulator.check_simulation_finished() -> bool", - "doc": "Checks if the simulation has finished.\n\n:return: True if the simulation is finished, False otherwise.\n:type return: bool" - }, - "currentStep": { - "signature": "opm.simulators.GasWaterSimulator.current_step() -> int", - "doc": "Gets the current simulation step.\n\n:return: The current step number." - }, - "getCellVolumes": { - "signature": "opm.simulators.GasWaterSimulator.get_cell_volumes() -> NDArray[float]", - "doc": "Retrieves the cell volumes of the simulation grid.\n\n:return: An array of cell volumes.\n:type return: NDArray[float]" - }, - "getDT": { - "signature": "opm.simulators.GasWaterSimulator.get_dt() -> float", - "doc": "Gets the timestep size of the last completed step.\n\n:return: Timestep size in days.\n:type return: float" - }, - "getFluidStateVariable": { - "signature": "opm.simulators.GasWaterSimulator.get_fluid_state_variable(name: str) -> NDArray[float]", - "doc": "Retrieves a fluid state variable for the simulation grid.\n\n:param name: The name of the variable. Valid names are 'pw' (pressure water), 'pg' (pressure gas), 'po' (pressure oil), 'rho_w' (density water), 'rho_g' (density gas), 'rho_o' (density oil)'Rs' (soultion gas-oil ratio), 'Rv' (volatile gas-oil ratio), 'Sw' (water saturation), 'Sg' (gas saturation), 'So' (oil saturation), and 'T' (temperature).\n:type name: str\n\n:return: An array of fluid state variables.\n:type return: NDArray[float]" - }, - "getPorosity": { - "signature": "opm.simulators.GasWaterSimulator.get_porosity() -> NDArray[float]", - "doc": "Retrieves the porosity values of the simulation grid.\n\n:return: An array of porosity values.\n:type return: numpy.ndarray" - }, - "getPrimaryVarMeaning": { - "signature": "opm.simulators.GasWaterSimulator.get_primary_var_meaning(variable: str) -> NDArray[int]", - "doc": "Retrieves the primary variable meaning of the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: An array of primary variable meanings. See ``get_primary_variable_meaning_map()`` for more information.\n:type return: NDArray[int]" - }, - "getPrimaryVarMeaningMap": { - "signature": "opm.simulators.GasWaterSimulator.get_primary_var_meaning_map(variable: str) -> dict[str, int]", - "doc": "Retrieves the primary variable meaning map for each primary variable.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: A dictionary of primary variable meanings. The keys are the primary variable meanings and the values are the corresponding integer codes. The integer codes are used to represent the primary variable meanings in the simulation grid. For variable name 'pressure', the valid keys are: 'Po', 'Pg', and 'Pw', for variable name 'water', the valid keys are: 'Sw', 'Rvw', 'Rsw', and 'Disabled', for variable name 'gas', the valid keys are: 'Sg', 'Rs', 'Rv', and 'Disabled', for variable name 'brine', the valid keys are: 'Cs', 'Sp', and 'Disabled'.\n:type return: dict[str, int]" - }, - "getPrimaryVariable": { - "signature": "opm.simulators.GasWaterSimulator.get_primary_variable(variable: str) -> NDArray[float]", - "doc": "Retrieves the primary variable's values for the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n\n:return: An array of primary variable values. See ``get_primary_variable_meaning()`` for more information.\n:type return: NDArray[float]" - }, - "run": { - "signature": "opm.simulators.GasWaterSimulator.run() -> int", - "doc": "Runs the simulation to completion with the provided deck file or previously set deck.\n\n:return: EXIT_SUCCESS if the simulation completes successfully." - }, - "setPorosity": { - "signature": "opm.simulators.GasWaterSimulator.set_porosity(array: NDArray[float]) -> None", - "doc": "Sets the porosity values for the simulation grid.\n\n:param array: An array of porosity values to be set.\n:type array: NDArray[float]" - }, - "setPrimaryVariable": { - "signature": "opm.simulators.GasWaterSimulator.set_primary_variable(variable: str, value: NDArray[float]) -> None", - "doc": "Sets the primary variable's values for the simulation grid.\n\n:param variable: The name of the variable. Valid names are 'pressure', 'water', 'gas', and 'brine'.\n:type variable: str\n:param value: An array of primary variable values to be set. See ``get_primary_variable()`` for more information.\n:type value: NDArray[float]" - }, - "setupMpi": { - "signature": "opm.simulators.GasWaterSimulator.mpi_init(init: bool, finalize: bool) -> None", - "doc": "Sets MPI up for parallel simulation. This method should be called before any other method.\n\n:param init: Whether to call ``MPI_Init()`` or not.\n:param finalize: Whether to call ``MPI_Finalize()```when the simulator object goes out of scope.\n\n:return: None" - }, - "step": { - "signature": "opm.simulators.GasWaterSimulator.step() -> int", - "doc": "Executes the next simulation report step.\n\n:return: Result of the simulation step." - }, - "stepCleanup": { - "signature": "opm.simulators.GasWaterSimulator.step_cleanup() -> int", - "doc": "Performs cleanup after the last simulation step.\n\n:return: EXIT_SUCCESS if cleanup is successful." - }, - "stepInit": { - "signature": "opm.simulators.GasWaterSimulator.step_init() -> int", - "doc": "Initializes the simulation before taking the first report step. This method should be called before the first call to ``step()``\n\n:return: EXIT_SUCCESS if the initialization is successful." - } -} diff --git a/python/simulators/CMakeLists.txt b/python/simulators/CMakeLists.txt index 6689fc2ec94..283c62f4799 100644 --- a/python/simulators/CMakeLists.txt +++ b/python/simulators/CMakeLists.txt @@ -1,9 +1,8 @@ set(PYTHON_OPM_SIMULATORS_PACKAGE_PATH ${PROJECT_BINARY_DIR}/python/opm/simulators) -# Set the path to the input docstrings.json file and the output .hpp file +# Set the path to the input docstrings.json file and the output .hpp files set(PYTHON_DOCSTRINGS_FILE "${PROJECT_SOURCE_DIR}/python/docstrings_simulators.json") set(PYTHON_DOCSTRINGS_GENERATED_HPP "${PROJECT_BINARY_DIR}/python/PyBlackOilSimulatorDoc.hpp") -set(PYTHON_GW_DOCSTRINGS_FILE "${PROJECT_SOURCE_DIR}/python/docstrings_gw_simulators.json") set(PYTHON_GW_DOCSTRINGS_GENERATED_HPP "${PROJECT_BINARY_DIR}/python/PyGasWaterSimulatorDoc.hpp") # Note: If the new find_package(Python3) is used in the top level CMakeLists.txt, the variable # ${PYTHON_EXECUTABLE} is set there to ${Python3_EXECUTABLE} @@ -26,8 +25,8 @@ add_custom_command( OUTPUT ${PYTHON_GW_DOCSTRINGS_GENERATED_HPP} COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_SOURCE_DIR} ${PYTHON_EXECUTABLE} ${PYTHON_GENERATE_DOCSTRINGS_PY} - ${PYTHON_GW_DOCSTRINGS_FILE} ${PYTHON_GW_DOCSTRINGS_GENERATED_HPP} PYGASWATERSIMULATORDOC_HPP "Opm::Pybind::DocStrings" - DEPENDS ${PYTHON_GW_DOCSTRINGS_FILE} + ${PYTHON_DOCSTRINGS_FILE} ${PYTHON_GW_DOCSTRINGS_GENERATED_HPP} PYGASWATERSIMULATORDOC_HPP "Opm::Pybind::DocStrings" "GasWater" + DEPENDS ${PYTHON_DOCSTRINGS_FILE} COMMENT "Generating PyGasWaterSimulatorDoc.hpp from JSON file" ) # NOTE: The variable ${PYBIND11_SYSTEM} is set in python/CMakeLists.txt