CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [PyFoam] First discussion thread about PyFoam (https://www.cfd-online.com/Forums/openfoam-community-contributions/60683-first-discussion-thread-about-pyfoam.html)

gschaider October 7, 2007 14:50

Hi Pierre! Yeah. A Bug. But
 
Hi Pierre!

Yeah. A Bug. But not in my stuff. There were 2 things wrong with the blockMeshDict written by the cylindermesh.m4. That it was parsed by blockMesh is owed to the fact that the OF-fileparser seems to be very tolerant:

1. The data-header did not conform to the description in section 4.2.3 of the UserGuide (quote: "All data files ..... begin with a dictionary named FoamFile containing ...." In the generated files the content was present, but the "FoamFile {" and "}" that should enclose the content to make it a dictionary was missing
2. The patch definitions contained lists of the form "(2 4(0 3 2 1))" which should in fact be "(0 3 2 1)". The first version is a list that consists of a number and a list of 4 vertices. Don't know what this is supposed to mean. (It's not explicitly stated in the UG, but I believe that a list in an OF-File is a collection of things of the same type, like the List-template class)

I will not fix the parser to tolerate these two inconsistencies. Instead I post a version of cyclindermesh.m4 that writes a dictionary that is read by PyFoam:

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif cylinderMesh.m4

Bernhard

PS: OK. The ParserError could be a bit more descriptive. I'll work on that

pvc October 9, 2007 23:46

Hi Bernhard, Thanks again
 
Hi Bernhard,

Thanks again for considering my request.
The patch definition you mentionned is namely a bit unclear but working in the native file. Can't explain why also ...

Actually, I am sorry but the file you've just posted does not work with PyFoam. I have checked and double-checked without any success, but I may be wrong ...

Rgds

Pierre

gschaider October 10, 2007 08:59

Hi Pierre! You have first s
 
Hi Pierre!

You have first sent it through m4, have you? (it's not a blockMeshDict, but a m4-script to produce the dict, like in the thread you referenced). The generated blockMesh works on my PyFoam-installation. What is the problem you're having now? (Of cousre I can't exclude the possibility that it is a version-problem, as my version is a bit more up-to-date than yours)

Bernhard

braennstroem October 12, 2007 03:42

Hi Bernhard, sorry for the
 
Hi Bernhard,

sorry for the delay, forgot to answer... the extraction of the average pressure works good. Thanks!

So, I have one more question :-)
Can I use pyfoam to distribute runs on certain machines and start their calculations/importing/post all from one script. In plain python I would just use os.system("rsh machine RUN_OPF"), but then the script does not wait for the calculation to finish. It would be nice, if I can do that with pyfoam!?

A similar problem is to start a run in parallel with pyfoamRunner. I could not figure the exact syntax to start a parallel job. Do you have a small example?

Greetings!
Fabian

gschaider October 12, 2007 05:48

Hi Fabian! @rsh-feature: No
 
Hi Fabian!

@rsh-feature: Not yet. Sounds like a cool feature (you can become the most unpopular person in the whole lab: "Where does this run come from?"). I'll have a look at how difficult it would be to implement it. (BTW: have a look at the subprocess-library in python 2.4+. It has facilities that wait for the end of an execution)

Parallel runs should be easy. Decompose the case with (no need to write the dict yourself)
pyFoamDecomposer --method=metis testCase 4
Then (provided you run on an SMP-machine)
pyFoamRunner --proc=4 simpleFoam . testCase
If you are running on more than one machine you must create a hostfile and do
pyFoamRunner --machinefile=hostfile simpleFoam . testCase
pyFoam should run your favourite MPI-implementation (in the case of LAM it first does a lamboot), no need to say mpirun (or -parallel).
Please note, that I currently only have OpenMPI (the LAM-support used to work a year ago, I don't see why it should be broken). MPIch I never had access to, don't know if it works.

Bernhard

braennstroem October 14, 2007 12:27

Hi Bernhard, thanks for the
 
Hi Bernhard,

thanks for the parallel help! According to you rsh-concerns; I would just run the jobs over night ;-) Thanks for the hint with the subprocess-library.

Fabian

markusrehm October 16, 2007 02:21

Hello Bernhard, I recently
 
Hello Bernhard,

I recently installed pyFoam and I think it is great. There was just one thing I wasn't able to achieve: plotting ;)

It tells me for example
Warning: empty x range [1641:1641], adjusting to [1624.59:1657.41]
Warning: empty y range [6.07427e-07:6.07427e-07], adjusting to [6.01353e-07:6.13501e-07]
Warning: empty y2 range [6.07427e-07:6.07427e-07], adjusting to [6.01353e-07:6.13501e-07]

and the plots stay empty. I installed the Gnuplot site-package for Python. Is that correct? If yes you could add that to the Wiki as well - because I needed to struggle some time to find out that this is needed and not the "normal" gnuplot-package.

Thank you Markus.

braennstroem October 17, 2007 11:38

Hi Bernhard, I have a small
 
Hi Bernhard,

I have a small add-on request... it would be great, if the plotting stuff would work with matplotlib too, which has some nice features as paning, zooming and saving. It is probably to late and to much work to implement!?

Fabian

gschaider October 18, 2007 07:28

@markus: It seems that gnuplot
 
@markus: It seems that gnuplot currently has only the data for one timestep (what are you using the pyFoamPlotRunner.py or the pyFoamPlotWatcher.py? Or the Library without an application). That is the usual output gnuplot gives, when you're trying to plot. What is the other output you're seeing on the terminal (from the solver) or does the script end with some error message?

For the requirements: gnuplot itself should be sufficient. PyFoam brings the Gnuplot-Library with it (in the ThirdParty-branch). And the Python-Numeric package is needed for plotting (I hope I stated that on the Wiki. Will check.)

@fabian: I will have a look at it. But don't hold your breath.
The two main goals for the plotting library were:
- portability: The user should not be required to install too much external software. gnuplot can be assumed to be installed on any decently managed workstation (OK Python-Numeric is required. But that was too big to be distributed with the PyFoam-sources)
- speed: The main reason I was using gnuplot and not some library was that when I was trying out these things they were not as fast as I wanted them to be. When I use the plotter to watch the residuals for some 5000-cells MickyMouse-case I don't want to spend more CPU-time for plotting than for calculating (some libraries were making beautiful graphs, but they were taking in the order of seconds to plot 1000+-points - not splitseconds like gnuplot)

But if you want beautiful graphs you can always use the --write-option of the plot-commands. They will write the residuals etc to a directory and you can use any other program (XMgrace, Origin ..... Excel) to make them

Bernhard

braennstroem October 20, 2007 12:27

Hi Bernhard, the main advan
 
Hi Bernhard,

the main advantage of matplotlib over gnuplot is just the possible interactivity. And until today, I thought, that gnuplot python does not work with the numeric-successor numpy, but just replacing the imports of numeric seem to work...so don't do to much work with matplotlib, unless you already like it so much ;-)

Fabian

markusrehm October 23, 2007 01:49

Hi Bernhard, thanks for you
 
Hi Bernhard,

thanks for your help but I couldn't fix it yet. I have to spend some more time. The solver gives no errors. I use pyFoamPlotRunner.py.

Thanks so far. Regards Markus.

gschaider October 23, 2007 07:46

Hi Markus! And the solver h
 
Hi Markus!

And the solver has completed more than one timestep? (Because before the second time-step Gnuplot will produce that kind of output)

Could you please send me a file (preferably by mail, we don't want to bother the people on the MessageBoard) with the output of your solver, so that I can try to reproduce the problem (10 time-steps or so would be sufficient)

Bernhard

jason November 8, 2007 14:13

Hi Bernhard, I have just in
 
Hi Bernhard,

I have just installed PyFoam and thank you, it is wonderful. But I have a small problem when running in parallel. I followed your instructions above on 12/10/07 and I am trying to run a case on a dual dual-core machine ie 4 processors but I get some errors. For a single processor case everything works great but after I have decomposed and issue the command

pyFoamRunner.py --proc=4 simpleFoam . <mytestcase>

I get the following error

[linux-qz5q:12360] [0,0,0] ORTE_ERROR_LOG: Error in file runtime/orte_init_stage1.c at line 312
--------------------------------------------------------------------------
It looks like orte_init failed for some reason; your parallel process is
likely to abort. There are many reasons that a parallel process can
fail during orte_init; some of which are due to configuration or
environment problems. This failure appears to be an internal failure;
here's some additional information (which may only be relevant to an
Open MPI developer):

orte_pls_base_select failed
--> Returned value -1 instead of ORTE_SUCCESS

--------------------------------------------------------------------------
[linux-qz5q:12360] [0,0,0] ORTE_ERROR_LOG: Error in file runtime/orte_system_init.c at line 42
[linux-qz5q:12360] [0,0,0] ORTE_ERROR_LOG: Error in file runtime/orte_init.c at line 52
--------------------------------------------------------------------------
Open RTE was unable to initialize properly. The error occured while
attempting to orte_init(). Returned value -1 instead of ORTE_SUCCESS.
--------------------------------------------------------------------------
Getting LinuxMem: [Errno 2] No such file or directory: '/proc/12360/status'

Would you be able to help?

Regards

Jason

jason November 8, 2007 14:16

ps - I forgot to say that ever
 
ps - I forgot to say that everything works ok when I start a parallel case using

mpirun -np 4 simpleFoam . <mytestcase> -parallel

But I would love to see some plots of the simulation too.

Regards

Jason

jason November 8, 2007 14:27

pps - I also forgot to say tha
 
pps - I also forgot to say that I am running openSUSE v10.2, 32 bit version and OF release v1.4.1 and upto now everything works great.

I also get this error when I run the pitzDaily tutorial in parallel so I don't think it is my model.

Regards

Jason

gschaider November 8, 2007 15:23

Hi Jason! OK. Its seems tha
 
Hi Jason!

OK. Its seems that you are the victim of a fix I had to do at my site (passwordless-login on other machines, you don't want to know).

Open the file PyFoam/Execution/ParallelExecution.py and look for the line
mpirun+=["--mca","pls_rsh_agent","rsh"]+nr+machine+["-x","LD_LIBRARY_PATH","-x", "WM_PROJECT_DIR","-x","FOAM_MPI_LIBBIN","-x","MPI_BUFFER_SIZE"]

replace it with the line

mpirun+=nr+machine

That should work. If not, add the line

print mpirun

before

return mpirun

It should look similar to your commandline. If not: tell me what it looks like

Bernhard

PS: Don't forget: Indentation is important in Python!!
PPS: I'll make the fix more configurable in the next release

jason November 8, 2007 16:23

Hi Bernhard, Many thanks fo
 
Hi Bernhard,

Many thanks for the quick response, I followed your instructions but I got the same error. I've attached the ParallelExecution.py file to make sure I did it right (sorry, but I'm not a good programmer). The print mpirun part didnt seem to do anything

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif ParallelExecution.py

Here is the error output

[linux-qz5q:06128] [0,0,0] ORTE_ERROR_LOG: Error in file runtime/orte_init_stage1.c at line 312
--------------------------------------------------------------------------
It looks like orte_init failed for some reason; your parallel process is
likely to abort. There are many reasons that a parallel process can
fail during orte_init; some of which are due to configuration or
environment problems. This failure appears to be an internal failure;
here's some additional information (which may only be relevant to an
Open MPI developer):

orte_pls_base_select failed
--> Returned value -1 instead of ORTE_SUCCESS

--------------------------------------------------------------------------
[linux-qz5q:06128] [0,0,0] ORTE_ERROR_LOG: Error in file runtime/orte_system_init.c at line 42
[linux-qz5q:06128] [0,0,0] ORTE_ERROR_LOG: Error in file runtime/orte_init.c at line 52
--------------------------------------------------------------------------
Open RTE was unable to initialize properly. The error occured while
attempting to orte_init(). Returned value -1 instead of ORTE_SUCCESS.
--------------------------------------------------------------------------
Getting LinuxMem: [Errno 2] No such file or directory: '/proc/6128/status'

Thanks

Jason

gschaider November 8, 2007 17:37

Hi Jason! The changes are c
 
Hi Jason!

The changes are correct. My suspicion is that the file is not used. Did you install PyFoam as described on the Wikipage (python setup.py install) ? And if yes which version of ParallelyExecution.py did you edit:

a) the one that comes from the untarring of the archive
b) the one that was written to some system directory by setup.py

