Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/mcgoldba/pyFoamd into main
Browse files Browse the repository at this point in the history
Conflicts:
	pyFoamd.egg-info/SOURCES.txt
  • Loading branch information
mcgoldba committed Jan 30, 2024
2 parents 5983ebb + 1f4e0e0 commit 2e1e13d
Show file tree
Hide file tree
Showing 22 changed files with 361 additions and 51 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/github-actions-demo.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/release.yml
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 }}
13 changes: 13 additions & 0 deletions CHANGELOG.md
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)
11 changes: 11 additions & 0 deletions Pipfile
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"
149 changes: 148 additions & 1 deletion README.md
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
```
14 changes: 12 additions & 2 deletions setup.py → _setup.py
100755 → 100644
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()
Expand All @@ -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',
Expand All @@ -25,6 +34,7 @@
install_requires=[
'pint',
'pandas',
'rich'
'rich',
'ipython'
]
)
83 changes: 76 additions & 7 deletions pyFoamd.egg-info/PKG-INFO
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

Expand Down Expand Up @@ -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
12 changes: 11 additions & 1 deletion pyFoamd.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LICENSE
README.md
setup.py
pyproject.toml
pyFoamd.egg-info/PKG-INFO
pyFoamd.egg-info/SOURCES.txt
pyFoamd.egg-info/dependency_links.txt
Expand All @@ -11,15 +11,24 @@ pyfoamd/__init__.py
pyfoamd/__main__.py
pyfoamd/functions.trash.py
pyfoamd/richinclude.py
pyfoamd.egg-info/PKG-INFO
pyfoamd.egg-info/SOURCES.txt
pyfoamd.egg-info/dependency_links.txt
pyfoamd.egg-info/entry_points.txt
pyfoamd.egg-info/requires.txt
pyfoamd.egg-info/top_level.txt
pyfoamd/commandline/__init__.py
pyfoamd/commandline/_iPython_env.py
pyfoamd/functions/__init__.py
pyfoamd/functions/_interpretUnitsAndConvert.py
pyfoamd/functions/_unitDecoder.py
pyfoamd/functions/allRun.py
pyfoamd/functions/appendEntry.py
pyfoamd/functions/clean.py
pyfoamd/functions/cleanDictFile.py
pyfoamd/functions/cloneCase.py
pyfoamd/functions/cloneCases.py
pyfoamd/functions/dictUtil.py
pyfoamd/functions/extractLogData.py
pyfoamd/functions/foamVersion.py
pyfoamd/functions/getLatestTime.py
Expand All @@ -41,6 +50,7 @@ pyfoamd/functions/plot.py
pyfoamd/functions/printInputs.py
pyfoamd/functions/readCaseFromCache.py
pyfoamd/functions/readConfig.py
pyfoamd/functions/readDict.py
pyfoamd/functions/readDictFile.py
pyfoamd/functions/readInputs.py
pyfoamd/functions/removeBlockEntries.py
Expand Down
Loading

0 comments on commit 2e1e13d

Please sign in to comment.