Getting OpenFOAM result using python script

A subforum specific to the development of the OpenFoam-based workbenches ( Cfd and CfdOF )

Moderator: oliveroxtoby

Post Reply
Posts: 54
Joined: Tue Aug 27, 2019 4:33 pm

Getting OpenFOAM result using python script

Post by S-Y.Chen »

Hi There,

Is it possible to get the result of OpenFOAM using the python scripts ? I am mostly interested in getting result like flow rate/pressure on a specific inlet/outlet/face or other quantities.

Or is it possible to get into these values into the Spreadsheet ?

If it is not possible, which file or data should I look in into ? I am interested in the text data so that maybe I can process it by myslef.

Any guideline ?

Your help is greatly appreciated.

S-Y. Chen
Posts: 85
Joined: Tue May 04, 2021 12:17 am

Re: Getting OpenFOAM result using python script

Post by KAKM »

That should be pretty straightforward. OpenFOAM saves its results to a file (or files) in the case directory, so you can do a typical file read to get into them. They're put under folders numbered with the timestep (e.g., the 0 folder holds the initial conditions). I don't remember if CfdOF imports them back into FreeCAD in a way that's more convenient for that, but I suspect it doesn't, since the post-processing is primarily done in ParaView.

If you want an idea of how to approach that, you might want to look into PyFOAM. Here's a pretty good introduction on how to use it: ... aining.pdf
Post Reply