CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Run case with different settings

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By fisichel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 25, 2018, 05:45
Default Run case with different settings
  #1
New Member
 
manu ebn
Join Date: Aug 2015
Location: Switzerland
Posts: 18
Rep Power: 11
Triggin is on a distinguished road
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

Last edited by Triggin; January 25, 2018 at 05:46. Reason: Forgot to mention this:
Triggin is offline   Reply With Quote

Old   January 25, 2018, 10:28
Default Run case with different settings
  #2
New Member
 
Chris Fisichella
Join Date: Oct 2012
Posts: 28
Rep Power: 14
fisichel is on a distinguished road
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 View Post
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 and Eko like this.
fisichel is offline   Reply With Quote

Old   January 26, 2018, 02:50
Default
  #3
New Member
 
manu ebn
Join Date: Aug 2015
Location: Switzerland
Posts: 18
Rep Power: 11
Triggin is on a distinguished road
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 is offline   Reply With Quote

Old   January 26, 2018, 08:15
Default Run case with different settings
  #4
New Member
 
Chris Fisichella
Join Date: Oct 2012
Posts: 28
Rep Power: 14
fisichel is on a distinguished road
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 View Post
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 is offline   Reply With Quote

Old   January 30, 2018, 02:39
Default
  #5
New Member
 
manu ebn
Join Date: Aug 2015
Location: Switzerland
Posts: 18
Rep Power: 11
Triggin is on a distinguished road
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
Triggin is offline   Reply With Quote

Old   January 30, 2018, 08:28
Default
  #6
New Member
 
Chris Fisichella
Join Date: Oct 2012
Posts: 28
Rep Power: 14
fisichel is on a distinguished road
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
fisichel is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some questions about a multi region case run in parallel zfaraday OpenFOAM Running, Solving & CFD 5 February 23, 2017 11:25
cannot run naca0012 case using JST paulocaveman SU2 0 December 26, 2016 02:08
Use XiFoam to run a laminar spherical flame case. fcrl-zxr OpenFOAM Running, Solving & CFD 0 June 8, 2015 12:11
How to run this kind of case? steven123 OpenFOAM Running, Solving & CFD 0 July 8, 2014 15:59
Trying to run a benchmark case with simpleFoam spsb OpenFOAM 3 February 24, 2012 10:07


All times are GMT -4. The time now is 22:59.