Skip to main content

Python Interface to OpenFOAM (Configured Using YAML)

Project description

Contributors Forks Stargazers Issues GPL-3.0 License


Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

This repository was originally designed to solve the problem of complex OpenFOAM case structure, and the solution was to re-present the original cases using the common configuration file format YAML. Later, since there is a corresponding package for the YAML format in Python, I wrote this Python interface package for OpenFOAM, and then I added progress bars to most OpenFOAM solvers by analyzing log files in real time. Although there are still many details to be specified in this repository, its function of generating cases and calling solvers is ready for preliminary use, for example, I used this package to generate cases in batch in my own project. In the future I would like to integrate the post-processing steps into this interface package as well.

(back to top)

Built With

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

This project currently uses Poetry to manage Python dependencies. I've heard good things about PDM so far, and may provide PDM support subsequently. If Poetry is not installed, you can refer to official installation guide.

Installation

  1. Clone the repository
    git clone https://github.com/iydon/of.yaml.git
    
  2. Install Python dependencies
    poetry install --extras full
    
  3. Activate the virtual environment
    poetry shell
    
  4. (Optional) Convert Python package into a single file
    make standalone
    

(back to top)

Usage

Demo

Save the following demo code as a separate file (e.g. demo.py).

from foam import Foam

foam = Foam.from_file('tutorials/incompressible/simpleFoam/airFoil2D.yaml')
foam.save('airFoil2D')
foam.cmd.all_run()

Running the demo code in the virtual environment results in the following output.

$ poetry run python demo.py
Running simpleFoam on .../of.yaml/airFoil2D
 63%|██████████████████████████████████████▏                      | 313.0/500.0 [00:06<00:04, 46.66it/s]

Tutorials

The following table shows the OpenFOAM cases that have been converted to YAML format. You can find the corresponding rules by comparing the YAML format with its original format, and I don't have the time or interest to organize the corresponding documentation for the time being.

The existing OpenFOAM tutorials in YAML format
YAML OpenFOAM Version Solver
airFoil2D.yaml airFoil2D 7 incompressible/simpleFoam
beamEndLoad.yaml beamEndLoad 7 stressAnalysis/solidEquilibriumDisplacementFoam
boxTurb16.yaml boxTurb16 7 DNS/dnsFoam
cylinder.yaml cylinder 7 basic/potentialFoam
damBreak.yaml damBreak 7 multiphase/interMixingFoam
damBreak4phase.yaml damBreak4phase 7 multiphase/multiphaseInterFoam
damBreak4phaseFine.yaml damBreak4phaseFine 7 multiphase/multiphaseInterFoam
damBreakWithObstacle.yaml damBreakWithObstacle 7 multiphase/interFoam
DTCHull.yaml DTCHull 7 multiphase/interFoam
elbow.yaml elbow 7 incompressible/icoFoam
europeanCall.yaml europeanCall 7 financial/financialFoam
fileHandler.yaml fileHandler 7 lagrangian/icoUncoupledKinematicParcelFoam
flange.yaml flange 7 basic/laplacianFoam
mixerVessel2D.yaml mixerVessel2D 7 multiphase/multiphaseInterFoam
nozzleFlow2D.yaml nozzleFlow2D 7 multiphase/interFoam
pipeCyclic.yaml pipeCyclic 7 incompressible/simpleFoam
pitzDaily.yaml pitzDaily 7 basic/potentialFoam
pitzDaily.yaml pitzDaily 7 basic/scalarTransportFoam
plateHole.yaml plateHole 7 stressAnalysis/solidDisplacementFoam
sloshingTank3D6DoF.yaml sloshingTank3D6DoF 7 multiphase/interFoam
propeller.yaml propeller 7 multiphase/interPhaseChangeFoam
mixerVesselAMI.yaml mixerVesselAMI 7 multiphase/interFoam
sloshingTank2D.yaml sloshingTank2D 7 multiphase/compressibleInterFoam
damBreak4phase.yaml damBreak4phase 7 multiphase/compressibleMultiphaseInterFoam
flamePropagationWithObstacles.yaml flamePropagationWithObstacles 7 combustion/PDRFoam
kivaTest.yaml kivaTest 7 combustion/XiEngineFoam
moriyoshiHomogeneous.yaml moriyoshiHomogeneous 7 combustion/XiFoam
throttle.yaml throttle 7 multiphase/cavitatingFoam
throttle3D.yaml throttle3D 7 multiphase/cavitatingFoam
throttle.yaml throttle 7 multiphase/cavitatingFoam
nacaAirfoil.yaml nacaAirfoil 7 compressible/rhoPimpleFoam

Task List

The following is a task list to convert OpenFOAM-7 to the corresponding YAML format. The corresponding rules for conversion are not currently organized because some of them are still unstable. I will first try to convert as many tutorials as possible, and then organize the rules afterwards.