If you edited a) then you won't see any changes because b) is still used by the utilities. One possibility to correct this is to run the setup again (thus copying your changes from a) to b) ).

Bernhard

braennstroem November 9, 2007 06:02

Hi Bernhard, there seems to
 
Hi Bernhard,

there seems to be a small bug with a lot of impact...
Using pyFoamClone case the source and destination should be vice versa!? At least I just erased existing simulations:

ceplx049~/SCR1/Solververgleich/E1_Messaufbau/OpenFOAM/ceplx015> pyFoamCloneCase.py E1_SIMPLE_GROB_EPSILON E1_SIMPLE_GROB_EPSILON_OPF_Poly E1_SIMPLE_FEIN_POLY_RNG
Traceback (most recent call last):
File "/scr/ceplx049/scr1/gcae504/Software/OpenFOAM/PyFoaM/bin//pyFoamCloneCase.py", line 5, in ?
CloneCase()
File "/scr/ceplx049/scr1/gcae504/Software/OpenFOAM/PyFoaM//lib/python2.3/site-package s/PyFoam/Applications/CloneCase.py", line 14, in __init__
PyFoamApplication.__init__(self,description=descri ption,usage="%prog <source> <destination>",interspersed=True,nr=2)
File "/scr/ceplx049/scr1/gcae504/Software/OpenFOAM/PyFoaM//lib/python2.3/site-package s/PyFoam/Applications/PyFoamApplication.py", line 21, in __init__
self.run()
File "/scr/ceplx049/scr1/gcae504/Software/OpenFOAM/PyFoaM//lib/python2.3/site-package s/PyFoam/Applications/CloneCase.py", line 40, in run
sol.cloneCase(dName)
File "/scr/ceplx049/scr1/gcae504/Software/OpenFOAM/PyFoaM//lib/python2.3/site-package s/PyFoam/RunDictionary/SolutionDirectory.py", line 70, in cloneCase
self.execute("cp -r "+d+" "+name)
TypeError: cannot concatenate 'str' and 'NoneType' objects
ceplx049~/SCR1/Solververgleich/E1_Messaufbau/OpenFOAM/ceplx015> pyFoamCloneCase.py
usage: pyFoamCloneCase.py <source> <destination>


Maybe I just did something wrong, but ...

Regards!
Fabian

jason November 9, 2007 07:49

Hi Bernhard, I modified th
 
Hi Bernhard,

I modified the one in the tar archive!, I ran the setup again and sucess, it all works fine, thank you.

I have a couple of other less technical questions.

1/ Are the graphs saved anywhere automatically or do I have to do alt-printscreen?
2/ Is the data that the graphs are drawn from saved anywhere for possible manipulation elsewhere?
3/ Do have have to run reconstructPar manually after or is there an automatic option?

Thanks

Jason


All times are GMT -4. The time now is 19:00.