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

bash script for pseudo-parallel usage of reconstructPar

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree8Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   August 18, 2014, 02:06
Default
  #21
Member
 
hannes
Join Date: Mar 2013
Posts: 38
Rep Power: 4
hanness is on a distinguished road
Hi,
could you post some more information about your case? From what you are writing I would assume that you only have two timesteps to reconstruct because the way the script is written it will never start more jobs than there are timesteps left.

Hannes
hanness is offline   Reply With Quote

Old   September 11, 2014, 05:40
Default Error while running parReconstructPar
  #22
kcn
New Member
 
Join Date: May 2014
Posts: 29
Rep Power: 3
kcn is on a distinguished road
Hi,

I get the following error while trying to run parReconstructPar.

Starting Job 1 - reconstructing time = 0.1 through 166.6
Job started with PID 10452
Starting Job 2 - reconstructing time = 166.7 through 234.1
Job started with PID 10462
Starting Job 3 - reconstructing time = 234.2 through 31.7
Job started with PID 10472
Starting Job 4 - reconstructing time = 31.8 through 300
Job started with PID 10482


--> FOAM FATAL ERROR:
No times selected

From function reconstructPar
in file reconstructPar.C at line 210.

FOAM exiting

If you notice the time ranges in job 3 and 4 there a bit strange too.

Can someone please tell me how to correct this?

Thanks
kcn
kcn is offline   Reply With Quote

Old   September 11, 2014, 05:54
Default
  #23
Senior Member
 
Bernhard Linseisen
Join Date: May 2010
Location: Magdeburg/Geneva
Posts: 178
Blog Entries: 1
Rep Power: 7
Linse is on a distinguished road
Hi kcn!

I can only GUESS, but is it maybe related to the timestep given in your controlDict?
Otherwise: Did you already try if it would work with two processors only? Maybe the division of timesteps is giving values which do not work?
Or maybe you could try to decompose timestep 0 as well, so it would work beginning from timestep 0 instead of 0.1?

As I said: It is all only guessing, but I think these would be the approaches I would take for further testing...

Cheers,
Bernhard
Linse is offline   Reply With Quote

Old   September 11, 2014, 18:27
Default Minor Fix to get all numeric directories
  #24
New Member
 
Will
Join Date: Dec 2011
Posts: 15
Rep Power: 5
willzyba is on a distinguished road
The errors reported above are due to a bug in the way the script lists list the time files in processor0. They needed to be ordered by value using the "1v" flag, otherwise you can get the times in the wrong order, e.g. ... 0.7, 0.8, 1, 10, 1.1, 1.2 ....

If the number of processors is such that one processor picks up the range from 10 to 1.9 (say), when it should be from 1.1 to 1.9, then you have a problem.

Simply replace all occurrences of "ls processor0 | ...." with "ls processor0 -1v | ...."

Modified script attached.

parReconstructPar.txt

Otherwise a great script. Thankyou.
elvis likes this.
willzyba is offline   Reply With Quote

Old   September 18, 2014, 01:45
Default
  #25
kcn
New Member
 
Join Date: May 2014
Posts: 29
Rep Power: 3
kcn is on a distinguished road
Dear Will,

Thank you very much for the corrected script.

kcn
kcn is offline   Reply With Quote

Old   October 7, 2014, 06:21
Default
  #26
New Member
 
sd
Join Date: May 2014
Posts: 14
Rep Power: 3
OvGU is on a distinguished road
Quote:
Originally Posted by kwardle View Post
All,
I thought I would post this as maybe someone else will find it useful. I wrote a short script (not necessarily pretty, but it works...) that runs reconstructPar in pseudo-parallel mode by breaking the time directories into a number of ranges and running multiple instances of reconstructPar. For lack of a better name I have called it parReconstructPar.
Enjoy.
-Kent

