[Paraview] Slices generation with pvpython

Borchi Leonardo Leonardo.Borchi at ducati.com
Wed Apr 8 04:47:27 EDT 2015


Hi everybody,

I have a problem when I tried to implement an automated procedure for postprocessing analysis.
I have wrote and run (from command prompt) the following script with pvpython.exe.

If the variable numberofslice is <= 20 the script run well, but if I try to generate 40 slides for example, after the twenty one, for a couple of slide, the image is blank. After that, the following slides are generated in a correct manner.

I have tried to change the py with different type of algorithm ( for, while, if ) but the problem remain.

Have you any ideas for resolve this strange issue??


Thanks for your support



Leonardo

#Import the simple module from the paraview
from paraview.simple import *

#Disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

#Create a new 'OpenFOAMReader'
case_foam = OpenFOAMReader(FileName='\\\\SERVERCORSE\\RUN_051\\case.foam')
(xmin,xmax,ymin,ymax,zmin,zmax) = case_foam.GetDataInformation().GetBounds()
xmax = float(2.000)
xmin = float(-0.200)
ymax = float(0.250)
ymin = float(-0.250)
zmax = float(1.350)
zmin = float(0.000)
numberofslice = 20
deltax = (xmax-xmin)/numberofslice
deltay = (ymax-ymin)/numberofslice
deltaz = (zmax-zmin)/numberofslice
case_foam.CellArrays = ['U', 'p']
case_foam.MeshRegions = ['internalMesh']

#Use node discretization instead of cell one.
pointData = CellDatatoPointData(Input=case_foam)

#Calculate Cp and Cg coefficients
Cp = Calculator(Input=pointData)
Cp.Function = 'p/(0.5*50*50)'
Cp.ResultArrayName = 'Cp'
Cg = Calculator(Input=Cp)
Cg.Function = '(p+(0.5*(U.U)))/(0.5*50*50)'
Cg.ResultArrayName = 'Cg'

renderView_ = CreateRenderView()
renderView_.ViewSize = [1920,1080]
renderView_.InteractionMode ='2D'

# Z SLICE
#renderView_.CameraPosition = [1.104649161719515, 0.1483969716170493, 70.80596909030284]
#renderView_.CameraFocalPoint = [1.104649161719515, 0.1483969716170493, 0.30000001192092896]
#renderView_.CameraViewUp = [0.0, 1.0, 0.0]
#renderView_.CameraParallelScale = 0.8642834397172128

# Y SLICE
#renderView_.CameraPosition = [0.76, -70.50, 0.85]
#renderView_.CameraFocalPoint = [0.76, 0.0, 0.85]
#renderView_.CameraViewUp = [0.0, 0.0, 1.0]
#renderView_.CameraParallelScale = 1.25

# X SLICE
renderView_.CameraPosition = [16.89230484541337, 0.022500131777517626, 0.8954779729169607]
renderView_.CameraFocalPoint = [0.5, 0.022500131777517626, 0.8954779729169607]
renderView_.CameraViewUp = [0.0, 0.0, 1.0]
renderView_.CameraParallelScale = 0.9233222262058975

cgCM_ = GetColorTransferFunction('Cg')
cgCM_.RGBPoints = [-1.00, 0.0, 0.0, 1.0, 1.20, 1.0, 0.0, 0.0]
cgCM_.ColorSpace = 'HSV'
cgCM_.NanColor = [0.498039, 0.498039, 0.498039]
cgCM_.ScalarRangeInitialized = 1.0

cgOM_ = GetOpacityTransferFunction('Cg')
cgOM_.Points = [-1.00, -0.5, 0.0, 0.5, 1.0]
cgOM_.ScalarRangeInitialized = 1

cgCMColorBar_ = GetScalarBar(cgCM_, renderView_)

# Z SLICE
#cgCMColorBar_.Position = [0.2924509803921572, 0.8569873380156294]
#cgCMColorBar_.Position2 = [0.4299999999999994, 0.1200000000000001]

# Y SLICE
#cgCMColorBar_.Position = [0.30, 0.025]
#cgCMColorBar_.Position2 = [0.45, 0.025]

# X SLICE
cgCMColorBar_.Position = [0.2675490196078431, 0.8524428726877044]
cgCMColorBar_.Position2 = [0.42999999999999955, 0.11999999999999988]

cgCMColorBar_.Orientation = 'Horizontal'
cgCMColorBar_.Title = 'Cg'
cgCMColorBar_.ComponentTitle = ''
cgCMColorBar_.TextPosition = 'Ticks left/bottom, annotations right/top'
cgCMColorBar_.RangeLabelFormat = '%4.3f'
cgCMColorBar_.NumberOfLabels = 2
cgCMColorBar_.TitleBold = 1
cgCMColorBar_.TitleItalic = 1
cgCMColorBar_.LabelFontFamily = 'Courier'
cgCMColorBar_.LabelBold = 1
cgCM_.LockScalarRange = 1
cgCM_.RescaleTransferFunction(-0.3, 1.2)
cgOM_.RescaleTransferFunction(-0.3, 1.2)

coord = xmin
iteraz = 0

while coord < xmax:

                         slice_ = Slice(Input=Cg)
                         slice_.SliceType = 'Plane'
                         slice_.SliceType.Origin = [coord, 0.000, 0.000]
#                       slice_.SliceType.Origin = [0.000, coord, 0.000]
#                       slice_.SliceType.Origin = [0.000, 0.000, coord]
                         slice_.SliceType.Normal = [1.0, 0.0, 0.0]
#                       slice_.SliceType.Normal = [0.0, 1.0, 0.0]
#                       slice_.SliceType.Normal = [0.0, 0.0, 1.0]
                         slice_.SliceOffsetValues = [0.0]

                         slice_display_ = Show(slice_, renderView_)
                         slice_display_.ColorArrayName = ['POINTS', 'Cg']
                         cgCM_.RescaleTransferFunction(-0.3, 1.2)
                         cgOM_.RescaleTransferFunction(-0.3, 1.2)
                         slice_display_.LookupTable = cgCM_
                         slice_display_.SetScalarBarVisibility(renderView_, True)

                         name_file = '\\\\SERVER\\RUN_051\\postProcessing\\00%4.0d_img_%4.3f.png' % (iteraz, coord)

                         Render(view=renderView_)

                         SaveScreenshot(name_file, magnification=1, quality=100, view=renderView_)

                         coord = coord + deltax
                         iteraz = iteraz + 1

                         Delete(slice_)
                         Delete(slice_display_)

                         del slice_
                         del slice_display_

Delete(renderView_)
del renderView_
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150408/1cc440b9/attachment.html>


More information about the ParaView mailing list