-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/mcgoldba/pyFoamd into main
Conflicts: pyFoamd.egg-info/SOURCES.txt
- Loading branch information
Showing
22 changed files
with
361 additions
and
51 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Build distribution | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
pypi-publish: | ||
name: Upload release to PyPI | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/pyfoamd | ||
steps: | ||
# retrieve your distributions here | ||
|
||
- name: Publish package distributions to PyPI | ||
if: github.repository == 'mcgoldba/pyfoamd' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.pypi_password }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## 0.0.3 (2023-10-02) | ||
|
||
### Fix | ||
|
||
- Corrected setup entry point | ||
|
||
## 0.0.2 (2023-10-02) | ||
|
||
### Fix | ||
|
||
- reorganized private methods | ||
|
||
## 0.0.1 (2023-10-02) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,149 @@ | ||
# pyFoamd | ||
pyFoamd | ||
------- | ||
|
||
Pythonic modification of OpenFOAM dictionaries and case files. | ||
|
||
Features | ||
-------- | ||
|
||
* Load OpenFOAM cases as Python objects | ||
* Read and edit OpenFOAM dictionary entries | ||
* Manipulated OpenFOAM cases from command line using the integrated iPython console | ||
* Manipulate OpenFOAM cases from a Python script file. | ||
* Support for most OpenFOAM naitive types including: | ||
* dictonary entries, lists, scalars, vectors, tensors, dimensioned types, tables, coded objects, and more | ||
* Run OpenFOAM case Allrun scripts | ||
* Easily setup and execute parametric OpenFOAM studies with many simulations | ||
|
||
Installation | ||
------------ | ||
|
||
```bash | ||
#terminal | ||
python -m pip install pyfoamd | ||
``` | ||
|
||
Basic Usage | ||
----------- | ||
|
||
Copy a template case and load as a python object | ||
```bash | ||
#terminal | ||
cp $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily . | ||
cd pitzDaily | ||
pf init | ||
``` | ||
|
||
View case variables | ||
```bash | ||
#terminal | ||
pf edit | ||
``` | ||
|
||
```python | ||
#Python console | ||
>>> case.constant.turbulenceProperties.RAS.RASModel | ||
kEpsilon | ||
``` | ||
Change case dictionary entries | ||
|
||
```python | ||
#Python console | ||
>>> case.constant.case.constant.turbulenceProperties.RAS.RASModel = kOmega | ||
``` | ||
|
||
Write the updated case to file | ||
|
||
```python | ||
#Python console | ||
>>> case.write() | ||
``` | ||
|
||
Run the Allrun script | ||
```python | ||
#Python console | ||
>>> case.run() | ||
``` | ||
|
||
Scripting | ||
--------- | ||
|
||
PyFoamd can also be imported into a python script to allow for manipultion of OpenFOAM cases. This is useful, for example, when performing parameteric studies to run multiple simulations with varibale parameters (e.g. different turbulence models): | ||
|
||
```bash | ||
#terminal | ||
#- Setup the OpenFOAM study directory | ||
cd ~ | ||
mkdir ofStudy | ||
cd ofStudy | ||
cp $FOAM_TEMPLATES/incompressible/simpleFoam/pitzDaily of.template | ||
touch runStudy.py | ||
``` | ||
|
||
runStudy.py | ||
```python | ||
import pyfoamd.functions as pf | ||
import pyfoamd.types as pt | ||
import pamdas as pd | ||
|
||
turbulenceModels = [kEpsilon, realizableKE, kOmega, kOmegaSST] | ||
parameterNames = ['Turbulence Model'] | ||
|
||
samples = pd.DataFrame( | ||
[[model] for model in turbulenceModels], | ||
columns = parameterNames | ||
) | ||
|
||
def updateCase(case, values): | ||
""" | ||
This function is called from the ofStudy. | ||
Parameters | ||
---------- | ||
case [pyfoamd.ofCase]: | ||
The OpenFOAM case which is to be updated. | ||
values [list]: | ||
Sample point as a list of dictionary values to be updated for the current simulation | ||
Return | ||
------ | ||
case [pyfoamd.ofCase]: | ||
The updated OpenFOAM case. | ||
""" | ||
turbModel = values[0] | ||
|
||
case.constant.case.constant.turbulenceProperties.RAS.RASModel = turbModel | ||
|
||
return case | ||
|
||
#- Create the OpenFOAM study | ||
study = pt.ofStudy('of.template', parameterNames, sample, updateCase) | ||
|
||
#- Run all 4 simulations | ||
study.run() | ||
|
||
``` | ||
|
||
```bash | ||
#terminal | ||
# Run the study | ||
python runStudy.py | ||
``` | ||
|
||
Releasing | ||
--------- | ||
|
||
Releases are published automatically when a tag is pushed to GitHub. | ||
|
||
```bash | ||
# Set next version number | ||
export RELEASE=x.x.x | ||
|
||
# Create tags | ||
git commit --allow-empty -m "Release $RELEASE" | ||
git tag -a $RELEASE -m "Version $RELEASE" | ||
|
||
# Push | ||
git push upstream --tags | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
from setuptools import setup, find_packages | ||
import toml | ||
from pathlib import Path | ||
|
||
pyproject_path = str(Path(__file__).parent / 'pyproject.toml') | ||
file = open(pyproject_path, "r") | ||
toml_str = file.read() | ||
|
||
parsed_toml = toml.loads(toml_str) | ||
|
||
with open('README.md') as f: | ||
readme = f.read() | ||
|
@@ -8,14 +16,15 @@ | |
|
||
setup( | ||
name='pyFoamd', | ||
version='0.1.0', | ||
version=parsed_toml['tool']['commitizen']['version'], | ||
description='Pythonic interface for OpenFOAM dictionaries and case files.', | ||
entry_points = { | ||
'console_scripts': [ | ||
'pf = pyfoamd.__main__:main' | ||
] | ||
}, | ||
long_description=readme, | ||
long_description_content_type='text/markdown', | ||
author='Marc Goldbach', | ||
author_email='[email protected]', | ||
url='https://github.com/mcgoldba/pyFoamd', | ||
|
@@ -25,6 +34,7 @@ | |
install_requires=[ | ||
'pint', | ||
'pandas', | ||
'rich' | ||
'rich', | ||
'ipython' | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
Metadata-Version: 2.1 | ||
Name: pyFoamd | ||
Version: 0.1.0 | ||
Summary: Pythonic interface for OpenFOAM dictionaries and case files. | ||
Home-page: https://github.com/mcgoldba/pyFoamd | ||
Author: Marc Goldbach | ||
Author-email: [email protected] | ||
Name: pyfoamd | ||
Version: 0.0.2 | ||
Author-email: Marc Goldbach <[email protected]> | ||
License: GNU GENERAL PUBLIC LICENSE | ||
Version 3, 29 June 2007 | ||
|
||
|
@@ -680,8 +677,80 @@ License: GNU GENERAL PUBLIC LICENSE | |
Public License instead of this License. But first, please read | ||
<https://www.gnu.org/licenses/why-not-lgpl.html>. | ||
|
||
Project-URL: Home, https://github.com/mcgoldba/pyFoamd | ||
Requires-Python: >=3.7 | ||
Description-Content-Type: text/markdown | ||
License-File: LICENSE | ||
Requires-Dist: pint | ||
Requires-Dist: pandas | ||
Requires-Dist: rich | ||
Requires-Dist: ipython | ||
|
||
pyFoamd | ||
------- | ||
|
||
# pyFoamd | ||
Pythonic modification of OpenFOAM dictionaries and case files. | ||
|
||
Installation | ||
------------ | ||
|
||
.. code-block:: bash | ||
|
||
python -m pip install pyfoamd | ||
|
||
Basic Usage | ||
----------- | ||
|
||
Copy a template case and load as a python object | ||
|
||
.. code-block:: bash | ||
|
||
cp $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily . | ||
cd pitzDaily | ||
pf init | ||
|
||
View case variables | ||
|
||
.. code-block:: bash | ||
|
||
pf edit | ||
|
||
.. code-block:: python | ||
|
||
>>> case.constant.turbulenceProperties.RAS.RASModel | ||
kEpsilon | ||
|
||
Change case dictionary entries | ||
|
||
.. code-block:: python | ||
|
||
>>> case.constant.case.constant.turbulenceProperties.RAS.RASModel = kOmega | ||
|
||
Write the updated case to file | ||
|
||
.. code-block:: python | ||
|
||
>>> case.write() | ||
|
||
Run the Allrun script | ||
|
||
.. code-block:: python | ||
|
||
>>> case.run() | ||
|
||
Releasing | ||
--------- | ||
|
||
Releases are published automatically when a tag is pushed to GitHub. | ||
|
||
.. code-block:: bash | ||
|
||
# Set next version number | ||
export RELEASE=x.x.x | ||
|
||
# Create tags | ||
git commit --allow-empty -m "Release $RELEASE" | ||
git tag -a $RELEASE -m "Version $RELEASE" | ||
|
||
# Push | ||
git push upstream --tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.