Commit Graph
59 Commits
Author SHA1 Message Date
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
Arne Morten Kvarving 9c38f01997 changed: vendor pybind11 using FetchContent 2023-11-16 10:02:04 +01:00
Tor Harald Sandve 968686e7e0 Merge pull request #4943 from hakonhagland/pybind3
Get simulator time step size from Python BlackOilSimulator module
2023-10-26 11:28:42 +02:00
Tor Harald Sandve 922fa5b9bf Merge pull request #4853 from hakonhagland/pybind2
Get cell volumes from Python
2023-10-24 13:56:58 +02:00
Håkon Hægland 8849c7d357 Removed reference to unit system
The unit system is not used in this example, so we can remove it.
2023-09-25 11:01:12 +02:00
Håkon Hægland 9778929a81 Added some Python documentation 2023-09-25 10:18:13 +02: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 063e336ec6 Remove SYSTEM argument for cmake >= 3.12
Remove SYSTEM argument for pybind11_add_module() if cmake version is
greater than 3.12. It appears that this argument has been deprecated
and also removed by the new FindPython mode in the cmake tools for
pybind11.
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
Arne Morten Kvarving 3a512c0f20 changed: use runStatic in python simulator 2021-11-10 09:51:17 +01:00
Håkon Hægland 7a394df43f Include <stdexcept> header to use std::logic_error()
And some minor stylistic changes.
2021-09-23 13:13:23 +02:00
Håkon Hægland 4c5245196b Changed calling convention for shared pointers.
Expect non-reference type shared pointers arguments instead of references
to shared pointer. This will make it clear to the caller that the called
function is making a copy of the pointer for its own use and not trying
to modify the original pointer of the caller.
2021-09-22 23:49:13 +02:00
Håkon Hægland 5ad65c70ee Initialize blackoil simulator from schedule shared with Python.
Adds a new constructor to Main.hpp that takes shared pointers to Deck,
EclipseState, Schedule, and SummaryConfig. This makes it possible to
share these variables with Python without worrying about lifetime issues
of the underlying C++ objects. For example, a Python script can first
create an opm.io.schedule.Schedule object which is modified from Python.
Then, assume the same Python script creates an
opm.simulators.BlackOilSimulator which is initialized with the same
schedule object. Since the underlying C++ object is a shared pointer,
the Schedule object in Python may go out of scope (get deleted by Python)
without having the C++ schedule object being deleted. And the Python
BlackOilSimulator may continue to be used after the Python Schedule object
has been deleted since it still has a valid C++ schedule object.
2021-09-21 15:52:59 +02:00
Markus Blatt 755c23bfb5 Support using pybind from the system.
This should make packaging easier and more streamlined
to the process on some Linux systems.
2021-03-19 19:56:53 +01:00
Arne Morten Kvarving 16d644032c add cmake option to disable the python tests
due to bugs in the openmpi on bionic, this test fails to
execute properly in pbuilder environments. instead
of rebuilding openmpi without dynamic loading
(which is the suggested fix) and potentially break users
systems, this is a non-intrusive workaround to be used
for packaging.

also add explicit option for python support to make it
visible in cmake frontends.
2020-11-18 10:55:46 +01:00
Håkon Hægland b680d96198 The data directory is relative to the parent.
The test data directory is relative to the parent directory, not the
current directory.
2020-11-05 09:48:39 +01:00
Joakim Hove 68e8c4a900 Use python pushd 2020-11-04 14:24:39 +01:00
Håkon Hægland 7011a6c0b7 Restore cwd after each unittest.
Restores the original cwd after each unittest in test_basic.py. Also
simplifies add_test() in python/simulators/CMakeLists.txt such that the
Bash script wrapper run-python-tests.sh is no longer needed to run the
tests.
2020-11-04 13:51:36 +01:00
Håkon Hægland 648bab7108 Implements access to the porosity from Python.
Implements access (read/write) to the porosity from Python.
2020-11-03 17:18:14 +01:00
Håkon Hægland 53cbe0c57e Initialize boolean variables in-class.
Initialize the boolean variables hasRunInit_ and hasRunCleanup_ in
the class instead of in the constructor.
2020-11-03 16:17:52 +01:00
Håkon Hægland 0403d4e6e7 Implements a Python step_cleanup() method.
Continues the work in #2735 on implementing Python bindings for the flow
simulator.
2020-11-03 16:12:12 +01:00
Arne Morten Kvarving d286079393 changed: reuse objects if building python inline 2020-09-25 13:47:39 +02:00
Håkon Hægland 81319a7923 Implements the Python step() method.
A resubmission of commit 8e4f748 in PR #2403 and PR #2444 and continues
the work in #2690 implementing Python bindings to the flow simulator.

The Python step() method advances the simulator one report step. Before
calling step() for the first time, step_init() must have been called.
2020-08-25 13:42:48 +02:00
Håkon Hægland 3749dcab7d Implements the Python step_init() function.
A resubmission of commit 11eaa3d7 in PR #2403 and PR #2443 and continues
the work in #2555 implementing Python bindings to the flow simulator.

The step_init() method initializes the simulation. It is required for the
Python script to run step_init() before calling the step() method (which
will be implemented in a later commit).
2020-08-24 10:27:50 +02:00
Arne Morten Kvarving c4be14c0da mark the pybind11 headers SYSTEM to avoid (shadowing) warnings 2020-05-14 11:12:15 +02:00