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/)
-   -   Run case with different settings (https://www.cfd-online.com/Forums/openfoam-solving/198060-run-case-different-settings.html)

Triggin January 25, 2018 04:45

Run case with different settings
 
Hello Foamers

I had a quick look, but since I didn't find a single hit on google, I will ask the question right here:

How can I run an OpenFOAM case automatically with different settings?
Lets say I would like to compare different schemes. How can I programm this?
Does this have to edited in the "Allrun"-shell?

It would be desirable if I get all the results in the same main folder. And, after I run foamToVTK, I can load all results out of the same folder.

Every input is warmly welcome!

Thank you
Triggin

fisichel January 25, 2018 09:28

Run case with different settings
 
Hi Triggin,

OpenFoam uses text files, as you probably already know. I don't know of a facility within OpenFoam to run several jobs in the same run folder. You can, however, create different run folders. Using the Allrun script will help run them automatically.

You will have to load the results out of different folders, however.

HTH,
Chris

Quote:

Originally Posted by Triggin (Post 679323)
Hello Foamers

I had a quick look, but since I didn't find a single hit on google, I will ask the question right here:

How can I run an OpenFOAM case automatically with different settings?
Lets say I would like to compare different schemes. How can I programm this?
Does this have to edited in the "Allrun"-shell?

It would be desirable if I get all the results in the same main folder. And, after I run foamToVTK, I can load all results out of the same folder.

Every input is warmly welcome!

Thank you
Triggin


Triggin January 26, 2018 01:50

Hi fisichel, thank you for the answer.

Okay. So probably i have to set a for-loop (e.g. for an array of different inlet velocities) in the Allrun-script. As soon as the calculation is finished, rename the solution folder and lets the case run again with the new velocity.

At the end i could automatically move all .vtk-files into the same folder, to have all together.

If anyone did something similar already, please let us know.

I will start to do something like this and would post the script here (this won't happen before the mid of february).

Best wishes
Triggin

fisichel January 26, 2018 07:15

Run case with different settings
 
Hi,

That sounds like a very reasonable approach. You don't necessarily have to use a shell script. Python, C, or some other language could be used. Like you pointed out, you just need to have file interrogation and file manipulation facilities to do what you need to do.

It's too bad you have to wait blindly for the vtk files. Are you able to look at the output and decide on a new value? That might help direct your calculations better. OpenFoam can also output force files. They are easy to query.

Best Regards,
Chris

Quote:

Originally Posted by Triggin (Post 679460)
Hi fisichel, thank you for the answer.

Okay. So probably i have to set a for-loop (e.g. for an array of different inlet velocities) in the Allrun-script. As soon as the calculation is finished, rename the solution folder and lets the case run again with the new velocity.

At the end i could automatically move all .vtk-files into the same folder, to have all together.

If anyone did something similar already, please let us know.

I will start to do something like this and would post the script here (this won't happen before the mid of february).

Best wishes
Triggin


Triggin January 30, 2018 01:39

For the ones who are interested in:

I just made a shell script which is able to set up different simulations, based on different values (cf. the array rollVel and inletVel).

Code:

#!/bin/sh

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

# Main directory
myOrigin=$(pwd)
# Create VTK directory
mkdir VTK

# Setting the case-name array
rollVel[0]=000
rollVel[1]=010
rollVel[2]=020
rollVel[3]=040
rollVel[4]=060
rollVel[5]=080
rollVel[6]=100

inletVel[0]=0.2
inletVel[1]=0.6
inletVel[2]=1.0
inletVel[3]=1.4
inletVel[4]=1.8
inletVel[5]=2.2

echo ${#rollVel[@]}

for ((myi=0; myi < ${#rollVel[@]}; myi++ ))
do
    for ((myj=0; myj < ${#inletVel[@]}; myj++ ))
    do

      # Build filename
      a0='RV'
      a1=${rollVel[myi]}
      a2='_IV'
      a3=${inletVel[myj]}
      a4=$a0$a1$a2$a3
      printf '<%s>\n' "$a4"

      # Create folder and put the files in there
      mkdir $a4
      cp -r 0 $a4
      cp -r constant $a4
      cp -r system $a4
     
      # Change directory
      cd $a4/0/include
      # Edit files
      sed -i "s/tempInlet/${inletVel[myj]}/" "initialConditions"
      sed -i "s/tempRoll/${rollVel[myj]}/" "initialConditions"

      # Run from the parent directory (../caseName)
      cd ../..
      # cd ${0%/*} || exit 1   
      echo "current directory" $(pwd)
      application=`getApplication`

      # Run Case
      runApplication decomposePar # > log &
      runParallel $application 10 # > log &
      runApplication reconstructParMesh -constant # > log &
      runApplication reconstructPar -latestTime # > log &
      runApplication foamToVTK # > log &

      rm -rf processor*

      cd $myOrigin

    done
done

Quote:

It's too bad you have to wait blindly for the vtk files. Are you able to look at the output and decide on a new value?
I am not done yet and will extend the script with some utilities which should deliver me some indications based on which i have to decide if i use laminar or turbulence models, etc.

Thanks to Chris for your support :)

Best regards
Triggin

fisichel January 30, 2018 07:28

Very cool. That's all there is to it. This is one of my favorite features of OpenFOAM. It's transparent. Good luck!

Best,
Chris


All times are GMT -4. The time now is 17:05.