CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Paraview & paraFoam (http://www.cfd-online.com/Forums/openfoam-paraview/)
-   -   Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 (http://www.cfd-online.com/Forums/openfoam-paraview/118294-annoying-issue-automatic-rescale-data-range-parafoam-paraview-3-12-a.html)

keepfit May 24, 2013 08:49

Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12
 
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.)
http://24.media.tumblr.com/c5416f7c2...saho1_1280.png

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

http://24.media.tumblr.com/f6927b4a1...saho2_1280.png



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

Best,

David

wyldckat May 25, 2013 08:44

1 Attachment(s)
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 :eek:
Best regards,
Bruno

keepfit May 25, 2013 15:55

Quote:

Originally Posted by wyldckat (Post 429974)
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 :eek:
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?

wyldckat May 25, 2013 16:07

Quote:

Originally Posted by keepfit (Post 430021)
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.

immortality August 3, 2013 20:58

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.

wyldckat August 17, 2013 13:24

1 Attachment(s)
Greetings to all!

Quote:

Originally Posted by immortality (Post 443662)
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 (Post 443662)
@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 (Post 429792)
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: http://www.cfd-online.com/Forums/ope...tml#post446170
Best regards,
Bruno

immortality August 18, 2013 10:32

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?

wyldckat August 18, 2013 10:41

Quote:

Originally Posted by immortality (Post 446423)
I did what you told

What exactly? Did you see how much I wrote on the previous post? :rolleyes:

Quote:

Originally Posted by immortality (Post 446423)
can't do anything?

Do what? :confused:

immortality August 18, 2013 10:52

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?

wyldckat August 18, 2013 11:00

No, the ".OpenFOAM" file is not the problem.

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

immortality August 18, 2013 11:25

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?

wyldckat August 18, 2013 11:55

Quote:

Originally Posted by immortality (Post 446437)
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 (Post 446437)
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 (Post 446437)
is the field with a circle on left in a point representation not cell represent,right?

Cell vs Point is shown in this post: http://www.cfd-online.com/Forums/ope...tml#post446170 post #10

immortality August 18, 2013 12:54

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!

wyldckat August 18, 2013 13:03

Quote:

Originally Posted by immortality (Post 446458)
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 (Post 446458)
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.

immortality August 18, 2013 13:17

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


wyldckat August 18, 2013 15:13

For other readers, I've already explained this one:
Quote:

Originally Posted by immortality (Post 446463)
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: http://www.cfd-online.com/Forums/ope...tml#post446210 post #35


As for this error:
Quote:

Originally Posted by immortality (Post 446463)
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

wyldckat August 18, 2013 16:15

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: http://www.cfd-online.com/Forums/ope...tml#post435470 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.

wyldckat August 18, 2013 16:28

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


immortality August 18, 2013 17:11

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


wyldckat August 18, 2013 17:19

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



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