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

running OF on local machine with batch script / job scheduler

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By mturcios777

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 2, 2010, 11:14
Default running OF on local machine with batch script / job scheduler
  #1
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 96
Rep Power: 17
val46 is on a distinguished road
Hi,
I would like to run simpleFoam in batch mode on a local machine with 4 cores.
Has anyone a simple script with I could use? (My c++ skills are very limited)

Thanks in advance

Best Regards,
Toni
val46 is offline   Reply With Quote

Old   November 2, 2010, 13:07
Default
  #2
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Do you want to run one case on each core? If that is the case then you can probably just use this (assuming you are in a bash environment):

Code:
#!/bin/bash

CASE1=/location/of/1st/case
CASE2=/location/of/2nd/case
CASE3=/location/of/3rd/case
CASE4=/location/of/4th/case

cd $CASE1
foamJob simpleFoam
cd $CASE2
foamJob simpleFoam
cd $CASE3
foamJob simpleFoa
cd $CASE4
foamJob simpleFoam
Scripting is a worthwhile skill to learn. I used this tutorial to get me started:
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Dohyun likes this.
mturcios777 is offline   Reply With Quote

Old   November 2, 2010, 13:13
Default
  #3
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 96
Rep Power: 17
val46 is on a distinguished road
Hi Marco,
thanks for your reply.
Quote:
Do you want to run one case on each core?
No, I would like to run a case with 4 nodes and after it has finished a new case (also with 4 nodes) should start automatically.


Regards,
Toni
val46 is offline   Reply With Quote

Old   November 2, 2010, 13:27
Default
  #4
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
Ah, then you'll need to use
1. decomposePar to split the simulation domain
2. mpirun to run the solver in parallel

The dam-break tutorial shows you how to work with parallel cases. Once you figure that out, then you should have a clear idea of how to change the above script
mturcios777 is offline   Reply With Quote

Old   November 2, 2010, 14:05
Default
  #5
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 96
Rep Power: 17
val46 is on a distinguished road
No,no! I know how to run a parallel case.
I need a script to start cases automatically.
The script should always check if a case is running or if the cores are "occupied". If so than "wait", if not than "start another case".

Hope you know what I mean.
val46 is offline   Reply With Quote

Old   November 2, 2010, 14:39
Default
  #6
Member
 
