10
PyFoam Manipulating OpenFoam using Python CFD-Meeting | 04.07.18 | PyFoam | Franziska Schulz 1

PyFoam - Wikis...What is PyFoam? „Python library that can manipulate OpenFOAM-casesand control OpenFOAM-runs“ •Python program inbuilt in PyFoam with specific function •Easy

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

  • PyFoam

    Manipulating OpenFoam using Python

    CFD-Meeting | 04.07.18 | PyFoam | Franziska Schulz

    1

  • What is PyFoam?

    „Python library that can manipulate OpenFOAM-casesand control OpenFOAM-runs“

    • Python program inbuilt in PyFoam with specific function

    • Easy to use • Popular

    • Classes• Individual manipulation

    and control

    CFD-Meeting | 04.07.18 | PyFoam | Franziska Schulz

    2

    LibraryUtilities

  • CFD-Meeting | 04.07.18 | PyFoam | Franziska Schulz

    3

    Utilities

    Postprocessing

    Processing

    Preprocessing

    PyFoamPVSnapshot.py: Generates snapshots fromOpenFoam-data using a Paraview-state file

    PyFoamPlotRunner.py: Runs an OpenFoam solver and stores information (residuals, continuity) in a logfile inside the case directory.

    • A list of utilities can be displayed in the console using PyFoam + „tab“• For each utility --help provides specific information

    PyFoamCloneCase.py: Creates a copy of a case with only the most essential files (“0”, ”constant”, ”system”)

  • 1. Clone a template case

    CFD-Meeting | 04.07.18 | PyFoam | Franziska Schulz

    4

    Let‘s have an example: Lid-driven cavity

    3. Display results in Paraview

    2. Run case with changed parameters

    pyFoamCloneCase.py cavity-template cavityUtility --add-item=cavity_state.pvsm

    pyFoamPlotRunner.py --with-all icoFoam

    pyFoamPVSnapshot.py --state-file=cavity_state.pvsm --latest-time cavityUtility

  • CFD-Meeting | 04.07.18 | PyFoam | Franziska Schulz

    5

  • • Write a python script similar to the utilities usingPyFoam classes

    • Individual manipulation and control usingcustomized python programmes

    • Documentation is available as HTML in the pyFoampackage

    CFD-Meeting | 04.07.18 | PyFoam | Franziska Schulz

    6

    Library – PyFoam classes

    Example: Systematic variation of the tangential velocity in the cavity test cae

  • CFD-Meeting | 04.07.18 | PyFoam | Franziska Schulz

    7

    Example Script: „ParameterVariationPyFOAM.py“

    1. Import classes from PyFoam library

    2. Parameter Variation

  • 8

  • CFD-Meeting | 04.07.18 | PyFoam | Franziska Schulz

    9

  • CFD-Meeting | 04.07.18 | PyFoam | Franziska Schulz

    10

    Additional material/References [1] http://openfoamwiki.net/index.php/Contrib/PyFoam

    • Official documentation• Contains list of introducory presentations• Installation instructions

    [2] http://jhoepken.github.io/blog/2012/01/22/parameter-variation-in-openfoam-using-pyfoam• Good overview over imported python classes• Python script example

    You can find the example parameter variation script „ParameterVariationPyFOAM.py“ in the Wiki

    THANK YOU!

    http://openfoamwiki.net/index.php/Contrib/PyFoamhttp://jhoepken.github.io/blog/2012/01/22/parameter-variation-in-openfoam-using-pyfoam