CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Paraview & paraFoam

Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12

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

Like Tree8Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   May 24, 2013, 08:49
Unhappy Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12
  #1
Member
 
David Long
Join Date: May 2012
Location: Germany
Posts: 54
Rep Power: 5
keepfit is on a distinguished road
Hi Foamers,

It seems that "Automatically Rescale to Fit Data Range" does not work in compiled ParaView 3.12 for OpenFoam 2.1.1. This issue was always bugging me, especially when comes to saving "Animation".

System: Ubuntu 12.04 32-bit, OF 2.1.1, paraview 3.12

PV settings: 1) Edit --> Settings: Rescale Data Range Mode -->Grow every timestep
2) Color scale editor: Automatically Rescale to Fit Data Range is on

When playing saved results, the value of selected colour legend is rising while the max. exceeds the current max.. However, when the current max value drops, the max. value of the colour legend does not change!

This causes saved animations has same colour of selected fields (pressure or velocity) especially a very high value of magnitude takes places in few timesteps.

For example, if i wanna make a animation of propagation of water waves over slope, the max. velocity of wave during the overall simulation is c.a 12 m/s, while the estimated average velocity is 4~6 m/s, so the contour colour of most screen-shots looks the same and could not figure out the Velocity Fields.

1. Animation screenshot (It is difficult to find out the max velocity.)


2. Manually press the "Rescale to Data Range" button (expected output)





Having searched through the forum but could not find the solution. Has some one faced this annoying issue and solved it?

Best,

David
keepfit is offline   Reply With Quote

Old   May 25, 2013, 08:44
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings David,

Many thanks for the thorough explanation!

Here's what I've managed to figure out:
  • Can't blame the feature, since it's doing what it says it should do: "Grow every timestep" - so if the maximum doubles its value in a single iteration, it simply goes to where it should!
  • There are a few suggestions on what you can try to make it easier to see, as shown in the attached image:
    • Click on "Choose Preset" to change to "Blue to Red ... - HSV". This will make it easier to see the different colour gradings.
    • Change "Resolution" to "32", so that it'll be easier to see the different colours, since it won't be as mixed.
    • Add and move reference points in the colour scale. If you compare the bar on the top of the attached image, to the one you've got, you should see 2 new points on the attached image. You can click to add/select (use the "Del" key to remove a selected one) and use the mouse to drag the point to a better location.
  • There is also the possibility of hacking this scaling feature using the "Programmable Filter", but I haven't tried this.
  • Last but not least... the latest ParaView 4.0 (currently RC1... or maybe it was already on ParaView 3.98?), seems to have some very wicked colour range scaling techniques: http://paraview.org/Wiki/ParaView/Di...sfer_Functions
Best regards,
Bruno
Attached Images
File Type: png Screenshot from 2013-05-25 13:07:52.png (48.2 KB, 83 views)
wyldckat is offline   Reply With Quote

Old   May 25, 2013, 15:55
Default
  #3
Member
 
David Long
Join Date: May 2012
Location: Germany
Posts: 54
Rep Power: 5
keepfit is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
Greetings David,

Many thanks for the thorough explanation!

Here's what I've managed to figure out:
  • Can't blame the feature, since it's doing what it says it should do: "Grow every timestep" - so if the maximum doubles its value in a single iteration, it simply goes to where it should!
  • There are a few suggestions on what you can try to make it easier to see, as shown in the attached image:
    • Click on "Choose Preset" to change to "Blue to Red ... - HSV". This will make it easier to see the different colour gradings.
    • Change "Resolution" to "32", so that it'll be easier to see the different colours, since it won't be as mixed.
    • Add and move reference points in the colour scale. If you compare the bar on the top of the attached image, to the one you've got, you should see 2 new points on the attached image. You can click to add/select (use the "Del" key to remove a selected one) and use the mouse to drag the point to a better location.
  • There is also the possibility of hacking this scaling feature using the "Programmable Filter", but I haven't tried this.
  • Last but not least... the latest ParaView 4.0 (currently RC1... or maybe it was already on ParaView 3.98?), seems to have some very wicked colour range scaling techniques: http://paraview.org/Wiki/ParaView/Di...sfer_Functions
Best regards,
Bruno
thanks Bruno, i will try the methods you've mentioned.

Since the feature is not provided, is there any other hacking way to the source code that the "Rescale to Data Range" button is automatically pressed each time step?
keepfit is offline   Reply With Quote

