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

Allrun in background

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 30, 2016, 03:14
Default Allrun in background
  #1
New Member
 
Hagen
Join Date: Nov 2016
Posts: 16
Rep Power: 9
HagenC is on a distinguished road
Hi everyone,
I have a question concerning the Allrun script in background mode. Running Allrun redirects the output to log files, but still the command window is blocked for new commands. I tried running the script in background by
Code:
./Allrun &
But still the command window is blocked.

Thank you for your help.
HagenC is offline   Reply With Quote

Old   November 30, 2016, 16:41
Default
  #2
Member
 
Rodrigo
Join Date: Mar 2010
Posts: 98
Rep Power: 16
guin is on a distinguished road
simplest way: edit the script Allrun, so that it uses foamJob utility.
Replace the line where the solver call appears (i.e. runApplication $yourSolverName)by:
foamJob $yourSolverName

in case of working in parallel you shall rather use
foamJob -parallel $yourSolverName
(no need to specify the number of processes, that is read automatically from system/decomposeParDict)

other (less recommended) possibilities:
a. stop process and send it to background manually
./Allrun &
Ctrl+Z
bg

b. use nohup utility:
nohup ./Allrun &
guin is offline   Reply With Quote

Old   January 9, 2017, 04:53
Default
  #3
New Member
 
Hagen
Join Date: Nov 2016
Posts: 16
Rep Power: 9
HagenC is on a distinguished road
Thank you very much for your reply.
foamJob works, but then I get another problem when using several commands that should be executed one after another, like in the following example:
Code:
foamJob snappyHexMesh
foamJob simpleFoam
The execution of simpleFoam does not wait until snappyHexMesh is finished.
I tried
Code:
foamJob snappyHexMesh
wait
foamJob simpleFoam
But without success.
Has someone an idea on that?
Thank you very much.
HagenC is offline   Reply With Quote

Old   January 9, 2017, 05:07
Default
  #4
Member
 
Rodrigo
Join Date: Mar 2010
Posts: 98
Rep Power: 16
guin is on a distinguished road
Quote:
Originally Posted by HagenC View Post
Thank you very much for your reply.
foamJob works, but then I get another problem when using several commands that should be executed one after another, like in the following example:
Code:
foamJob snappyHexMesh
foamJob simpleFoam
The execution of simpleFoam does not wait until snappyHexMesh is finished.
I tried
Code:
foamJob snappyHexMesh
wait
foamJob simpleFoam
But without success.
Has someone an idea on that?
Thank you very much.
Hi,
that is because foamJob executes the process in the background, so the next command does not have yo wait for it to finish before being executed. Try out to call snappyHexMesh using "runApplication" instead of "foamJob" .
guin is offline   Reply With Quote

Old   January 9, 2017, 05:10
Default
  #5
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 20
floquation will become famous soon enough
What exactly does your script look like?

If I have a prepareCase script like:
Code:
##### Prepare Case #####
echo "> Preparing case."
if [ ! -d "./logs" ]; then
    mkdir "./logs"
fi
[ -d 0 ] && 'rm' -rf 0
cp -r 0.org 0
# Mesh
echo "----> blockMesh"
blockMesh > ./logs/blockMesh.log || exit 1
# setFields
echo "----> setFields"
mv "0/alpha.water.org" "0/alpha.water"
setFields > ./logs/setFields.log || exit 1
I can run it in the background by:
Code:
./prepareCase.sh &
Or silently:
Code:
./prepareCase.sh > log &
All commands inside the prepareCase.sh script are executed sequentially - as they should.
If this is not the case for you, I presume that you have inserted some background "&"s inside the script?
floquation is offline   Reply With Quote

Old   January 9, 2017, 05:27
Default
  #6
New Member
 
