Commit Graph
67 Commits
Author SHA1 Message Date
David Landa Marban 1fd280c68d Removing trailing spaces and adding eol at eof 2025-10-02 10:22:55 +02:00
Svenn Tveit 8eaa56885d Use docstring template for OnePhaseSimulator documentation 2025-09-23 13:20:42 +02:00
Svenn Tveit 46559c532f Adressed review comments 2025-09-23 12:54:28 +02:00
Svenn Tveit 5153cd6fc0 Add OnePhaseSimulator to custom Python target 2025-09-23 12:52:46 +02:00
Svenn Tveit d0c08c4382 Python wrapper of single phase (water) simulator 2025-09-23 12:52:46 +02:00
Arne Morten Kvarving fafa4d8a19 Merge pull request #6418 from hakonhagland/docstring-template-refactor
Add support for Python docstring.json template format
2025-09-23 08:36:05 +02:00
David Landa Marban d3101a9c80 BIOFILM effects for gas-water systems 2025-09-18 11:15:48 +02:00
Håkon Hægland 2f6bf952e1 Use new docstring format for python modules 2025-09-17 15:35:17 +02:00
Håkon Hægland 7552aec2c0 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
2025-09-17 14:47:04 +02:00
Håkon Hægland 3c6313b619 Custom target to build all simulator modules
Create a convenience target to build all Python simulator modules.
2025-09-17 10:06:50 +02:00
Svenn Tveit 753fcc2ec4 Cleaned up formatting 2025-09-17 10:06:50 +02:00
Svenn Tveit 32dd09c78f Add Python gas-water simulator and refactor to template base class
Extend the Python blackoil simulator to support two-phase gas-water
simulations by extracting common functionality into a template base
class and implementing proper module separation.

- Extract PyBaseSimulator<TypeTag> template base class containing all
  common simulator functionality (20+ methods including advance, run,
  step, property access, and MPI handling)
- Add PyGasWaterSimulator for two-phase gas-water simulations using
  FlowGasWaterProblem TypeTag with oil phase disabled
- Split Python modules to avoid ODR violations:
  - BlackOil.so for PyBlackOilSimulator (FlowProblemTPFA)
  - GasWater.so for PyGasWaterSimulator (FlowGasWaterProblem)
- Implement proper template instantiation control with explicit
  instantiations per module

- Eliminate ~400 lines of code duplication between simulators
- Clean inheritance hierarchy: derived classes contain only constructors
- Type-safe specialization through OPM's TypeTag property system
- Separate docstring generation for each simulator type
- Independent build targets with shared infrastructure

- Update CMakeLists.txt to support multiple pybind11 modules
- Add docstrings_gw_simulators.json for gas-water simulator documentation
- Remove centralized Pybind11Exporter.cpp in favor of distributed exports
- Implement proper build dependencies and custom targets

This establishes a scalable foundation for extending OPM's Python
bindings to support additional simulator types (thermal, polymer,
solvent) while maintaining type safety and avoiding symbol conflicts.

Files changed: 21 files, 915 insertions, 428 deletions
2025-09-17 10:06:44 +02:00
Bård Skaflestad 54663f96a4 Add Missing Headers to Python Simulator
These were originally obtained through transitive includes,
especially from Main.hpp, but that's not a stable condition if the
set of transitive includes changes.
2025-01-30 12:17:39 +01:00
Arne Morten Kvarving 4d5a67fa82 added: ability to pass command line parameters from python 2024-11-28 09:14:53 +01:00
Arne Morten Kvarving 2353ba56a6 changed: don't store schedule keywords unless required in simulators
in the python simulator we cannot make this decision up front
since the schedule can be modified from python code so we have
to do the safe thing
2024-09-27 11:24:20 +02:00
Bård Skaflestad 03795d5b23 Merge pull request #5588 from akva2/move_python_initialization_function
Move python initialization function
2024-09-09 14:54:14 +02:00
Arne Morten Kvarving 2a9d81227b changed: subclass Main for python
move the initFlowBlackoil method into it

