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

PyFoam library

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 22, 2009, 05:52
Default
  #41
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by olivier View Post
Then I am missing something, because I am poiting at the NumPy installation in the PYTHONPATH. I will try to have a look at it tomorrow. I hate when I am not admin...

Olivier
You're pointing AT numpy or one direcotry ABOVE it? Second is correct
gschaider is offline   Reply With Quote

Old   November 30, 2009, 05:09
Default
  #42
Member
 
Bernard Esterhuyse
Join Date: Mar 2009
Location: Pretoria, South Africa
Posts: 50
Rep Power: 8
bernarde is on a distinguished road
Hi all

I had the same problem with the blank gnuplot's:

Quote:
Warning: empty x range [1:1], adjusting to [0.99:1.01]
Warning: empty y range [1:1], adjusting to [0.99:1.01]
I'm running Suse 11.1 and OF 1.6. I found the Numpy and Scipy aren't installed in Suse by default. Thus I had to install them from here:

http://software.opensuse.org/search

(just search for numpy and scipy and install both).

The plots then worked fine.

Regards

Bernard
bernarde is offline   Reply With Quote

Old   November 30, 2009, 05:14
Default
  #43
Member
 
Bernard Esterhuyse
Join Date: Mar 2009
Location: Pretoria, South Africa
Posts: 50
Rep Power: 8
bernarde is on a distinguished road
Just another question - is there any way to zoom into certain areas of the plot?

If I right-click on the plot, I get a square that I can drag. I though this would produce a zoom of the area in the square, however I just get the following in the console:

Quote:
line 0: warning: Skipping unreadable file "/tmp/tmpDLaJzj.gnuplot/fifo"
line 0: warning: Skipping unreadable file "/tmp/tmpRWr59v.gnuplot/fifo"
line 0: No data in plot
The plots just remain the same.
bernarde is offline   Reply With Quote

Old   November 30, 2009, 08:42
Default
  #44
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by bernarde View Post
Hi all

I had the same problem with the blank gnuplot's:



I'm running Suse 11.1 and OF 1.6. I found the Numpy and Scipy aren't installed in Suse by default. Thus I had to install them from here:

http://software.opensuse.org/search

(just search for numpy and scipy and install both).

The plots then worked fine.

Regards

Bernard
Yeah. It seems there are problems with Numeric (which is used as a fallback if numpy is not installed) especially on SuSE. pyFoamVersion.py says something in that sense, but it is not very clear Bernhard
gschaider is offline   Reply With Quote

Old   November 30, 2009, 08:47
Default
  #45
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by bernarde View Post
Just another question - is there any way to zoom into certain areas of the plot?

If I right-click on the plot, I get a square that I can drag. I though this would produce a zoom of the area in the square, however I just get the following in the console:



The plots just remain the same.
That is a problem of the gnuplot-terminal (which by default is x11). That can not do it. There are gnuplot-terminals that could do it, but they are not supported by pyFoam. What you can try with the most recent PyFoam is use the plotting-implementation matplotlib. That can do that (zooming). The problem is that it does not work on all platforms (only one of two I tested so far ), so: good luck Bernhard
gschaider is offline   Reply With Quote

Old   December 1, 2009, 11:12
Default
  #46
Senior Member
 
Rasmus Hemph
Join Date: Mar 2009
Location: Sweden
Posts: 108
Rep Power: 8
hemph is on a distinguished road
Quote:
Originally Posted by bernarde View Post
Hi all

I had the same problem with the blank gnuplot's:



I'm running Suse 11.1 and OF 1.6. I found the Numpy and Scipy aren't installed in Suse by default. Thus I had to install them from here:

http://software.opensuse.org/search

(just search for numpy and scipy and install both).

The plots then worked fine.

Regards

Bernard
Perfect! Got my graphs back again
//Rasmus
hemph is offline   Reply With Quote