Hagen
Join Date: Nov 2016
Posts: 16
Rep Power: 9
HagenC is on a distinguished road
Thank you again for your very quick answers!
My original ./Allrun file was:
Code:
#!/bin/sh
cd ${0%/*} || exit 1

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

runApplication blockMesh
runApplication surfaceFeatureExtract
runApplication snappyHexMesh -overwrite
runApplication simpleFoam
runApplication foamToVTK
And had the problem of blocked command window as described in the first post. So I changed the ./Allrun file to:
Code:
#!/bin/sh
cd ${0%/*} || exit 1

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

foamJob blockMesh
foamJob surfaceFeatureExtract
foamJob snappyHexMesh -overwrite
foamJob simpleFoam
foamJob foamToVTK
And had the problem of waiting for the previous job to be finished as described in the second post. By changing it to:
Code:
#!/bin/sh
cd ${0%/*} || exit 1

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

runApplication blockMesh
runApplication surfaceFeatureExtract
runApplication snappyHexMesh -overwrite
foamJob simpleFoam
runApplication foamToVTK
Then the problem is the foamToVTK not being executed after the solution process. Further I would like to have the snappyHexMesh also running in the background.
Cheers.
HagenC is offline   Reply With Quote

Old   January 9, 2017, 06:26
Default
  #7
Member
 
Rodrigo
Join Date: Mar 2010
Posts: 98
Rep Power: 16
guin is on a distinguished road
Hi,

You original Allrun file was OK. You can just call it by using one of my previously called "less-recommended" options "a" or "b" (post #2):

Personally, I would use option "a" because I don't like the logfile written by nohup.

Your second version of the Allrun file is definitetly not a good idea. Short (and surely oversimplified) hint: use foamJob only for calling the solver and ensure that it is the last action in your Allrun file.

There would be more possibilities of having it done, but I think there is no point on getting more into deep on this in this forum, provided the given options shall just work and have the additional advantage of being simple...

Last edited by guin; January 9, 2017 at 06:29. Reason: added link to previous post
guin is offline   Reply With Quote

Old   January 9, 2017, 08:28
Default
  #8
New Member
 
Hagen
Join Date: Nov 2016
Posts: 16
Rep Power: 9
HagenC is on a distinguished road
Yes, thanks guin.
Version a is exactly what I needed.
HagenC is offline   Reply With Quote

Old   November 26, 2019, 04:09
Default
  #9
New Member
 
Arne
Join Date: Dec 2018
Posts: 19
Rep Power: 7
arsimons is on a distinguished road
Quote:
Originally Posted by floquation View Post
What exactly does your script look like?

If I have a prepareCase script like:
Code:
##### Prepare Case #####
echo "> Preparing case."
if [ ! -d "./logs" ]; then
    mkdir "./logs"
fi
[ -d 0 ] && 'rm' -rf 0
cp -r 0.org 0
# Mesh
echo "----> blockMesh"
blockMesh > ./logs/blockMesh.log || exit 1
# setFields
echo "----> setFields"
mv "0/alpha.water.org" "0/alpha.water"
setFields > ./logs/setFields.log || exit 1
I can run it in the background by:
Code:
./prepareCase.sh &
Or silently:
Code:
./prepareCase.sh > log &
All commands inside the prepareCase.sh script are executed sequentially - as they should.
If this is not the case for you, I presume that you have inserted some background "&"s inside the script?

Hello Foamers!


I am currently trying to work on a local cluster via ssh. I was just wondering about the advantage of using the standard 'Allrun' script which has a header and uses 'runApplication', as compared to the script I quote from floquation?



Thanks in advance.


Best regards
Arne Simons
arsimons is offline   Reply With Quote

Reply

Tags
allrun background


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
A few questions about Gmsh: Background Mesh and Tutorial 7 SeanQuallen Main CFD Forum 2 November 27, 2017 03:28
Overset: refine background mesh without resetting the mesh JohnAB STAR-CCM+ 6 May 19, 2014 13:48
[Gmsh] background mesh in gmsh Nick_J OpenFOAM Meshing & Mesh Conversion 1 March 20, 2013 04:20
Background Image in Post ellevset CFX 4 April 1, 2009 11:01
Change Background Color Anindya Siemens 3 February 26, 2001 11:40


All times are GMT -4. The time now is 23:57.