in particular we then avoid the FlowMainType type alias
in Main.hpp
2024-09-09 14:28:20 +02:00
Arne Morten Kvarving 8ed1149252 fix python package versioning
remove opm-models cloning
build both bindings in one build directory
2024-09-09 12:45:00 +02:00
Arne Morten Kvarving a78337fc33 fixed: make python simulator object depend on copy_python
if not building just the python binding won't end up in
a complete build
2024-09-02 08:21:36 +02:00
Arne Morten Kvarving 0203f74b3f add python packaging fluff 2024-08-30 14:28:25 +02:00
Lisa Julia Nebel 42d79ebb97 Delete almost everything of the documentation here, this will be done in a separate repository opm-python-documentation
Keep only the file docstrings.json (renamed to docstrings_simulators.json)
2024-07-10 18:02:41 +02:00
Lisa Julia Nebel fa3392fb7d Use generate_docstring_hpp.py of opm-common and delete the one here 2024-07-09 13:52:01 +02:00
Håkon Hægland 6c3f3af4b4 Docstring fixes 2024-05-02 11:24:58 +02:00
Håkon Hægland a1b7d4b5dd 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.
2024-05-02 11:14:07 +02:00
Arne Morten Kvarving 3475da7d8c Rename ebos_simulator members/parameters to simulator 2024-03-06 10:53:00 +01:00
Arne Morten Kvarving d5748b6c55 Drop ebos in function names 2024-03-06 10:13:01 +01:00
Håkon Hægland 8cbb1707e7 Move statements to after target is defined 2024-03-05 11:11:53 +01:00
Håkon Hægland 1c5143f02e Improve CMakeLists.txt
Add the generated .hpp file directly to pybind11 sources instead of
creating a custom target.
2024-03-05 10:48:04 +01:00
Håkon Hægland e20faa255c Add docstrings for Python bindings 2024-03-05 10:18:54 +01:00
Håkon Hægland 757c67f284 Return vectors by value
Return vectors by value instead of unique pointers to arrays.
2024-03-01 14:22:37 +01:00
Håkon Hægland 55aab60549 Get primary variables and fluid state from Python
Added methods to Python module opm.simulators.BlackOilSimulator to
access primary variables and fluid state variables.
2024-03-01 14:22:35 +01:00
Arne Morten Kvarving f8b22631b0 fixed: don't link python module to flow_libblackoil
this leads to ODR violations which causes all sorts
of havoc. this was done to reuse a trivial method,
duplicate it in the python source instead.
2024-02-29 09:24:07 +01:00
Arne Morten Kvarving 4aa6dc355f rename TTag::EclFlowProblemTPFA to TTag::FlowProblemTPFA 2024-02-23 09:27:48 +01:00
Arne Morten Kvarving b09c70213b FlowMainEbos: rename to FlowMain 2024-02-06 10:42:23 +01:00
Håkon Hægland ac927d997b Added a get_dt() method
Added a get_dt() to the opm.simulators.BlackOilSimulator Python module.
This will return the size of the previous simulator time step.
2023-09-08 19:40:42 +02:00
Håkon Hægland e2f62644ae Get cell volumes from Python
Adds a new method get_cell_volumes() to the opm.simulators Python module
that returns a python list of the cell volumes in the black oil
simulator.
2023-09-08 09:39:24 +02:00
Arne Morten Kvarving c7016854d9 changed: make the deck an implementation detail in Opm::readDeck 2022-11-24 13:00:38 +01:00
Atgeirr Flø Rasmussen a7a5a7a98d Make the Python interface use the TpfaLinearizer. 2022-10-04 11:44:35 +02:00
Markus Blatt 02666a6677 Use CMake's find_file to find install.py for Python installation.
This seems to be a more stable approach as it does not produce
```
/usr/bin/python3.9: can't open file
'/home/mblatt/src/dune/opm-2.9/opm-common//install.py': [Errno 2] No such file or directory
```
for rebuilds after failed attempts.
2022-09-30 18:05:40 +02:00
Håkon Hægland 8e3ce1aed9 Only copy necessary files from python folder
Instead of copying the whole python folder, only copy the necessary files to
the build directory. This means the opm, test, and test_data directories.
2022-06-10 12:19:24 +02:00
Håkon Hægland 8af152dcff Make Python opm package a namespace package
Convert the Python opm package from a regular package to a namespace
package such that opm-simulators and opm-common can contribute to the
package from different filesystem paths. In this way, the two packages
opm.simulators and opm.io (in opm-common) can have a different parent
filesystem path.
2022-06-10 11:37:15 +02:00
Håkon Hægland 19b074805d Use the new opm-common_PYTHON_COMMON_DIR
Use the new opm-common_PYTHON_COMMON_DIR to locate the install.py
script if we are building against an installed opm-common.
2022-06-10 11:31:48 +02:00
Håkon Hægland 9b0c63b325 Also use installed install.py for copy_python
Also use the installed install.py when copying python files at build time
2022-06-10 11:31:48 +02:00
Håkon Hægland 696f830eab Use installed install.py
If we are building against an installed opm-common, use the installed
install.py script instead
2022-06-10 11:31:48 +02:00
Håkon Hægland 3c0498e55f Dynamically update schedule from Python
Adds some test cases that show how injection properties in Opm::Schedule
can be dynamically modified from Python.
2022-06-10 11:31:48 +02:00
Håkon Hægland 91ac3a2a32 Dynamically update schedule from Python
Adds some methods that enables Opm::Schedule to be dynamically modified
from Python. A test case in test_schedule.py illustrates the use case.
2022-05-05 13:10:39 +02:00
Markus Blatt 5c29a3c3e7 Make determining whether to use dist-packages more bullet proof.
Seems like getsitepackages is not always implemented.
2022-03-22 12:06:23 +01:00
Markus Blatt 17ca01b607 [python] Make sure Python files are installed similar to opm-common.
Instead of always using site-packages we query the sitepackages path
from Python. If it matches dist-packages then we use dist-packages if
we install below /usr, otherwise site-packages is used.

This will also make sure that the Python files end up in the same
location as for the ones of opm-common. This should make using them
easier.
2022-03-22 12:06:12 +01:00
Joakim Hove 6b92443cb4 Downstream filesystem reorganisation in opm-common 2022-01-02 14:33:34 +01:00
Arne Morten Kvarving 7f7fbab2f4 remove FLOW_BLACKOIL_ONLY hack from Main.hpp
now that the python simulator uses runStatic, the
runDynamic template is never instanced, and thus there
are no linker issues.
2021-11-10 10:07:11 +01:00