[Paraview] Memory issues with pvpython
Felix Salazar
felix.salazar at polymtl.ca
Wed Oct 23 14:08:56 EDT 2013
Hello paraview users and community
I checked old messages in the mail list, and found a similar question. I
modified the script, deleting some objects after each iteration with the
Delete() function, to avoid repetition. Now, there's no memory growth
during the loop.
Thanks
------------------------------------*
Félix Salazar
**felix.salazar at polymtl.ca**
*Étudiant au doctorat - PhD Student
*École Polytechnique de Montréal*
* LADYF*
* *Lab. de dynamique des fluides
(514) 340 4711 ext 2489
Local: C-318.21.3*
*------------------------------------
On Thu, Oct 10, 2013 at 6:03 PM, Felix Salazar <felix.salazar at polymtl.ca>wrote:
> Hello,
>
> I'm not very good in python, and I'm new in Paraview. I want to calculate
> an integral over a series of slices in a domain. I need an scalar per
> slice, that result being a function of the position of the slice. The
> easiest way I found to do this was a for loop in pvpython, changing the
> position of a single in each iteration, and dumping the value of the
> integral into an output file, one line per slice. Works good.
>
> Then I slightly modified my script to works with several files at the same
> time. It works without errors, but the memory usage grows each time a new
> file is processed, until eventually the machine collapse, and an error is
> printed (SEGFAULT).
>
> I read that some functions in pvpython have a memory leak, and the way to
> deal with this was using UnRegister(). I tried it, but it didn't solve my
> issues. Maybe I did not putting in the right place. Could someone help me
> with this issue?
>
> My script is the following. I removed the UnRegister() because they were
> not working. I also add a bunch of stuff at the beginning, to change the
> parameters of integration via command line options. I'm using ParaView
> 4.01, and my files are in the legacy .vtk file format. Thanks in advance
> for any help
>
> ==================
> START OF THE SCRIPT
> ==================
> #!/apps/local-linux/paraview4.01/bin/pvpython
>
> try: paraview.simple
> except: from paraview.simple import *
>
> import sys, getopt, math, subprocess, os.path
>
> def main(argv):
> inputfile = 'NS.vtk'
> Nstep = 200
> Zmin = -2.
> Zmax = 20.
> Zoffset = +1.
> try:
> opts, args =
> getopt.getopt(argv,"hi:o:N:Zmax:Zmin:Zoff:",["ifile=","Nstep=","zStart=","zEnd=","zOffset="])
> except getopt.GetoptError:
> print 'slices.py -i <inputfile> -N <Nstep> -Zmin <Z 1st slice> -Zmax <Z
> final slice> -Zoff <Offset in Z>'
> sys.exit(2)
> for opt, arg in opts:
> if opt == '-h':
> print 'slices.py -i <inputfile> -N <Nstep> -Zmin <Z 1st slice> -Zmax <Z
> final slice> -Zoff <Offset in Z>'
> sys.exit()
> elif opt in ("-i", "--ifile"):
> inputfile = arg
> elif opt in ("-N", "--Nstep"):
> Nstep = int(arg)
> elif opt in ("-Zmax", "--zEnd"):
> Zmax = float(arg)
> elif opt in ("-Zmin", "--zStart"):
> Zmin = float(arg)
> elif opt in ("-Zoff", "--zOffset"):
> Zoffset = float(arg)
>
> inputfile = '..' + inputfile
> command = ['find', '.', '-type', 'f', '-regex', inputfile]
> FileList = subprocess.check_output(command).split()
> for k in range (0,len(FileList)):
> vtkfile = FileList[k].replace('./','')
> outfile = FileList[k].replace('./','').replace('vtk','dat')
>
> if not os.path.isfile(outfile):
> NS_quad_vtk = LegacyVTKReader(FileNames=vtkfile)
>
> print "output: %s" %(outfile)
>
> Calculator1 = Calculator()
> Calculator1.Function = 'U+V+W_Z*coordsX'
> Calculator1.ResultArrayName = 'momX'
>
> Slice1 = Slice( SliceType="Plane" )
>
> IntegrateVariables1 = IntegrateVariables()
> IntegrateVariables1.Input=Slice1
>
> fout = open(outfile,'w')
>
> for i in range (0,Nstep):
> zOrigin = Zmin + float(i)*(Zmax-Zmin)/(Nstep-1.)
> Slice1.SliceOffsetValues = [0.0]
> Slice1.SliceType.Origin = [0.0, 0.0, zOrigin]
> Slice1.SliceType.Normal = [0.0, 0.0, 1.0]
> Slice1.SliceType = "Plane"
>
> intResult = servermanager.Fetch(IntegrateVariables1,0)
> pointIntResult = intResult.GetPointData()
> intMx = pointIntResult.GetArray("momX").GetTuple1(0)
> intW = pointIntResult.GetArray("U+V+W").GetTuple3(0)[2]
> E = intMx/intW
> fout.write(str(zOrigin+Zoffset) + "\t" + str(E) + "\n")
>
> fout.close()
>
> if __name__ == "__main__":
> main(sys.argv[1:])
> =================
> END OF THE SCRIPT
> =================
>
> ------------------------------------*
> Félix Salazar
> **felix.salazar at polymtl.ca**
> *Étudiant au doctorat - PhD Student
> *École Polytechnique de Montréal*
> ------------------------------------
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20131023/d27c3dcf/attachment.htm>
More information about the ParaView
mailing list