(The forum won't take a file without an extension so it is uploaded as a .txt -- just save it somewhere in your path as parReconstructPar and make it executable.)


I tried to put your file in my case directory and execute ./parReconstructPar but it doesn't work. Again I put it in my opt/bin directory for in case but also failed. Can you tell me where Im making mistake??
OvGU is offline   Reply With Quote

Old   October 7, 2014, 07:08
Default
  #27
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 296
Rep Power: 9
jherb is on a distinguished road
Have you set the executable flag?
Code:
chmod a+x parReconstructPar
In any case you should be able to start it with
Code:
sh parReconstructPar
kwardle likes this.
jherb is offline   Reply With Quote

Old   October 14, 2014, 04:52
Default
  #28
New Member
 
Jim KIT
Join Date: Aug 2012
Location: Germany
Posts: 23
Rep Power: 5
sharifi is on a distinguished road
Hallo,

thanks for sharing.
I'm doing a parallel simulation in OpenFoam and because of the limitation of files numbers in my computer, I have to prevent, that data be increased exponentially.
I have somehow no experience in bash scripting and I want to write a script, that after a certains time lets say 1 min search if there is a new time in processor0. It should than reconstract this new time and delete it in all the processors. Its clear that it shoud be able to run during the simulation.

I would appreciate if sombody can help me

thx
sharifi is offline   Reply With Quote

Old   December 7, 2014, 11:56
Default
  #29
New Member
 
Jaap Stolk
Join Date: Nov 2014
Posts: 4
Rep Power: 2
jwstolk is on a distinguished road
Dear Will,

I'm very happy with this script, but I would like to point out that there still is a small overlap in the detected time ranges when decimals are involved:

Starting Job 1 - reconstructing time = 0.25 through 30.5
Starting Job 2 - reconstructing time = 30.25 through 60.5

(I can only run 2 reconstructs in parallel on a single machine (16 GB ram limit)
but the script parameters make it very easy to manually divide the reconstructing over 2 or 3 machines.)

edit:
this example is a bit more problematic, I may have to run 30.5 manually:
Starting Job 1 - reconstructing time = 0.25 through 30.25
Starting Job 2 - reconstructing time = 30.75 through 61

Last edited by jwstolk; December 7, 2014 at 12:45. Reason: (another example)
jwstolk is offline   Reply With Quote

Old   December 14, 2014, 22:53
Default
  #30
New Member
 
ALLEN
Join Date: Aug 2014
Posts: 27
Rep Power: 3
allenfieldin is on a distinguished road
Quote:
Originally Posted by jwstolk View Post
Dear Will,

I'm very happy with this script, but I would like to point out that there still is a small overlap in the detected time ranges when decimals are involved:

Starting Job 1 - reconstructing time = 0.25 through 30.5
Starting Job 2 - reconstructing time = 30.25 through 60.5

(I can only run 2 reconstructs in parallel on a single machine (16 GB ram limit)
but the script parameters make it very easy to manually divide the reconstructing over 2 or 3 machines.)

edit:
this example is a bit more problematic, I may have to run 30.5 manually:
Starting Job 1 - reconstructing time = 0.25 through 30.25
Starting Job 2 - reconstructing time = 30.75 through 61

hello, jwstolk

I am using the tool on HPC, but can tell me how to tun this application, I have put the script in the directory where pro* files are stored. and when I run "parReconstructPar 12",it simply give me a error of "Command not found".

Quote:
[atlas7-c01]$ parReconstructPar 12
bash: parReconstructPar: command not found
[atlas7-c01]$ .parReconstructPar
bash: .parReconstructPar: command not found
[atlas7-c01]$ ./parReconstructPar
bash: ./parReconstructPar: Permission denied
[atlas7-c01]$ sh parReconstructPar

K. Wardle 6/22/09, modified by H. Stadler Dec. 2013, minor fix Will Bateman Sep 2014.
bash script to run reconstructPar in pseudo-parallel mode
by breaking time directories into multiple ranges


USAGE: parReconstructPar -n <NP> -f fields -o <OUTPUTFILE>
-f (fields) is optional, fields given in the form T,U,p; option is passed on to reconstructPar
-t (times) is optional, times given in the form tstart,tstop
-o (output) is optional

[atlas7-c01]$ parReconstructPar 12
bash: parReconstructPar: command not found
[atlas7-c01]$
I think something wrong with the use, can you help me out and tell me the exact usage running parReconstructPar, I am a new user for foam and HPC both.

very much appreciated if you can do any help.

/Allen
allenfieldin is offline   Reply With Quote

Old   December 15, 2014, 17:22
Default
  #31
New Member
 
Jaap Stolk
Join Date: Nov 2014
Posts: 4
Rep Power: 2
jwstolk is on a distinguished road
I don't know exactly what HPC is in this case, but I will assume this is some form of Linux.

You are on the right track.
./parReconstructPar should normally work, but since you downloaded the script, it is not marked as executable, and results in an error. if you run:
ls -l parReconstructPar
the "x" flag should be missing.
in that case, run something like:
chmod a+x parReconstructPar

(oh, and possibly read scripts you download from the internet before giving them executing privileges :-)

Normally you only need to use the -n option, like:
./parReconstructPar -n 12
(see the USAGE line in your quote)

Note that reconstructing takes quite a bit of RAM. I recommend just running first with 1 or 2 instead of 12, and then checking how much ram it ends up using (for example with top or htop), and then decide how many cases you can run in parallel without running out of ram.
The OS can swap other programs to disk, but the ram used by parReconstructPar is used continuously, and when even a small part of that needs to be swapped to disk, everything slows down to a crawl.

With my current cases, I can run upto "-n 3" with 16 GB ram.
Since my files are on an NFS drive, I can use the "-t start,end" option to process only half the time directories, and run the other half from another computer, with another 16 GB of ram.
(The standard reconstructPar tool can only rebuild all time directories, or a list of timestamps, and does not have the neat "start,end" option like this script.)

If you are using decimals in your saved timestamps, check that the script does not skip a timestep between the split time ranges, because bash has trouble with sorting numbers with decimals.
jwstolk is offline   Reply With Quote

Old   February 16, 2015, 00:35
Default reconstructPar in parallel using GNU Parallel with a bash one-liner
  #32
Member
 
Peter
Join Date: Feb 2015
Location: California
Posts: 33
Rep Power: 2
opedrofunk is on a distinguished road
Hi All,

I didn't know there was a script for this - really nice. I usually just do this with a bash one-liner:

Code:
$ foamListTimes  -processor > log.foamTimes; awk 'NR%4==1' log.foamTimes | parallel --halt=0 -j8 reconstructPar -newTimes -time {}:
Explanation:

Code:
foamListTimes -processor
lists all the times in the processor0/ directory and are saved to a file called log.foamTimes

Code:
awk 'NR%4==1' log.foamTimes
reads every 4th line (change that to whatever number more-or-less evenly divides the number of times in to the number of processors you want to use) and pipes it to

Code:
parallel --halt=0 -j8 reconstructPar -newTimes -time {}:
which takes the piped input and divides it among -j8 processes (change to whatever you want) which each run reconstructPar starting at -time {}: and skipping any times that may have already been processed by another job - this is important because we use ":" after inserting the start time value {}. The --halt=0 flag tells GNU Parallel to continue if an error happens to occur.

Anyway, that's the solution I've been using - hope this helps.
Peter
opedrofunk is offline   Reply With Quote

Old   July 19, 2015, 21:25
Default
  #33
New Member
 
methma Rajamuni
Join Date: Jul 2015
Posts: 4
Rep Power: 2
meth is on a distinguished road
Kwardly,

Thank you very much for sharing the parReconstructPar script. It is perfectly working.

Best,

Meth.
meth is offline   Reply With Quote

Reply

Tags
parallel processing, reconstructpar

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to Run Parallel Jobs in Rocks Cluster asaha OpenFOAM Running, Solving & CFD 12 July 4, 2012 22:51
Core usage on CFX parallel processing alterego CFX 6 December 21, 2011 06:45
Running decomposePar / reconstructPar as parallel apps? carcass OpenFOAM Running, Solving & CFD 2 July 22, 2009 10:56
Swap usage on parallel run nikhilesh OpenFOAM Running, Solving & CFD 0 April 30, 2009 09:50
TASCflow,problem with script and parallel mode Zbynek Hrncir CFX 0 October 2, 2001 07:30


All times are GMT -4. The time now is 12:55.