Old   May 25, 2013, 16:07
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Quote:
Originally Posted by keepfit View Post
Since the feature is not provided, is there any other hacking way to the source code that the "Rescale to Data Range" button is automatically pressed each time step?
Like I said:
Quote:
There is also the possibility of hacking this scaling feature using the "Programmable Filter", but I haven't tried this.
This requires that ParaView is built with Python. This way, "Programmable Filter" gives us access to the fields and should also somehow give access to the scales.

Another possibility is to do the animation purely through python scripts... ParaView does have the "Python Trace" feature, so it's just a matter of hacking the resulting macro script. But again, ParaView must be built with Python support.

Said Python support depends on how you built/installed ParaView in the first place.
wyldckat is offline   Reply With Quote

Old   August 3, 2013, 20:58
Default
  #5
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
hi Bruno
If 4 is better can i install Paraview 4.0 on ubuntu 11.10 or can't?!
@David
Hi
There is a button for automatic scale change in options,check mark it.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 17, 2013, 13:24
Default
  #6
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings to all!

Quote:
Originally Posted by immortality View Post
hi Bruno
If 4 is better can i install Paraview 4.0 on ubuntu 11.10 or can't?!
Technically, you can have all versions of ParaView since at least 3.12.0 up to 4.0.1, by using the pre-built binaries - http://paraview.org/paraview/resources/software.php - and they should work on Ubuntu 11.10.
The problem comes when you actually need to use them, namely:
  1. You'll only be able to use the internal ".foam" reader.
  2. You'll at least need an alias command for launching each ParaView instance.
The other possibility is to build ParaView 4.0.1 from source code and adjust the official OpenFOAM plugin as hinted by this bug report: http://www.openfoam.org/mantisbt/view.php?id=621


Quote:
Originally Posted by immortality View Post
@David
Hi
There is a button for automatic scale change in options,check mark it.
Didn't you read what David wrote?
Quote:
Originally Posted by keepfit View Post
System: Ubuntu 12.04 32-bit, OF 2.1.1, paraview 3.12

PV settings: 1) Edit --> Settings: Rescale Data Range Mode -->Grow every timestep
2) Color scale editor: Automatically Rescale to Fit Data Range is on

When playing saved results, the value of selected colour legend is rising while the max. exceeds the current max.. However, when the current max value drops, the max. value of the colour legend does not change!
____________________________________

But back on the original topic - As I wrote in the past, one needs Python built into ParaView for making the following technique to work. I only managed to look into this today, because since yesterday I've been studying how to use some of of the missing ParaView features.

So, to be able to get the animation to update the ranges on each iteration, one has to:
  1. Start ParaView and open the case in question.
  2. In the menu, check the "View -> Animation View" option.
  3. Follow the numbers on the attached image:
    1. Select the Python entry from the drop-down box.
    2. Click on the + button.
    3. Double-click on the grey line where the 3 is. It should show a dialogue window with the following code:
      Code:
      def start_cue(self): pass
      
      def tick(self): pass
      
      def end_cue(self): pass
  4. Now, replace the source code shown in the dialogue window with the following code:
    Code:
    from paraview.simple import *
    
    def start_cue(self): pass
    
    def tick(self):
        source = FindSource("testTubeMixer.foam")
    
        #This works fine on ParaView 3.12.0 to 4.0.1
        source.UpdatePipeline(GetAnimationScene().TimeKeeper.Time)
    
        #The array and number of components
        arrayName = "U"
        arrayComponents = 3
        component = -1
        #options for component: -1, 0, 1 and 2 => Mag, X, Y, Z
    
        # If it's a scalar field
        #arrayName = "p"
        #arrayComponents = 1
        #component = 0
    
    
        #Get the look-up table for this array
        lookupTable = GetLookupTableForArray(arrayName, arrayComponents)
    
        #get the access to the cellData or pointData
        data = source.GetCellDataInformation()
        #data = source.GetPointDataInformation()
    
        #get the array and the respective min-max
        array = data.GetArray(arrayName)
        dataRange = array.GetRange(component)
    
        lookupTable.LockScalarRange = 1
    
        #Now let's hack in the range values
        lookupTable.RGBPoints[0] = dataRange[0] #min
        lookupTable.RGBPoints[4] = dataRange[1] #max
    
    
    def end_cue(self): pass
  5. Hit the OK button and it's ready to go, namely it will rescale the Magnitude array of the "U"data on the entry "testTubeMixer.foam" on the "Pipeline Browser".