Conversion task list
  • DNS
    • dnsFoam
      • boxTurb16
  • IO
    • fileHandler
  • basic
    • laplacianFoam
      • flange
    • potentialFoam
      • cylinder
      • pitzDaily
    • scalarTransportFoam
      • pitzDaily
  • combustion
    • PDRFoam
      • flamePropagationWithObstacles
    • XiEngineFoam
      • kivaTest
    • XiFoam
      • RAS
        • moriyoshiHomogeneous
    • chemFoam
      • gri
      • h2
      • ic8h18
      • ic8h18_TDAC
      • nc7h16
    • coldEngineFoam
      • freePiston
    • fireFoam
      • LES
        • flameSpreadWaterSuppressionPanel
        • oppositeBurningPanels
        • smallPoolFire2D
        • smallPoolFire3D
    • reactingFoam
      • RAS
        • DLR_A_LTS
        • SandiaD_LTS
        • membrane
      • laminar
        • counterFlowFlame2D
        • counterFlowFlame2DLTS
        • counterFlowFlame2DLTS_GRI_TDAC
        • counterFlowFlame2D_GRI
        • counterFlowFlame2D_GRI_TDAC
  • compressible
    • rhoCentralFoam
      • LadenburgJet60psi
      • biconic25-55Run35
      • forwardStep
      • movingCone
      • obliqueShock
      • shockTube
      • wedge15Ma5
    • rhoPimpleFoam
      • LES
        • pitzDaily
      • RAS
        • aerofoilNACA0012
        • angledDuct
        • angledDuctLTS
        • annularThermalMixer
        • cavity
        • mixerVessel2D
        • nacaAirfoil
        • prism
        • squareBendLiq
      • laminar
        • blockedChannel
        • decompressionTank
        • forwardStep
        • helmholtzResonance
        • shockTube
    • rhoPorousSimpleFoam
      • angledDuctExplicit
      • angledDuctImplicit
    • rhoSimpleFoam
      • aerofoilNACA0012
      • angledDuctExplicitFixedCoeff
      • squareBend
      • squareBendLiq
  • discreteMethods
    • dsmcFoam
      • freeSpacePeriodic
      • freeSpaceStream
      • supersonicCorner
      • wedge15Ma5
    • molecularDynamics
      • mdEquilibrationFoam
        • periodicCubeArgon
        • periodicCubeWater
      • mdFoam
        • nanoNozzle
  • electromagnetics
    • electrostaticFoam
      • chargedWire
    • mhdFoam
      • hartmann
  • financial
    • financialFoam
      • europeanCall
  • heatTransfer
    • buoyantPimpleFoam
      • BernardCells
      • hotRoom
      • hotRoomBoussinesq
    • buoyantSimpleFoam
      • buoyantCavity
      • circuitBoardCooling
      • externalCoupledCavity
      • hotRadiationRoom
      • hotRadiationRoomFvDOM
      • hotRoomBoussinesq
      • iglooWithFridges
    • chtMultiRegionFoam
      • coolingSphere
      • heatExchanger
      • heatedDuct
      • reverseBurner
      • shellAndTubeHeatExchanger
  • incompressible
    • SRFPimpleFoam
      • rotor2D
    • SRFSimpleFoam
      • mixer
    • adjointShapeOptimizationFoam
      • pitzDaily
    • boundaryFoam
      • boundaryLaunderSharma
      • boundaryWallFunctions
      • boundaryWallFunctionsProfile
    • icoFoam
      • cavity
        • cavity
        • cavityClipped
        • cavityGrade
      • elbow
    • nonNewtonianIcoFoam
      • offsetCylinder
    • pimpleFoam
      • LES
        • channel395
      • RAS
        • TJunction
        • TJunctionFan
        • elipsekkLOmega
        • impeller
        • oscillatingInletACMI2D
        • pitzDaily
        • pitzDailyLTS
        • propeller
        • wingMotion
      • laminar
        • blockedChannel
        • mixerVesselAMI2D
        • movingCone
        • offsetCylinder
        • planarContraction
        • planarCouette
        • planarPoiseuille
    • pisoFoam
      • LES
        • motorBike
        • pitzDaily
        • pitzDailyMapped
      • RAS
        • cavity
        • cavityCoupledU
      • laminar
        • porousBlockage
    • porousSimpleFoam
      • angledDuctExplicit
      • angledDuctImplicit
      • straightDuctImplicit
    • shallowWaterFoam
      • squareBump
    • simpleFoam
      • T3A
      • airFoil2D
      • mixerVessel2D
      • motorBike
      • pipeCyclic
      • pitzDaily
      • pitzDailyExptInlet
      • rotorDisk
      • turbineSiting
      • windAroundBuildings
  • lagrangian
    • DPMFoam
      • Goldschmidt
    • MPPICFoam
      • Goldschmidt
      • column
      • cyclone
      • injectionChannel
    • coalChemistryFoam
      • simplifiedSiwek
    • icoUncoupledKinematicParcelFoam
      • hopper
        • hopperEmptying
        • hopperInitialState
      • mixerVesselAMI2D
    • reactingParcelFoam
      • counterFlowFlame2DLTS
      • cylinder
      • filter
      • hotBoxes
      • parcelInBox
      • rivuletPanel
      • splashPanel
      • verticalChannel
      • verticalChannelLTS
    • simpleReactingParcelFoam
      • verticalChannel
    • sprayFoam
      • aachenBomb
  • mesh
    • blockMesh
      • pipe
      • sphere
      • sphere7
      • sphere7ProjectedEdges
    • foamyHexMesh
      • blob
      • flange
      • mixerVessel
      • simpleShapes
      • straightDuctImplicit → ../../incompressible/porousSimpleFoam/straightDuctImplicit
    • foamyQuadMesh
      • jaggedBoundary
      • square
    • moveDynamicMesh
      • SnakeRiverCanyon
    • refineMesh
      • refineFieldDirs
    • snappyHexMesh
      • flange
      • iglooWithFridges → ../../heatTransfer/buoyantSimpleFoam/iglooWithFridges
      • motorBike → ../../incompressible/simpleFoam/motorBike
  • multiphase
    • cavitatingFoam
      • LES
        • throttle
        • throttle3D
      • RAS
        • throttle
    • compressibleInterFoam
      • laminar
        • climbingRod
        • depthCharge2D
        • depthCharge3D
        • sloshingTank2D
    • compressibleMultiphaseInterFoam
      • laminar
        • damBreak4phase
    • driftFluxFoam
      • RAS
        • dahl
        • mixerVessel2D
        • tank3D
    • interFoam
      • LES
        • nozzleFlow2D
      • RAS
        • DTCHull
        • DTCHullMoving
        • DTCHullWave
        • angledDuct
        • damBreak
        • damBreakPorousBaffle
        • floatingObject
        • mixerVesselAMI
        • waterChannel
        • weirOverflow
      • laminar
        • capillaryRise
        • damBreak
        • damBreakWithObstacle
        • mixerVessel2D
        • sloshingCylinder
        • sloshingTank2D
        • sloshingTank2D3DoF
        • sloshingTank3D
        • sloshingTank3D3DoF
        • sloshingTank3D6DoF
        • testTubeMixer
        • wave
    • interMixingFoam
      • laminar
        • damBreak
    • interPhaseChangeFoam
      • cavitatingBullet
      • propeller
    • multiphaseEulerFoam
      • bubbleColumn
      • damBreak4phase
      • damBreak4phaseFine
      • mixerVessel2D
    • multiphaseInterFoam
      • laminar
        • damBreak4phase
        • damBreak4phaseFine
        • mixerVessel2D
    • potentialFreeSurfaceFoam
      • movingOscillatingBox
      • oscillatingBox
    • reactingMultiphaseEulerFoam
      • RAS
        • wallBoiling1D_2phase
        • wallBoiling1D_3phase
      • laminar
        • bed
        • bubbleColumn
        • bubbleColumnFixedPolydisperse
        • bubbleColumnPolydisperse
        • mixerVessel2D
        • trickleBed
    • reactingTwoPhaseEulerFoam
      • LES
        • bubbleColumn
      • RAS
        • LBend
        • bubbleColumn
        • bubbleColumnEvaporatingReacting
        • bubbleColumnPolydisperse
        • fluidisedBed
        • wallBoiling
        • wallBoiling1D
        • wallBoilingIATE
        • wallBoilingPolyDisperse
      • laminar
        • bubbleColumn
        • bubbleColumnEvaporating
        • bubbleColumnEvaporatingDissolving
        • bubbleColumnIATE
        • fluidisedBed
        • injection
        • mixerVessel2D
        • steamInjection
    • twoLiquidMixingFoam
      • lockExchange
    • twoPhaseEulerFoam
      • LES
        • bubbleColumn
      • RAS
        • bubbleColumn
        • fluidisedBed
      • laminar
        • bubbleColumn
        • bubbleColumnIATE
        • fluidisedBed
        • injection
        • mixerVessel2D
  • resources
    • geometry
  • stressAnalysis
    • solidDisplacementFoam
      • plateHole
    • solidEquilibriumDisplacementFoam
      • beamEndLoad

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repository and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the GPL-3.0 License. See LICENSE.txt for more information.

(back to top)

Contact

Iydon Liang - @iydon - liangiydon_AT_gmail.com

(back to top)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ifoam-0.11.2.tar.gz (46.2 kB view hashes)

Uploaded Source

Built Distribution

ifoam-0.11.2-py3-none-any.whl (52.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page