[Paraview] Delete Data Array from unstructured mesh in pypython

Dan Goldstein dan at cora.nwra.com
Wed Mar 4 15:34:32 EST 2009


  Can anyone give me a hint on how to delete an array from an  
unstructured mesh
in a python script. I need to do this to save memory when going  
through multiple
steps processing data.
Below is an example python script and where I would like to delete  
unused arrays to save memory.
Thanks for any help or ideas.. Dan


     reader =  \
        servermanager.sources.XMLUnstructuredGridReader(FileName=in_dir 
+"/"+in_file)

# Use calculator to get the first component of velocity into the
     # scalar array velocity_u
     calc_u = servermanager.filters.Calculator(Input=reader)
     calc_u.ResultArrayName ='velocity_u'
     calc_u.AddScalarVariable = ['velocity', 'velocity', '0']
     calc_u.Function = 'velocity'

# Use calculator to get the first component of velocity into the
     # scalar array velocity_u
     calc_v = servermanager.filters.Calculator(Input=calc_u)
     calc_v.ResultArrayName ='velocity_v'
     calc_v.AddScalarVariable = ['velocity', 'velocity', '1']
     calc_v.Function = 'velocity'

# Use calculator to get the first component of velocity into the
     # scalar array velocity_u
     calc_w = servermanager.filters.Calculator(Input=calc_v)
     calc_w.ResultArrayName ='velocity_w'
     calc_w.AddScalarVariable = ['velocity', 'velocity', '2']
     calc_w.Function = 'velocity'

# I NO LONGER NEED THE WHOLE VELOCITY FIELD I WOULD LIKE TO DELETE IT

#calculate gradiants du
     grad_u= servermanager.filters.UnstructuredGradient(Input=calc_w)
     grad_u.ResultArrayName = "du"
     grad_u.SelectInputScalars = ["0","0","0","0","velocity_u"]
#calculate gradiants dv
     grad_v= servermanager.filters.UnstructuredGradient(Input=grad_u)
     grad_v.ResultArrayName = "dv"
     grad_v.SelectInputScalars = ["0","0","0","0","velocity_v"]
#calculate gradiants dw
     grad_w= servermanager.filters.UnstructuredGradient(Input=grad_v)
     grad_w.ResultArrayName = "dw"
     grad_w.SelectInputScalars = ["0","0","0","0","velocity_w"]

# I NO LONGER NEED THE WHOLE VELOCITY SCALAR FIELDS I WOULD LIKE TO  
DELETE THEM

#calculate vorticity magnitude
     calc_vort = servermanager.filters.Calculator(Input=grad_w)
     calc_vort.ResultArrayName ='VortMag'
     calc_vort.AddScalarVariable = \
        ['dudx', 'du', '0','dudy', 'du', '1','dudz', 'du', '2',\
         'dvdx', 'dv', '0','dvdy', 'dv', '1','dvdz', 'dv', '2',\
         'dwdx', 'dw', '0','dwdy', 'dw', '1','dwdz', 'dw', '2', ]
     calc_vort.Function = 'sqrt( (dwdy - dvdz)^2  + (dudz - dwdx)^2 +  
(dvdx - dvd
y )^2 )'

# ALL DONE ! I WOULD LIKE TO DELETE EVERYTHING EXCEPT THE REQUIRED  
VORTICITY MAGNITUDE SCALAR FIELD

     writer =  
servermanager.writers.XMLUnstructuredGridWriter(Input=calc_vort,\
              FileName=out_file )
     writer.UpdatePipeline()


More information about the ParaView mailing list