The code is commented and explains each major group of lines, but I'd like to point out the following items:
  • This is where you define the name of the entry:
    Code:
    source = FindSource("testTubeMixer.foam")
    Note: I used the tutorial "multiphase/interDyMFoam/ras/testTubeMixer" on OpenFOAM 2.2 for testing this feature. And I ran paraFoam with the "-builtin" option:
    Code:
    paraFoam -builtin
  • These are the variables that define which value array should we be rescaling to:
    Code:
    arrayName = "U"
    arrayComponents = 3
    component = -1
    Where:
    • "arrayName" is for the name defined in the "Color By" entry.
    • "arrayComponents" depends on whether it's a vector field (3) or a scalar field (1).
    • options for "component":
      • -1 => Mag
      • 0 => X
      • 1 => Y
      • 2 => Z
  • As if this wasn't enough of settings to be configured, keep in mind that it also depends on the representation you currently are using, namely:
    • If you are using the cell/face representation, use this line of code:
      Code:
      data = source.GetCellDataInformation()
    • Otherwise, if you're using the vertex/point/interpolated representation, use this code:
      Code:
      data = source.GetPointDataInformation()
    • edit: If you don't understand what I'm talking about, read the post #10 on this thread: studying a valve case
Best regards,
Bruno
Attached Images
File Type: jpg Screenshot from 2013-08-17 18:09:36.jpg (23.4 KB, 36 views)

Last edited by wyldckat; September 15, 2013 at 18:11. Reason: see "edit:"; Also fixed broken code for updating the pipeline
wyldckat is offline   Reply With Quote

Old   August 18, 2013, 10:32
Default
  #7
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
Hi dear Bruno
I did what you told except to using -builtin option and it didn't rescale data.should use -builttin necessarily? because I have reconstructed and deleted processor's folders.can't do anything?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 18, 2013, 10:41
Default
  #8
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Quote:
Originally Posted by immortality View Post
I did what you told
What exactly? Did you see how much I wrote on the previous post?

Quote:
Originally Posted by immortality View Post
can't do anything?
Do what?
wyldckat is offline   Reply With Quote

Old   August 18, 2013, 10:52
Default
  #9
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
I used the code as this:
Code:
from paraview.simple import *

def start_cue(self): pass

def tick(self):
    source = FindSource("WR_3.OpenFOAM")
    source.UpdatePipeline(self.GetAnimationTime())

    #The array and number of components
    #arrayName = "p"
    #arrayComponents = 1
    #component = -1
    #options for component: -1, 0, 1 and 2 => Mag, X, Y, Z

    # If it's a scalar field
    arrayName = "p"
    arrayComponents = 1
    component = 0


    #Get the look-up table for this array
    lookupTable = GetLookupTableForArray(arrayName, arrayComponents)

    #get the access to the cellData or pointData
    data = source.GetCellDataInformation()
    #data = source.GetPointDataInformation()

    #get the array and the respective min-max
    array = data.GetArray(arrayName)
    dataRange = array.GetRange(component)

    lookupTable.LockScalarRange = 1

    #Now let's hack in the range values
    lookupTable.RGBPoints[0] = dataRange[0] #min
    lookupTable.RGBPoints[4] = dataRange[1] #max


def end_cue(self): pass
only put the name and scalar field p.
is it incorrect to use .OpeFOAM extension?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 18, 2013, 11:00
Default
  #10
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
No, the ".OpenFOAM" file is not the problem.

We've exchanged so many emails and posts, and you still don't provide enough information...
What ParaView version are you using and is there any error message?
wyldckat is offline   Reply With Quote

Old   August 18, 2013, 11:25
Default
  #11
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
paraView 3.12.0
and each time use start paraView should add the code again?it doesn't save for me.
p increases and should decrease after a time but maximum doesn't decrease to real time maximum,no there isn't any error except that paraview is closed when reaches the last time folder but saves previous images to the path.
is the field with a circle on left in a point representation not cell represent,right?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 18, 2013, 11:55
Default
  #12
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Quote:
Originally Posted by immortality View Post
and each time use start paraView should add the code again?it doesn't save for me.
Only if you save the state file and reload the case directly from the case file when you need it again.

Quote:
Originally Posted by immortality View Post
p increases and should decrease after a time but maximum doesn't decrease to real time maximum,no there isn't any error except that paraview is closed when reaches the last time folder but saves previous images to the path.
Does the same happen when you do not save the animation? I.e., if you only click on the "play" icon button?

Quote:
Originally Posted by immortality View Post
is the field with a circle on left in a point representation not cell represent,right?
Cell vs Point is shown in this post: studying a valve case post #10
wyldckat is offline   Reply With Quote

