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">&lt;<a href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>&gt;</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(&quot;pressure&quot;))<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 &lt;<a href="mailto:dan@cora.nwra.com">dan@cora.nwra.com</a>&gt; wrote:<br>
&gt;<br>
&gt;  Can anyone give me a hint on how to delete an array from an unstructured<br>
&gt; mesh<br>
&gt; in a python script. I need to do this to save memory when going through<br>
&gt; multiple<br>
&gt; steps processing data.<br>
&gt; Below is an example python script and where I would like to delete unused<br>
&gt; arrays to save memory.<br>
&gt; Thanks for any help or ideas.. Dan<br>
&gt;<br>
&gt;<br>
&gt;    reader =  \<br>
&gt;<br>
&gt; servermanager.sources.XMLUnstructuredGridReader(FileName=in_dir+&quot;/&quot;+in_file)<br>
&gt;<br>
&gt; # Use calculator to get the first component of velocity into the<br>
&gt;    # scalar array velocity_u<br>
&gt;    calc_u = servermanager.filters.Calculator(Input=reader)<br>
&gt;    calc_u.ResultArrayName =&#39;velocity_u&#39;<br>
&gt;    calc_u.AddScalarVariable = [&#39;velocity&#39;, &#39;velocity&#39;, &#39;0&#39;]<br>
&gt;    calc_u.Function = &#39;velocity&#39;<br>
&gt;<br>
&gt; # Use calculator to get the first component of velocity into the<br>
&gt;    # scalar array velocity_u<br>
&gt;    calc_v = servermanager.filters.Calculator(Input=calc_u)<br>
&gt;    calc_v.ResultArrayName =&#39;velocity_v&#39;<br>
&gt;    calc_v.AddScalarVariable = [&#39;velocity&#39;, &#39;velocity&#39;, &#39;1&#39;]<br>
&gt;    calc_v.Function = &#39;velocity&#39;<br>
&gt;<br>
&gt; # Use calculator to get the first component of velocity into the<br>
&gt;    # scalar array velocity_u<br>
&gt;    calc_w = servermanager.filters.Calculator(Input=calc_v)<br>
&gt;    calc_w.ResultArrayName =&#39;velocity_w&#39;<br>
&gt;    calc_w.AddScalarVariable = [&#39;velocity&#39;, &#39;velocity&#39;, &#39;2&#39;]<br>
&gt;    calc_w.Function = &#39;velocity&#39;<br>
&gt;<br>
&gt; # I NO LONGER NEED THE WHOLE VELOCITY FIELD I WOULD LIKE TO DELETE IT<br>
&gt;<br>
&gt; #calculate gradiants du<br>
&gt;    grad_u= servermanager.filters.UnstructuredGradient(Input=calc_w)<br>
&gt;    grad_u.ResultArrayName = &quot;du&quot;<br>
&gt;    grad_u.SelectInputScalars = [&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;velocity_u&quot;]<br>
&gt; #calculate gradiants dv<br>
&gt;    grad_v= servermanager.filters.UnstructuredGradient(Input=grad_u)<br>
&gt;    grad_v.ResultArrayName = &quot;dv&quot;<br>
&gt;    grad_v.SelectInputScalars = [&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;velocity_v&quot;]<br>
&gt; #calculate gradiants dw<br>
&gt;    grad_w= servermanager.filters.UnstructuredGradient(Input=grad_v)<br>
&gt;    grad_w.ResultArrayName = &quot;dw&quot;<br>
&gt;    grad_w.SelectInputScalars = [&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;0&quot;,&quot;velocity_w&quot;]<br>
&gt;<br>
&gt; # I NO LONGER NEED THE WHOLE VELOCITY SCALAR FIELDS I WOULD LIKE TO DELETE<br>
&gt; THEM<br>
&gt;<br>
&gt; #calculate vorticity magnitude<br>
&gt;    calc_vort = servermanager.filters.Calculator(Input=grad_w)<br>
&gt;    calc_vort.ResultArrayName =&#39;VortMag&#39;<br>
&gt;    calc_vort.AddScalarVariable = \<br>
&gt;       [&#39;dudx&#39;, &#39;du&#39;, &#39;0&#39;,&#39;dudy&#39;, &#39;du&#39;, &#39;1&#39;,&#39;dudz&#39;, &#39;du&#39;, &#39;2&#39;,\<br>
&gt;        &#39;dvdx&#39;, &#39;dv&#39;, &#39;0&#39;,&#39;dvdy&#39;, &#39;dv&#39;, &#39;1&#39;,&#39;dvdz&#39;, &#39;dv&#39;, &#39;2&#39;,\<br>
&gt;        &#39;dwdx&#39;, &#39;dw&#39;, &#39;0&#39;,&#39;dwdy&#39;, &#39;dw&#39;, &#39;1&#39;,&#39;dwdz&#39;, &#39;dw&#39;, &#39;2&#39;, ]<br>
&gt;    calc_vort.Function = &#39;sqrt( (dwdy - dvdz)^2  + (dudz - dwdx)^2 + (dvdx -<br>
&gt; dvd<br>
&gt; y )^2 )&#39;<br>
&gt;<br>
&gt; # ALL DONE ! I WOULD LIKE TO DELETE EVERYTHING EXCEPT THE REQUIRED VORTICITY<br>
&gt; MAGNITUDE SCALAR FIELD<br>
&gt;<br>
&gt;    writer =<br>
&gt; servermanager.writers.XMLUnstructuredGridWriter(Input=calc_vort,\<br>
&gt;             FileName=out_file )<br>
&gt;    writer.UpdatePipeline()<br>
&gt; _______________________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the ParaView Wiki at:<br>
&gt; <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
&gt;<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>