Lars Kiewidt
Join Date: Sep 2009
Location: Germany
Posts: 54
Rep Power: 17
LarsPT is on a distinguished road
Just write a script, that executes all the OpenFOAM commands and then just write several commands divided by semicolons. The script may look like this! Take care of the paths (relative or absolute, it's your choice). The script below is for relative paths, e.g. your cases are in the OF-run folder.

Code:
/!bin/bash

JOBNAME=$1

cd $JOBNAME

blockMesh
setFields
decomposePar
mpirun -np 4 simpleFoam -parallel > log.simpleFoam
reconstructPar
sample
rm -r processor*

cd ..
Then you can type in a terminal:

Code:
user:~/OpenFOAM/username-1.x/run$ batchOF <JobName1>; batchOF <JobNameN>;
Of course you have to change the username to your username and the version of OF.

Lars
LarsPT is offline   Reply With Quote

Old   November 2, 2010, 16:58
Default OpenFoam Built-In run functions
  #7
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
How about using OF built in run functions?

they are in

Code:
$WM_PROJECT_DIR/bin/tools/RunFunctions
and are used in all the Allrun scripts in openfoam that are in the tutorials. Take a look at the Allrun script in the interFoam tutorial folder. A simple one I use for simpleFoam is:

Code:
#!/bin/sh
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

cd case1
    runApplication decomposePar
    hostname > system/machines
    runParallel simpleFoam 4 system/machines
    runApplication reconstructPar
cd ..
change the 4 to whatever number of processors you want and make sure it agrees with the decomposeparDict file.

This is assuming that you run it from above the case1 folder (or whatever case name you want), you have a correct decomposeParDict file, and there are no other files that have log.decomposePar, log.simpleFoam, or log.reconstructPar in the case folder or the run functions will detect them and not run. Each of the run functions will wait for the previous one to finish before being executed. Just copy the code to a text file, make the text file executable, and call it with ./(file name without parenthesis).

Alternatively, you can use some of the handy scripts in pyFoam (http://openfoamwiki.net/index.php/Contrib_PyFoam) but that takes some time to set up. Although its really worth it in the end...or at least I like it for some. Hope this helps.

Dan
chegdan is offline   Reply With Quote

Old   November 2, 2010, 17:49
Default
  #8
Senior Member
 
Philippose Rajan
Join Date: Mar 2009
Location: Germany
Posts: 552
Rep Power: 25
philippose will become famous soon enough
Hello,

A Good Evening to you!

I would strongly suggest that you consider using a load-balancing system such as Condor or the SUN GridEngine.

Even though you are talking about one local multi-core computer, a system such as Condor can help you quite a bit because you can submit multiple parallel jobs at the same time.... and the jobs go into a Queue which is automatically queried and handled by the software which runs as a service on your Linux system.

Condor runs the first simulation, and once that has been completed, it automatically starts the next job in the queue, and so on.

Later on in the future extending the setup to use more than one computer is trivial, because Condor is basically a "Cluster" tool, and has been designed to work with multiple systems over networks.

Hope this helps.

Philippose
philippose is offline   Reply With Quote

Old   November 4, 2010, 04:47
Default
  #9
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 96
Rep Power: 17
val46 is on a distinguished road
HAHA! Stupid me!
I know about the allrun scripts but somehow I wasn't aware of the fact that they can exactly do what I want.

Thank you for the hint, Dan!


I tried the following:
Code:
runApplication snappyHexMesh -overwrite

runApplication transformPoints -scale "(0.001 0.001 0.001)"

runApplication potentialFoam -writep

runApplication decomposePar -force

hostname > system/machines

runParallel simpleFoam 4 system/machines

runApplication reconstructPar -latestTime
But got an error message from the transformPoints command:

Code:
Wrong number of arguments, expected 0 found 2
Because of that I had to write these additional lines:

Code:
runtransformPoints()
{
    if [ -f log.transformPoints ]
    then
        echo "transformPoints already run on $PWD: remove log file to run"
    else
        echo "transformPoints: converting mesh"
        transformPoints -scale "($1 $2 $3)" > log.transformPoints 2>&1
    fi
}

runtransformPoints 0.001 0.001 0.001
Than it worked but I'm not very happy with it.
Why is the transformPoints command not working in the script?
I also tried ' instead of " but without success.


Best Regards,
Toni
val46 is offline   Reply With Quote

Old   November 4, 2010, 10:57
Default did you try no quotation marks?
  #10
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Im not near a Linux computer right now...but try

Code:
runApplication transformPoints -scale (0.001 0.001 0.001)
instead of
Code:
runApplication transformPoints -scale "(0.001 0.001 0.001)"
to pass numbers like that in the script you don't need the "" in that case i believe.

Dan
chegdan is offline   Reply With Quote

Old   November 4, 2010, 11:17
Default
  #11
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Scratch that, try

Code:
vector=(0.001 0.001 0.001)
runApplication transformPoints -scale $vector
instead and see what you get.

Dan

Quote:
Originally Posted by chegdan View Post
Im not near a Linux computer right now...but try

Code:
runApplication transformPoints -scale (0.001 0.001 0.001)
instead of
Code:
runApplication transformPoints -scale "(0.001 0.001 0.001)"
to pass numbers like that in the script you don't need the "" in that case i believe.

Dan
chegdan is offline   Reply With Quote

Old   November 9, 2010, 05:20
Default
  #12
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 96
Rep Power: 17
val46 is on a distinguished road
Hi Dan,

I tried what you suggested:
Code:
vector=(0.001 0.001 0.001)
runApplication transformPoints -scale $vector
But I got the following error message:
Code:
--> FOAM FATAL IO ERROR: 
Expected a '(' while reading VectorSpace<Form, Cmpt, nCmpt>, found on line 0 the doubleScalar 0.001

file: IStringStream.sourceFile at line 0.

    From function Istream::readBegin(const char*)
    in file db/IOstreams/IOstreams/Istream.C at line 86.
Any ideas?

Regards,
Toni
val46 is offline   Reply With Quote

Old   November 9, 2010, 10:24
Default
  #13
mgd
New Member
 
Join Date: Dec 2009
Location: UK
Posts: 2
Rep Power: 0
mgd is on a distinguished road
I believe the correct syntax is

Code:
transformPoints -scale '(0.001 0.001 0.001)'

i.e. you need a single quotes '....' to wrap the vector
mgd is offline   Reply With Quote

Old   November 10, 2010, 04:22
Default
  #14
Member
 
Join Date: Nov 2009
Location: Germany
Posts: 96
Rep Power: 17
val46 is on a distinguished road
Quote:
Originally Posted by mgd View Post
I believe the correct syntax is

Code:
transformPoints -scale '(0.001 0.001 0.001)'
i.e. you need a single quotes '....' to wrap the vector
This is the correct command in a console but not in a script.
val46 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
Running icepak on a linux machine Codemaster FLUENT 0 November 20, 2008 01:50
How to specify the iterations of a batch job Consol Main CFD Forum 0 October 19, 2008 00:42
Batch job M. Malik Main CFD Forum 6 February 12, 2008 10:49
How to create Batch job for CFX-10 in Linux OS siv CFX 2 March 21, 2006 04:38
submit batch job using PBS ali CFX 1 October 27, 2005 14:11


All times are GMT -4. The time now is 11:56.