Scripts to manage OpenFOAM cases
Dear foamers,
I am wondering how to write a script to manage OpenFOAM cases. Since I need to simulate 2D airfoil flow at different angle of attacks. Everytime I have to copy the case files and change the velocity and lift and drag direction. This method is time consuming and use a lot of disk. I know that using a script to mange the case and change the boundary condition is possible, anyone can give me some hints? Best regards, Ye |
you can use a custom dict, containing AoA in your case.
in your files 0/U etc include your dict und use variables depending on the entries in your dict. for example Ux #calc "$myVelocity*cos($myAoA)"; ... fixedValue ($Ux $Uy $Uz) referring to myVelocity and myAoA in your dict. this way, you only have to change the myAoA entry in a single dict to modify the case. Further, you can also use a shellscript to do the following steps for a whole list of prepared dict-files: copy dict_#i into the case, ./Allrun case, make directory anywhere/#i copy relevant output to anywhere/#i, ./Allclean case there might be more elegant ways, but it should work ;) |
I had a similar requirement, for which I created Python scripts (using some of pyFoam's functionality) to manage my case files and the automation of multiple CFD simulations.
|
Thank you Logan!
Cause I am quite new to OpenFOAM. It will be better if you can describe it more detail. Best regards, Ye |
4 Attachment(s)
Hi
I effectively set up code as described in the attached images. Attachment 25806 Attachment 25807 The OpenFoam utilities and solvers where called (run) through the use of pyFoam. http://openfoamwiki.net/index.php/Contrib_PyFoam In my case the mesh file was also scripted / generated in Python and then used in blockMesh, but you can easily use another meshing program like gmsh coupled to Python. The general process I followed is:
Attachment 25808 Attachment 25809 |
hello,
Like Logan say, take a look at pyFoam http://openfoamwiki.net/index.php/Contrib_PyFoam There is a full section about manipulating case. You can also change boundary with the changeDictionary commande, usin a "changeDictionnaryDict" file. regards, olivier |
Quote:
|
Quote:
It's hard to find a Linux distribution that hasn't got Python installed But if you want to use PyFoam: yes. Python is necessary |
Quote:
thanks |
If you want your life to be easy and enjoyable, I'd suggest sticking to a linux distribution and never use Windows for Openfoam simulations.
|
Quote:
|
All times are GMT -4. The time now is 02:16. |