Indeed, I think this would be very useful. For example I often use several calculators in a pipeline and then create a custom filter from my pipeline. Although the only data I need is the one in the output from my custom filter, all the intermediate variables are kept in memory (right?) which can make everything blow up. <div>
I know I can write the equivalent C++ code and only keep the array I want, but this means I do not use the existing filters.. </div><div><br></div><div>Jacques<br><br><div class="gmail_quote">2009/3/5 Berk Geveci <span dir="ltr"><<a href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Use a programmable filter with the following code (or something close to it):<br>
<br>
input = self.GetInputDataObject(0,0)<br>
output = self.GetOutputDataObject(0)<br>
output.CopyStructure(input)<br>
output.GetPointData().AddArray(input.GetArray("pressure"))<br>
<br>
This would avoid passing everything but pressure to the output.<br>
However, it would not delete the other arrays from memory as the<br>
previous objects in the pipeline are still referring to them. It<br>
would, however, prevent further processing of those arrays. There is<br>
really no way of deleting an object once you load it. There are ways<br>
of doing this in VTK. If there is a need for it, we can put<br>
investigating the idea on our roadmap.<br>
<font color="#888888"><br>
-berk<br>
</font><div><div></div><div class="h5"><br>
<br>
On Wed, Mar 4, 2009 at 3:34 PM, Dan Goldstein <<a href="mailto:dan@cora.nwra.com">dan@cora.nwra.com</a>> wrote:<br>
><br>
> Can anyone give me a hint on how to delete an array from an unstructured<br>
> mesh<br>
> in a python script. I need to do this to save memory when going through<br>
> multiple<br>
> steps processing data.<br>
> Below is an example python script and where I would like to delete unused<br>
> arrays to save memory.<br>
> Thanks for any help or ideas.. Dan<br>
><br>
><br>
> reader = \<br>
><br>
> servermanager.sources.XMLUnstructuredGridReader(FileName=in_dir+"/"+in_file)<br>
><br>
> # Use calculator to get the first component of velocity into the<br>
> # scalar array velocity_u<br>
> calc_u = servermanager.filters.Calculator(Input=reader)<br>
> calc_u.ResultArrayName ='velocity_u'<br>
> calc_u.AddScalarVariable = ['velocity', 'velocity', '0']<br>
> calc_u.Function = 'velocity'<br>
><br>
> # Use calculator to get the first component of velocity into the<br>
> # scalar array velocity_u<br>
> calc_v = servermanager.filters.Calculator(Input=calc_u)<br>
> calc_v.ResultArrayName ='velocity_v'<br>
> calc_v.AddScalarVariable = ['velocity', 'velocity', '1']<br>
> calc_v.Function = 'velocity'<br>
><br>
> # Use calculator to get the first component of velocity into the<br>
> # scalar array velocity_u<br>
> calc_w = servermanager.filters.Calculator(Input=calc_v)<br>
> calc_w.ResultArrayName ='velocity_w'<br>
> calc_w.AddScalarVariable = ['velocity', 'velocity', '2']<br>
> calc_w.Function = 'velocity'<br>
><br>
> # I NO LONGER NEED THE WHOLE VELOCITY FIELD I WOULD LIKE TO DELETE IT<br>
><br>
> #calculate gradiants du<br>
> grad_u= servermanager.filters.UnstructuredGradient(Input=calc_w)<br>
> grad_u.ResultArrayName = "du"<br>
> grad_u.SelectInputScalars = ["0","0","0","0","velocity_u"]<br>
> #calculate gradiants dv<br>
> grad_v= servermanager.filters.UnstructuredGradient(Input=grad_u)<br>
> grad_v.ResultArrayName = "dv"<br>
> grad_v.SelectInputScalars = ["0","0","0","0","velocity_v"]<br>
> #calculate gradiants dw<br>
> grad_w= servermanager.filters.UnstructuredGradient(Input=grad_v)<br>
> grad_w.ResultArrayName = "dw"<br>
> grad_w.SelectInputScalars = ["0","0","0","0","velocity_w"]<br>
><br>
> # I NO LONGER NEED THE WHOLE VELOCITY SCALAR FIELDS I WOULD LIKE TO DELETE<br>
> THEM<br>
><br>
> #calculate vorticity magnitude<br>
> calc_vort = servermanager.filters.Calculator(Input=grad_w)<br>
> calc_vort.ResultArrayName ='VortMag'<br>
> calc_vort.AddScalarVariable = \<br>
> ['dudx', 'du', '0','dudy', 'du', '1','dudz', 'du', '2',\<br>
> 'dvdx', 'dv', '0','dvdy', 'dv', '1','dvdz', 'dv', '2',\<br>
> 'dwdx', 'dw', '0','dwdy', 'dw', '1','dwdz', 'dw', '2', ]<br>
> calc_vort.Function = 'sqrt( (dwdy - dvdz)^2 + (dudz - dwdx)^2 + (dvdx -<br>
> dvd<br>
> y )^2 )'<br>
><br>
> # ALL DONE ! I WOULD LIKE TO DELETE EVERYTHING EXCEPT THE REQUIRED VORTICITY<br>
> MAGNITUDE SCALAR FIELD<br>
><br>
> writer =<br>
> servermanager.writers.XMLUnstructuredGridWriter(Input=calc_vort,\<br>
> FileName=out_file )<br>
> writer.UpdatePipeline()<br>
> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the ParaView Wiki at:<br>
> <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
</div></div></blockquote></div><br></div>