|
[Sponsors] |
July 8, 2016, 11:35 |
pvpython
|
#1 |
New Member
Thomas Reviol
Join Date: Jul 2011
Location: Germany, Kaiserslautern
Posts: 27
Rep Power: 15 |
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') Maybe one of you has already solved this problem? Kind Regards Thomas |
|
July 10, 2016, 04:55 |
|
#2 |
New Member
Thomas Reviol
Join Date: Jul 2011
Location: Germany, Kaiserslautern
Posts: 27
Rep Power: 15 |
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() |
|
Tags |
open foam, paraview, pvpython, python script |
|
|
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 |