Old   December 1, 2009, 12:07
Default
  #47
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by gschaider View Post
That is a problem of the gnuplot-terminal (which by default is x11). That can not do it. There are gnuplot-terminals that could do it, but they are not supported by pyFoam. What you can try with the most recent PyFoam is use the plotting-implementation matplotlib. That can do that (zooming). The problem is that it does not work on all platforms (only one of two I tested so far ), so: good luck Bernhard
Sorry for the misinformation: the x11 terminal CAN do zooming, BUT not if it gets the data from a pipe (which is the case here), so sorry no possibility. So the only way to zoom the graphs is to force writing of the data with --write-files and afterwards visualize that data with the plotting program of your choice (or use --start and/or --end if you'Re only interested in a certain time-range)

Bernhard
gschaider is offline   Reply With Quote

Old   January 3, 2011, 04:32
Default sorting of parsed dictionary
  #48
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 10
braennstroem is on a distinguished road
Hello Bernhard,

I have trouble understanding the sorting of your parser using the below expression:
f=ParsedParameterFile(fileDict)

Keys=f["addLayersControls"]["nameConventions"].keys()

for the fileDict:
addLayersControls
{
nameConventions // alphabetic order
{
GRO { nSurfaceLayers 4; }
ROT { nSurfaceLayers 6; }
WW { nSurfaceLayers 12; }
}
}

I would like to have the same order as it is listed in the dict;
unfortunately I get this order: ['WW', 'GRO', 'ROT'].

Do you have a hint or idea, how to get this!?
Would be great!

Regards!
Fabian
braennstroem is offline   Reply With Quote

Old   January 3, 2011, 06:47
Default
  #49
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by braennstroem View Post
Hello Bernhard,

I have trouble understanding the sorting of your parser using the below expression:
f=ParsedParameterFile(fileDict)

Keys=f["addLayersControls"]["nameConventions"].keys()

for the fileDict:
addLayersControls
{
nameConventions // alphabetic order
{
GRO { nSurfaceLayers 4; }
ROT { nSurfaceLayers 6; }
WW { nSurfaceLayers 12; }
}
}

I would like to have the same order as it is listed in the dict;
unfortunately I get this order: ['WW', 'GRO', 'ROT'].

Do you have a hint or idea, how to get this!?
Would be great!

Regards!
Fabian
The problem is that a dictionary usually does not have an order of the keys (the order is determined by the implementation). In your example the order of the definition is also the alphabetical order. To get the keys in alphabetical order (which is probably not what you want in the general case) just add Keys.sort(). If you need the stuff in the order of the definition (which in my opinion is not a good idea because that would mean that your OF-code depends on that order too and things might break should the implementation of dictionary.toc change) then something about the library would have to be changed. A quick fix would be to go to Basics/DataStructures.py and add to DictProxy a method
def keys(self): return self._order
(self._order is used to output stuff int the order of the definition) but this fix will NOT change the order if you iterate over the dictionary itself (without .keys())

Bernhard
gschaider is offline   Reply With Quote

Old   January 3, 2011, 07:34
Default
  #50
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 10
braennstroem is on a distinguished road
Hi Bernhard,

thanks for the quick response!

Quote:
Originally Posted by gschaider View Post
The problem is that a dictionary usually does not have an order of the keys (the order is determined by the implementation). In your example the order of the definition is also the alphabetical order. To get the keys in alphabetical order (which is probably not what you want in the general case) just add Keys.sort().
Yes, I tried the sort(), but is not suitable for this task.

Quote:
Originally Posted by gschaider View Post
If you need the stuff in the order of the definition (which in my opinion is not a good idea because that would mean that your OF-code depends on that order too and things might break should the implementation of dictionary.toc change) then something about the library would have to be changed.
In this case, pyFoam is used as a preprossing tool setting the number of layers in snappyHexMeshDict based on given name conventions. So it 'just' creates the snappyDict according to another Dict... So similar to the regexp stuff from 1.6.x on, I would be able to first set all patches depended on the first entry and the second could overwrite the setting...

Quote:
Originally Posted by gschaider View Post
A quick fix would be to go to Basics/DataStructures.py and add to DictProxy a method
def keys(self): return self._order
(self._order is used to output stuff int the order of the definition) but this fix will NOT change the order if you iterate over the dictionary itself (without .keys())
Works! Thanks!
Fabian
braennstroem is offline   Reply With Quote

Old   January 4, 2011, 13:31
Default
  #51
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by braennstroem View Post
Hi Bernhard,

thanks for the quick response!


Yes, I tried the sort(), but is not suitable for this task.


In this case, pyFoam is used as a preprossing tool setting the number of layers in snappyHexMeshDict based on given name conventions. So it 'just' creates the snappyDict according to another Dict... So similar to the regexp stuff from 1.6.x on, I would be able to first set all patches depended on the first entry and the second could overwrite the setting...


Works! Thanks!
Fabian
In the fix I sent you replace self._order with self._order[:] (this creates a copy of the list which avoids possible side-effects should somebody modify the list he gets - the original for returned a reference to the list)

Bernhard
gschaider is offline   Reply With Quote

Old   September 30, 2011, 08:01
Default
  #52
Member
 
Tibor Nyers
Join Date: Jul 2010
Location: Hungary
Posts: 91
Rep Power: 8
Toorop is on a distinguished road
Hi,
I would like to create a simple script that renders out a paraview state file at some time. I tried to reverse engineer your paraview related pyFoam utiliities and couldn't quite understand how the desired time is set.
My terminal command is:
Code:
paraview --script=./postproc/paraview/paraPlot.py
paraPlot.py
Code:
from paraview.simple import *

# load the state
servermanager.LoadState("./postproc/paraview/pw_pressure.pvsm")

# make sure that the view in the state is the active one
SetActiveView(GetRenderView())
GetActiveView()

# no success, no output
SetViewTime(800)

# now render and save
Render()
WriteImage("./postproc/paraview/pw_pic.png")
This method is not working, no output is generated. If I left out SetViewTime, there is a picture, but I guess paraview uses the time defined in the state file and my color isn't rescaled to data range as well.

My other try:
Code:
from paraview.simple import *

# load the state
servermanager.LoadState("./postproc/paraview/pw_pressure.pvsm")

# make sure that the view in the state is the active one so we don't have to refer to it by name
SetActiveView(GetRenderView())
view=GetActiveView()

view.ViewTime=0

# now render and save
view.Render()
view.WriteImage("./postproc/paraview/pw_pic.png")
The color is rescaled, but no output.
In both cases the legends aren't scaled to data range.

Is there a solution or one should modify the state file instead?
What's the command for quiting paraview at the end of the script?
Can someone advise some tutorials on python scripting paraview - stream tracer creation, slicing and contour plots, etc? This state file loading is not really impressive, contains a lot of boiler plate stuff, hard to edit and customize. It would be much better the other way around.

Thank you!
Toorop is offline   Reply With Quote

Old   September 30, 2011, 08:28
Default
  #53
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 577
Blog Entries: 5
Rep Power: 13
elvis is on a distinguished road
Hi,

I think you are better served with Python Scripting http://paraview.org/Wiki/ParaView/Python_Scripting or http://paraview.org/Wiki/Take_a_Scre..._of_a_VTP_File

http://www.openfoamworkshop.org/6th_...rle_slides.pdf =>see slide Batch/reproducible workflow "topic macro"
elvis is offline   Reply With Quote

Reply

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
PyFoam braennstroem OpenFOAM 293 June 11, 2015 20:53
DT NURBS Library AS Main CFD Forum 0 September 17, 2008 08:43
About AMR Library C.-G. CHEN Main CFD Forum 0 October 31, 2007 01:34
Library JB Phoenics 0 June 20, 2004 15:12
The impeller library Chialin CFX 0 May 4, 2000 02:23


All times are GMT -4. The time now is 08:03.