Old   August 18, 2013, 12:54
Default
  #13
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
then I should use "save state" and "load state" after I start paraView?
Quote:
Does the same happen when you do not save the animation? I.e., if you only click on the "play" icon button?
I'll test and say.
Quote:
Cell vs Point is shown in this post: studying a valve case post #10
I don't know which one is which!
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 18, 2013, 13:03
Default
  #14
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Quote:
Originally Posted by immortality View Post
then I should use "save state" and "load state" after I start paraView?
Yes, use "File -> Load State" after ParaView starts.

Quote:
Originally Posted by immortality View Post
I don't know which one is which!
I've edit the other post at the other thread, with a more clear indication of which is which.
wyldckat is offline   Reply With Quote

Old   August 18, 2013, 13:17
Default
  #15
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
I forgot to say this error occurs when playing or animating in paraView in all time snapshots not only first time step due to #'s in 0 folder:

Code:
ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 19 of /home/ehsan/Desktop/WR_4/0/T: Expected number, string or (, found Temperature


ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 19 of /home/ehsan/Desktop/WR_4/0/U: Expected number, string or (, found Velocity


ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 20 of /home/ehsan/Desktop/WR_4/0/k: Expected number, string or (, found turbulentK


ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 20 of /home/ehsan/Desktop/WR_4/0/omega: Expected number, string or (, found turbulentOmega


ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 19 of /home/ehsan/Desktop/WR_4/0/p: Expected number, string or (, found Pressure


Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 19 of /home/ehsan/Desktop/WR_4/0/T: Expected number, string or (, found Temperature


ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 19 of /home/ehsan/Desktop/WR_4/0/U: Expected number, string or (, found Velocity


ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 20 of /home/ehsan/Desktop/WR_4/0/k: Expected number, string or (, found turbulentK


ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 20 of /home/ehsan/Desktop/WR_4/0/omega: Expected number, string or (, found turbulentOmega


ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 19 of /home/ehsan/Desktop/WR_4/0/p: Expected number, string or (, found Pressure


Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 18, 2013, 15:13
Default
  #16
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
For other readers, I've already explained this one:
Quote:
Originally Posted by immortality View Post
Code:
ERROR: In /home/opencfd/OpenFOAM/ThirdParty-dev/ParaView-3.12.0/VTK/IO/vtkOpenFOAMReader.cxx, line 6481
vtkOpenFOAMReaderPrivate (0x1ad5ec0): Error reading line 19 of /home/ehsan/Desktop/WR_4/0/T: Expected number, string or (, found Temperature
I explained this here: do particle tracking in paraview? post #35


As for this error:
Quote:
Originally Posted by immortality View Post
Code:
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/simple.py", line 39, in <module>
    import servermanager
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/servermanager.py", line 43, in <module>
    import paraview, re, os, os.path, new, sys, vtk
  File "/opt/paraviewopenfoam3120/lib/paraview-3.12/site-packages/paraview/vtk/__init__.py", line 1, in <module>
    from vtkCommonPython import *
ImportError: No module named vtkCommonPython
I reported it just now here: http://www.openfoam.org/mantisbt/view.php?id=969

I'm currently trying to figure out if there a simple fix for this.

Best regards,
Bruno
immortality likes this.
wyldckat is offline   Reply With Quote

Old   August 18, 2013, 16:15
Default
  #17
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
OK, as implied in the previous post, the bug is related to the missing "vtk*Python.so" library files. This post is meant to fix this problem.


In my DropBox account is the following file (130kB): http://dl.dropboxusercontent.com/u/7...thon_so.tar.gz - it provides the aforementioned library binaries for x86_64, built on a virtual machine with OpenSUSE 12.1 x86_64 and Python 2.7.2, which where built for this post: paraview and python install problem post #5

WARNING: Given that these binaries are in my DropBox account and not signed as in Ubuntu, so there is always a risk of the binaries being contaminated with something
Nonetheless, the SHA256 of this file is:
Code:
0acb36947b1f85bf8f3e6d0d6b2958bd602527cee00a15953fd32de566a1fc4e  ParaView-3.12.0-vtk_Python_so.tar.gz
I got it by running:
Code:
sha256sum ParaView-3.12.0-vtk_Python_so.tar.gz
Now, once you download the file, close ParaView and run the following command from where you have the file:
Code:
sudo tar -xf ParaView-3.12.0-vtk_Python_so.tar.gz -C/opt/paraviewopenfoam3120/lib/paraview-3.12
Now, once you start ParaView once again, it should now work as intended.

--------------------

At the request sent to me over private message, here is the 32bit version of the "vtk*Python.so" library files: https://www.dropbox.com/s/xeon94tor1...so-i686.tar.gz - it was built in Ubuntu 12.04 i686, which uses Python 2.7.3.
The SHA256 of this file is:
Code:
2874b682999075462dd131aa0aa81994fc10a273e4e7ea8253d53752089d9910  ParaView-3.12.0-vtk_Python_so-i686.tar.gz
The instructions are the same.

Last edited by wyldckat; October 26, 2013 at 17:28. Reason: Added link and info for the 32bit
wyldckat is offline   Reply With Quote

Old   August 18, 2013, 16:28
Default
  #18
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
With the previous post, the bug is fixed. The post #6 has been updated with instructions on how to use the script in ParaView 3.12.0.

@Ehsan: As a result, the code you should be using is this:
Code:
from paraview.simple import *

def start_cue(self): pass

def tick(self):
    source = FindSource("WR_3.OpenFOAM")
    source.UpdatePipeline(GetAnimationScene().TimeKeeper.Time)

    #The array and number of components
    #arrayName = "p"
    #arrayComponents = 1
    #component = -1
    #options for component: -1, 0, 1 and 2 => Mag, X, Y, Z

    # If it's a scalar field
    arrayName = "p"
    arrayComponents = 1
    component = 0


    #Get the look-up table for this array
    lookupTable = GetLookupTableForArray(arrayName, arrayComponents)

    #get the access to the cellData or pointData
    data = source.GetCellDataInformation()
    #data = source.GetPointDataInformation()

    #get the array and the respective min-max
    array = data.GetArray(arrayName)
    dataRange = array.GetRange(component)

    lookupTable.LockScalarRange = 1

    #Now let's hack in the range values
    lookupTable.RGBPoints[0] = dataRange[0] #min
    lookupTable.RGBPoints[4] = dataRange[1] #max


def end_cue(self): pass
wyldckat is offline   Reply With Quote

Old   August 18, 2013, 17:11
Default
  #19
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
this kind of errors is shown when play and the minimum and maximum are not correct,I have set poinData in the code:

Code:
  File "<string>", line 27
    data = source.GetPointDataInformation()
    ^
IndentationError: unexpected indent
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.

Last edited by wyldckat; August 18, 2013 at 17:16. Reason: fixed long post. there was no need to post the same error message several times
immortality is offline   Reply With Quote

Old   August 18, 2013, 17:19
Default
  #20
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
It means that your code is broken. This is why I don't completely like Python

The reason is because for Python, this:
Code:
def tick(self):

    #...

    #get the access to the cellData or pointData
    #data = source.GetCellDataInformation()
     data = source.GetPointDataInformation()
is incorrect. The corrected code is:
Code:
def tick(self):

    #...

    #get the access to the cellData or pointData
    #data = source.GetCellDataInformation()
    data = source.GetPointDataInformation()

Therefore, the correct complete code you want should be:
Code:
from paraview.simple import *

def start_cue(self): pass

def tick(self):
    source = FindSource("WR_3.OpenFOAM")
    source.UpdatePipeline(GetAnimationScene().TimeKeeper.Time)

    #The array and number of components
    #arrayName = "p"
    #arrayComponents = 1
    #component = -1
    #options for component: -1, 0, 1 and 2 => Mag, X, Y, Z

    # If it's a scalar field
    arrayName = "p"
    arrayComponents = 1
    component = 0


    #Get the look-up table for this array
    lookupTable = GetLookupTableForArray(arrayName, arrayComponents)

    #get the access to the cellData or pointData
    #data = source.GetCellDataInformation()
    data = source.GetPointDataInformation()

    #get the array and the respective min-max
    array = data.GetArray(arrayName)
    dataRange = array.GetRange(component)

    lookupTable.LockScalarRange = 1

    #Now let's hack in the range values
    lookupTable.RGBPoints[0] = dataRange[0] #min
    lookupTable.RGBPoints[4] = dataRange[1] #max


def end_cue(self): pass
wyldckat is offline   Reply With Quote

Reply

Tags
paraview, rescale to data range

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
fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ... 12 May 2, 2013 10:52
data range problem bptsj ParaView 1 October 5, 2012 10:35
Automatic Data Export (ascii format) A Kourm FLUENT 3 January 21, 2009 08:36
Automatic range in paraview animations arno OpenFOAM Paraview & paraFoam 1 August 29, 2006 04:00
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 18:27


All times are GMT -4. The time now is 04:20.