|
[Sponsors] |
March 28, 2022, 19:34 |
Automating Openfoam
|
#1 |
New Member
Aniruddha Saha
Join Date: Mar 2022
Posts: 9
Rep Power: 4 |
Hi all,
Could you please guide me with the possible ways of automating openfoam using shell script or any other method? I am using Ubuntu and it gets difficult to enter the OpenFoam environment using shell script. |
|
March 29, 2022, 03:09 |
|
#2 |
Senior Member
Uwe Pilz
Join Date: Feb 2017
Location: Leipzig, Germany
Posts: 744
Rep Power: 15 |
OF is a command line driven programm. It can be skripted easily.
__________________
Uwe Pilz -- Die der Hauptbewegung überlagerte Schwankungsbewegung ist in ihren Einzelheiten so hoffnungslos kompliziert, daß ihre theoretische Berechnung aussichtslos erscheint. (Hermann Schlichting, 1950) |
|
March 29, 2022, 10:15 |
|
#3 |
New Member
Aniruddha Saha
Join Date: Mar 2022
Posts: 9
Rep Power: 4 |
I know it is a command line software and hence I said I need some help with the way how to do it
|
|
March 29, 2022, 15:03 |
|
#4 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
You can try out pyfoam. https://openfoamwiki.net/index.php/Contrib/PyFoam
Have a look. Maybe it helps |
|
April 1, 2022, 08:36 |
Example
|
#5 |
Member
Join Date: Mar 2018
Posts: 33
Rep Power: 8 |
Here is an example of a script in shell.
How to run a script (input in shell window): Code:
./scriptname.sh I have 73 folders with names AoA0, AoA5 etc. For each of them, openfoam gets inside the folder, decomposes the case in parallel, runs simplefoam in parallel, reconstructs the parallel folders, and then runs foamlog Script: Code:
#!/bin/bash #cd "${0%/*}" || exit # Run from this directory folders=( AoA0 AoA5 AoA10 AoA15 AoA20 AoA25 AoA30 AoA35 AoA40 AoA45 AoA50 AoA55 AoA60 AoA65 AoA70 AoA75 AoA80 AoA85 AoA90 AoA95 AoA100 AoA105 AoA110 AoA115 AoA120 AoA125 AoA130 AoA135 AoA140 AoA145 AoA150 AoA155 AoA160 AoA165 AoA170 AoA175 AoA180 AoA185 AoA190 AoA195 AoA200 AoA205 AoA210 AoA215 AoA220 AoA225 AoA230 AoA235 AoA240 AoA245 AoA250 AoA255 AoA260 AoA265 AoA270 AoA275 AoA280 AoA285 AoA290 AoA295 AoA300 AoA305 AoA310 AoA315 AoA320 AoA325 AoA330 AoA335 AoA340 AoA345 AoA350 AoA355 AoA360) for i in ${folders[@]} ; do cd $i echo "Carpeta actual: $i" decomposePar mpiexec -n 4 simpleFoam >log -parallel reconstructPar foamLog log cd .. done |
|
April 1, 2022, 10:46 |
|
#6 |
Senior Member
Chris Sideroff
Join Date: Mar 2009
Location: Ottawa, ON, CAN
Posts: 434
Rep Power: 22 |
<cue shameless plug>
We've developed an open-source Python library, called CPL, that does precisely this: https://caelus.readthedocs.io/en/latest/ Check out the Parametric Runs section to automate multiple CFD runs. You install it with, ideally, conda or pip. The source code is available here: https://bitbucket.org/appliedccm/cpl/src/master/ Despite Caelus (an OpenFOAM derivative) being in the name, it works equally well with OpenFOAM. -Chris |
|
April 11, 2022, 17:10 |
|
#7 |
Senior Member
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5 |
||
April 11, 2022, 17:15 |
|
#8 |
Senior Member
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5 |
For general scripting help, I found this tutorial really useful when I started using Ubuntu and OpenFOAM.
I recently started using PyFoam (as mentioned above by mAlletto). It is incredibly useful for automating setup of various dicts etc for parametric studies and does not require a massive amount of python experience. If you are having issues accessing openfoam environment when using shell script, it sounds like your foam is not installed correctly, or you have some fundamental issue in your bash script. Joszef Nagy has some videos on installation I believe. Maybe they will be useful for you. |
|
April 11, 2022, 17:32 |
|
#9 |
New Member
Aniruddha Saha
Join Date: Mar 2022
Posts: 9
Rep Power: 4 |
Thanks a lot for your message ! I am trying to learn using PyFoam. My doubt regarding she’ll script was using it to modify text files such as BlockMeshDict and even exporting values from the vtk files. But now I think after all these helps, I’ll be able to pull off.
|
|
April 12, 2022, 05:15 |
|
#10 | |
Senior Member
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5 |
Quote:
|
||
Tags |
automating, shell script, terminal |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Frequently Asked Questions about Installing OpenFOAM | wyldckat | OpenFOAM Installation | 3 | November 14, 2023 12:58 |
How to develop OpenFOAM with CMake and popular IDEs | cosscholar | OpenFOAM Programming & Development | 0 | March 16, 2022 16:17 |
OpenFOAM Foundation releases OpenFOAM® 3.0.0 | CFDFoundation | OpenFOAM Announcements from OpenFOAM Foundation | 1 | November 7, 2015 16:16 |
OpenFOAM Training, London, Chicago, Munich, Sep-Oct 2015 | cfd.direct | OpenFOAM Announcements from Other Sources | 2 | August 31, 2015 14:36 |
64bitrhel5 OF installation instructions | mirko | OpenFOAM Installation | 2 | August 12, 2008 19:07 |