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

[OpenFOAM] pvpython

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

Like Tree3Likes
  • 3 Post By TReviol

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 8, 2016, 10:35
Default pvpython
  #1
New Member
 
Thomas Reviol
Join Date: Jul 2011
Location: Germany, Kaiserslautern
Posts: 27
Rep Power: 11
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, 03:55
Default
  #2
New Member
 
Thomas Reviol
Join Date: Jul 2011
Location: Germany, Kaiserslautern
Posts: 27
Rep Power: 11
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, JensD and Simone81 like this.
TReviol is offline   Reply With Quote

Reply

Tags
open foam, paraview, pvpython, python script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 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 09:44
[General] Export spreadsheet from pvpython wgan ParaView 0 June 10, 2016 15:53
[General] pvpython can't find numpy seanread ParaView 0 April 4, 2016 21:40
[OpenFOAM] matlab call a pvpython script, ecountering error dalianwei ParaView 0 July 11, 2015 12:09
[OpenFOAM] setting up pvpython to act like parafoam jonathanbyrn ParaView 1 September 26, 2013 09:42


All times are GMT -4. The time now is 21:51.