|
| 1 | +# README # |
| 2 | + |
| 3 | +### What is this? ### |
| 4 | + |
| 5 | +This section contains OpenFOAM code and tutorials that show how to use Python interpreters to interact with OpenFOAM via pythonPal. pythonPal offers Python support and interoperability between the C++/Python data based on the pybind11 library [1]. The code in this repository is based on OpenFOAM-9, however, as noted below, the procedures are expected to compile with similar versions and forks of OpenFOAM. |
| 6 | + |
| 7 | +### [Manual approach] How do I get set up? ### |
| 8 | + |
| 9 | +In addition to an installation of OpenFOAM-9, a Python installation is required. The following libraries are required to run the tutorials: |
| 10 | + |
| 11 | +* Python 3.8.12 |
| 12 | + |
| 13 | +* NumPy 1.18.5 |
| 14 | + |
| 15 | +* pybind11 2.8.1 |
| 16 | + |
| 17 | +These libraries can be installed from the supplied pythonpal-no-gpu.yml file using the conda software (https://conda.io). Once conda is installed, the Python environment is installed with: |
| 18 | + |
| 19 | + conda env create -f pythonPal-no-gpu.yml |
| 20 | + |
| 21 | +The conda environment can be activated with: |
| 22 | + |
| 23 | + conda activate pythonPal-no-gpu |
| 24 | + |
| 25 | +Please be aware that the examples may not work with other versions of Python libraries, although they are likely to work with similar versions, e.g. Python 3.8.*. |
| 26 | + |
| 27 | +In addition, two pybind11 environment variables must be defined, for example, as: |
| 28 | + |
| 29 | + export PYBIND11_INC_DIR=$(python3 -m pybind11 --includes) |
| 30 | + export PYBIND11_LIB_DIR=$(python3 -c 'from distutils import sysconfig; print(sysconfig.get_config_var("LIBDIR"))') |
| 31 | + |
| 32 | +Once those environment variables have been defined, the OpenFOAM code included in the current section can be compiled with the Allwmake script in the parent folder: |
| 33 | + |
| 34 | + ./Allwmake |
| 35 | + |
| 36 | +If the Allwmake script gives the error “libpython or lpython not found” then please manually update the LD_LIBRARY_PATH environment variable with "export LD_LIBRARY_PATH=$PYBIND11_LIB_DIR:$LD_LIBRARY_PATH” and run the “./Allwmake” command again. |
| 37 | + |
| 38 | +This will install: |
| 39 | + |
| 40 | +**./applications/solvers/**: |
| 41 | + |
| 42 | +* pythonPalIcoFoam: This is a version of icoFoam that, once the simulation has converged, passes the velocity field to Python where the specific kinetic energy (k) is calculated. Then, OpenFOAM prints the k field. |
| 43 | + |
| 44 | +### How do I run the cases? ### |
| 45 | + |
| 46 | +Currently, there is only one tutorial case which solves the cavity case using pythonPalIcoFoam, as explained in the paper. To run it: |
| 47 | + |
| 48 | + cd tutorials/pythonPalIcoFoam/cavity |
| 49 | + ./Allrun |
| 50 | + |
| 51 | +### Compatible OpenFOAM versions ### |
| 52 | + |
| 53 | +pythonPal is independent of the OpenFOAM version/fork and is expected to work with all main versions. The included code compiles with the following versions and forks (it will probably work with others too): |
| 54 | + |
| 55 | +* OpenFOAM-9 |
| 56 | +* OpenFOAM-v2012 |
| 57 | +* foam-extend-4.1 |
| 58 | + |
| 59 | +The presented tutorial has been tested using these three versions. |
| 60 | + |
| 61 | +If desired, the user can make the small changes required to get the cases to work with their particular version of OpenFOAM. |
| 62 | + |
| 63 | + |
| 64 | +### Who do I talk to? ### |
| 65 | + |
| 66 | + Simon Rodriguez |
| 67 | + simon.rodriguezluzardo@ucdconnect.ie |
| 68 | + https://www.linkedin.com/in/simonrodriguezl/ |
| 69 | + |
| 70 | + Philip Cardiff |
| 71 | + philip.cardiff@ucd.ie |
| 72 | + https://www.linkedin.com/in/philipcardiff/ |
| 73 | + |
| 74 | + |
| 75 | +### References ### |
| 76 | + |
| 77 | +[1] W. Jakob, J. Rhinelander, and D. Moldovan, “pybind11 – Seamless operability between C++11 and Python.” 2017. |
0 commit comments