CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[OpenFOAM] pvpython

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 4 Post By TReviol

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 8, 2016, 11:35
Default pvpython
  #1
New Member
 
Thomas Reviol
Join Date: Jul 2011
Location: Germany, Kaiserslautern
Posts: 27
Rep Power: 15
TReviol is on a distinguished road
Dear Foamers,

I am trying to use pvpython for my postProcessing. I studied some examples and tutorials, but I didn't find out how to create a Slice for a simple Foam-Case. (Maybe I just could't find the correct hint within many many possible google search results. And yes, I am felling very ashamed to be unable to solve such a simple problem )

I attach my python script and I hope one of you will find my mistake/misunderstanding:

Code:
from paraview.simple import *

case1=OpenFOAMReader(FileName='./elbow.foam')
case1.CellArrays = ['U']
case1.MeshRegions = ['internalMesh']
case1.TimestepValues.SetData(10.0)

servermanager.Fetch(case1)

pointData = CellDatatoPointData(Input=case1)

U=Calculator(Input=pointData)
U.Function='U'
#U_=GetLookupTableForArray('U',1)

slice1=Slice(Input=pointData)
slice1.SliceType="Plane"
slice1.SliceType.Origin=[0.0, 0.0, 0.0]
slice1.SliceType.Normal=[0.0, 0.0, 1.0]
slice1.PointData.GetArray(0)
slice1.UpdatePipeline()

view1=CreateRenderView()
view1.ViewSize = [600,400]
view1.InteractionMode ='2D'
view1.CameraViewUp = [0.0, 1.0, 1.0]

display1=Show(slice1, view1)
display1.SelectScaleArray=['U']

servermanager.SaveState('./elbow.pvsm')
As you can see, I tried my script with the icoFoam-elbow-Tutorial. After executing the script in pvpython, I check the result in paraview via the pvsm-file. The result is: the data-import as well as the creation of the slice is correctly done. But I do not know how to colour the slice by the variable U.

Maybe one of you has already solved this problem?

Kind Regards

Thomas
TReviol is offline   Reply With Quote

Old   July 10, 2016, 04:55
Default
  #2
New Member
 
Thomas Reviol
Join Date: Jul 2011
Location: Germany, Kaiserslautern
Posts: 27
Rep Power: 15
TReviol is on a distinguished road
Dear Foamers,

I solved the problem by myself. Attached you find a working python-script.


Code:
from paraview.simple import *

#paraview.simple._DisableFirstRenderCameraReset()

# Read Foam Case
case1=OpenFOAMReader(FileName='./elbow.foam')
case1.CellArrays = ['U']
case1.MeshRegions = ['internalMesh']
servermanager.Fetch(case1)
pointData = CellDatatoPointData(Input=case1)

# create slice
slice1=Slice(Input=pointData)
slice1.SliceType="Plane"
slice1.SliceType.Origin=[0.0, 0.0, 0.0]
slice1.SliceType.Normal=[0.0, 0.0, 1.0]
slice1.PointData.GetArray(0)

# create view
view1=CreateRenderView()
#view1.ViewSize = [600,400]
view1.InteractionMode ='2D'
#view1.CameraViewUp = [0.0, 1.0, 1.0]
view1.ViewTime=max(case1.TimestepValues)

# show view
display1=Show(slice1, view1)
display1.Visibility=1
display1.ColorArrayName='U'
display1.LookupTable=GetLookupTableForArray("U", 0)

# save state
#servermanager.SaveState('./elbow.pvsm')

# render view
Render()
Thomas
cbcoutinho, FlyFox, JensD and 1 others like this.
TReviol is offline   Reply With Quote

Reply

Tags
open foam, paraview, pvpython, python script


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM] Correctly loading my casefiles via pvpython karma15 ParaView 3 August 18, 2016 10:44
[General] Export spreadsheet from pvpython wgan ParaView 0 June 10, 2016 16:53
[General] pvpython can't find numpy seanread ParaView 0 April 4, 2016 22:40
[OpenFOAM] matlab call a pvpython script, ecountering error dalianwei ParaView 0 July 11, 2015 13:09
[OpenFOAM] setting up pvpython to act like parafoam jonathanbyrn ParaView 1 September 26, 2013 10:42


All times are GMT -4. The time now is 10:38.