[Paraview] pvpython eating all my memory

Peter Brady petertbrady at gmail.com
Wed Apr 1 16:48:29 EDT 2009


Hello all,

I have some reasonable sized data sets (256x256x512) that I'm using
paraview to do some postprocessing on via a python script.  However,
for some reason, as time progresses and it slogs through more
timesteps the memory usage slowly creeps up until my workstation
crashes (seems to take about 200-300 timesteps before it eats up all
my memory).  I haven't encountered this problem before but this is the
largest data set I've processed thus far.  My data format is ensight
gold.  The script I'm using is below:

from paraview import servermanager

if not servermanager.ActiveConnection:
    connection = servermanager.Connect()

suffix = ''

# open file center_vol_data and get center and radius data
datafile = open('center_vol_data'+suffix, 'r')
lines = datafile.readlines()
datafile.close()

filterfile = open('prog_filter.py', 'r')
filterString = filterfile.read()
filterfile.close()

tempfile = open('temp_data', 'w')
tempfile.write(lines[0])
tempfile.close()

# open NGA data and read in temperature field
#nga_reader = servermanager.sources.ensight(ByteOrder='LittleEndian',CaseFileName='ensight-3D/arts.case')

#nga_reader.UpdatePipelineInformation()
# only read in temperature...
a1 = ['Pressure', '0']
a2 = ['Viscosity', '0']
a3 = ['Diffusivity', '0']
a4 = ['T', '1']
a5 = ['VolumeFraction', '0']
a6 = ['Density', '0']
a7 = ['Curvature', '0']
a8 = ['SurfaceTension', '0']
a9 = ['Sigma', '0']
a10 = ['divg', '0']
a11 = ['Pcrit', '0']
a12 = ['Qcrit', '0']
a13 = ['Rcrit', '0']
#nga_reader.CellArrayStatus = a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13
#nga_reader.UpdatePipeline()

# outline source
myBox = servermanager.sources.OutlineSource()
myBox.Bounds = [-0.0225, 0.0225, -0.0225, 0.0225, 0.0, 0.060]
myBox.UpdatePipeline()

# open LIT data
lit_reader = servermanager.sources.ensight(ByteOrder='LittleEndian',

CaseFileName='dump'+suffix+'/td.case')
lit_reader.UpdatePipelineInformation()
# only read in G field
a1 = ['G', '1']
a2 = ['KAPPA', '0']
a3 = ['V', '0']
lit_reader.PointArrayStatus = a1+a2+a3
lit_reader.UpdatePipeline()

# apply contour to G field
g_cont = servermanager.filters.Contour(Input=lit_reader)
g_cont.ContourValues = 0.0
g_cont.SelectInputScalars = ['0', '0', '0', '0', 'G']
g_cont.UpdatePipeline()

# resample dataset
#resample = servermanager.filters.Probe(Input=nga_reader, Source=g_cont)
#resample.UpdatePipeline()

# read in center and volume from file
#deform = servermanager.filters.ProgrammableFilter(Input=resample)
deform = servermanager.filters.ProgrammableFilter(Input=g_cont)
deform.Script = filterString
deform.UpdatePipeline()

# create rendering views
view = servermanager.CreateRenderView()
rep1 = servermanager.CreateRepresentation(deform, view)
rep1.Representation = 2 # set view to surface
#rep2 = servermanager.CreateRepresentation(nga_reader, view)
rep2 = servermanager.CreateRepresentation(myBox, view)
rep2.Representation = 3

# set background to black
view.Background = [0.0, 0.0, 0.0]
view.CameraParallelProjection = 1
view.ViewSize = [625,700]
view.CameraPosition = [0.0263666,-0.165717,0.0707883]
view.CameraViewUp = [-0.019148, 0.236082, 0.971544]
view.UseOffscreenRenderingForScreenshots = 0
view.ResetCamera()

lt = servermanager.rendering.PVLookupTable()
rep1.LookupTable = lt
rep1.ColorAttributeType = 0 # point data
rep1.ColorArrayName = "radiusDeform"
lt.RGBPoints = [-3,0,0,1,3,1,0,0]
lt.ColorSpace = 1
rep2.Color = [1.0, 1.0, 1.0]

# color legend
sbar = servermanager.rendering.ScalarBarWidgetRepresentation()
sbar.Title = '% def'
sbar.LookupTable = lt
sbar.Position = [0.85, 0.1]
view.Representations.append(sbar)

# get timesteps and append to view
tsteps = lit_reader.TimestepValues.GetData()
annTime = servermanager.filters.TimeToTextConvertor(Input=lit_reader)
timeRep = servermanager.rendering.TextSourceRepresentation(Input=annTime)
view.Representations.append(timeRep)
#make bigger
timeRep.Position2 = [0.2,0.2]

# get ready to do some file saving
#savestep = [0, 1] # frame of interest
savestep= range(1000,1100)
namei = map(str, savestep)
#offset = 624-63
#for i in range(len(savestep)):
#    namei[i] = str(savestep[i]+offset)

for i in range(len(savestep)):
    tempfile = open('temp_data', 'w')
    tempfile.write(lines[savestep[i]])
    tempfile.close()
    view.ViewTime = tsteps[savestep[i]]
    if savestep[i] < 10:
        namei[i] = "000" + namei[i]
    elif savestep[i] < 100:
        namei[i] = "00" + namei[i]
    elif savestep[i] < 1000:
        namei[i] = "0" + namei[i]
    view.WriteImage("movie/arc."+namei[i]+".png", "vtkPNGWriter", 1)

Any help in this matter would be greatly appreciated.
Thanks,
Peter.


More information about the ParaView mailing list