CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   bash script for pseudo-parallel usage of reconstructPar (https://www.cfd-online.com/Forums/openfoam-post-processing/64652-bash-script-pseudo-parallel-usage-reconstructpar.html)

kwardle May 18, 2009 14:43

bash script for pseudo-parallel usage of reconstructPar
 
1 Attachment(s)
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.)

kwardle July 22, 2009 10:42

parallel reconstruction (slightly improved)
 
All,
Here is an updated version of my bash script for parallel reconstruction with a few minor modifications--it lists the total number of directories remaining to be reconstructed. I suppose it would be relatively simple to also put in an estimate for the time remaining but I think I'll save that for later.

parReconstructPar

Note that this is geared toward reconstruction of a large number of time directories from a long transient run--if you just want to reconstruct a single time directory this is NOT what you need. Also, it basically assumes you currently have no other reconstructed time directories in your base case directory besides 0.

I would love to hear if anyone has found this to be useful.
-Kent

jploz August 15, 2009 10:55

Nice and useful
 
Works well for me. Thank you for sharing such nice and useful tool. Helps to save some time on multiprocessor machines.

Regards.

oskar August 16, 2009 17:51

Nice!
 
Always good to have utilities that make using OpenFOAM more efficient (and that you don't have to study for many days to figure out how to use).

...user interface, when oh when?

Bastian November 1, 2009 14:35

Bugs?
 
Hi,

I tried to use it with a case I started from time=10 s (to continue it). First reconstructPar job exists with an error. In the end, I have the files that were reconstructed by the 2. and following instances of reconstructPar (so everything from 11.3 s). But the last timeStep (15 s) is missing as well.

My fault or does it just work from 0 on?

Would like to use it though, so if you would fix that in case it's a bug...

Thanks! Bastian

kwardle November 4, 2009 10:15

Well, I guess strictly speaking that is not a bug, just a deficiency of the simplistic method I am using and I mentioned that it assumes you are reconstructing from the smallest time dir in your processor0 directory since it figures out the total number of time directories there and breaks it up into chunks. There is probably an easy fix to generalize this so that you could start the reconstruction from a different value (like t=10s in your case)--I don't know that I have time in the near term (next few weeks) to look at this again, so if someone else wants to run with it and post back that would be awesome.

Bastian November 4, 2009 14:24

Hhhmm I'm pretty sure that that (10 s) was the smallest dir in my processor0, since I usually delete all processor dirs after reconstructing. And only if i reconstruct I can continue from another time. But I'll have a look again.

Bastian

makaveli_lcf October 18, 2010 05:03

1 Attachment(s)
Kent,

thank you very much to your contribution, I found this script very useful for me!
Here I attach my bash script, which reconstructs only those case files, which are not reconstructed yet. It is not parallel, but perhaps someone will find it useful for common usage)))

FG_HSRM October 18, 2010 05:44

Thanks to Kent, until now it's working perfectly for me.

Linse March 24, 2011 15:39

Thanks a lot, Kent!
It worked nicely for me, using a dual-core with hyperthreading.
A thing a little bit surprising though: It counted down nicely from around 1000 timesteps. But the last one before it ended was around 200.
This was causing not more than a bit of curiosity, for sure it's not a problem!

Thanks for the tool again!

braennstroem March 26, 2011 15:13

Hi,

I wonder, if anyone tried to rewrite reconstructPar/Mesh to run in real parallel... foamToEnsight is able to write data and mesh in parallel to a 'serial' file quite quickly, so it should be possible to write direct openfoam data as well!? Did anyone tried this yet?

Best REgards
Fabian

Nik_984 January 31, 2014 07:51

Hi Kent,

This works great, only one question, in my case it always run 2 or 3 processors for reconstructing the case, is there some way to change the code and push it to use more processors, or I am doing something wrong there?

Best Regards
Nikola

kwardle March 28, 2014 12:44

Maybe you have already sorted this out, but I just noticed I never replied to this post. Not sure what is happening. If you run the script name without args you will see that you run it using:

parReconstructPar <number of processors for reconstruction> <name of output file, optional>

Is it not using 8 processes if you run the script as:

parReconstructPar 8

?

Nik_984 April 11, 2014 18:01

Yes I figured it out, in the same way as you have explained in your answer.

Sorry for a late reply.

Thanks.

Z.Q. Niu May 6, 2014 22:05

Hello kent !
I 'm also counter this problem, and Ithink this script is useful to me ! I have download it but I don't know how to run it ? would you mind telling me how to get it work? Thanks !

openfoammaofnepo August 14, 2014 14:37

Dear Kent,

Thank you very much for your sharing the file. In my case, I only need to reconstruct one of the variables, so the command is:

Code:

reconstructPar -fields '(U)'
So I need to add the option -fields '(U)' to the appflag in your file like:

Code:

appflag="-noZero -fields '(U)'"
But when I have this in the file, the running always crashes and it seems it does not work. When I removed what I added, it is OK. Do you know how to add the options like that ?

Thank you.

OFFO

hanness August 15, 2014 01:39

1 Attachment(s)
Dear all,

thank you Kent for this great tool. I picked it up and added some extra features. With this script you can specify the fields to reconstruct and it is possible to specify the timeframe (start,end).
The syntax for using slightly differs from the normal reconstructPar but it is explained in the file.

Hope somebody finds it useful
Hannes

openfoammaofnepo August 15, 2014 06:20

Thank you, it works very well.

kwardle August 15, 2014 09:56

Hannes,
Beautiful work! Thanks for your contribution in adding several features that make the script more flexible and that I am sure will be useful to many people.
-Kent

openfoammaofnepo August 15, 2014 16:46

Hello Hannes,

When I have four parallel runs to preform the reconstruct, there only two are running, the other are not. Is this caused by that fact that the my computer memory is not enough to support the reconstruct?


All times are GMT -4. The time now is 07:13.