CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   bash files: starting test simulation automatically after another test in OpenFOAM (https://www.cfd-online.com/Forums/openfoam-solving/221901-bash-files-starting-test-simulation-automatically-after-another-test-openfoam.html)

C.C November 4, 2019 09:13

bash files: starting test simulation automatically after another test in OpenFOAM
 
Hi all!

I want to simulate one case in OpenFOAM and after it finish and want to simulate another case but I want that it will start automatically. For example, if I have a CFD in-house code developed in fortran I can have a batch file and run a few cases since I have the .exe file. In Ansys Fluent I can create a journal file... It is possible to do something similar in OpenFOAM?

It is possible to not start the simulation manually but instead start it automatically? It would be very useful to start a new simulation automatically mainly for cases which can be finished during the night...


I have been trying with bash files and also phyton, but not successfully unitl now... The bash files that I have start all the simulations at almost the same time and not one after the previous one have finished, my bash file looks like this



#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

nameCases="case_3_15_4 case_3_15_5"


for caseName in $nameCases
do

( cd $caseName && bash simulation.sh )

done




Please anyone can help? Thank you.
BR,

CC

fresty November 4, 2019 10:52

Have you tried the 'wait' command?

Certainly not the best solution but could you not try doing something like this in the main bash file:

Code:

filename_prefix='case_3_15_'
num=0
for num in {0..5};
        cd $filename_prefix$num/
        do
                {solver executable commands}
                cd $main_dir
        done

...and run the pre-processing script(s)/routine bash simulation.sh separately. It may be a good idea to separate the processes.

raumpolizei November 5, 2019 02:31

Hey, you could separate your commands with semicolons:
Code:

cd dir;
bash executableScript;

Cheers RP

C.C November 5, 2019 06:36

To say the truth with some shame, I am quite new working on linux and OpenFOAM. I did not know about the 'wait' command . But now I know this good command and I can put to run batch mode simulations.
Thank you!


All times are GMT -4. The time now is 14:02.