<HTML>
<HEAD>
<TITLE>Re: [Paraview] Calculator speed</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
Dig it.<BR>
<BR>
Is numpy_support documented anywhere?<BR>
<BR>
Thanks,<BR>
Greg<BR>
<BR>
<BR>
On 9/11/08 10:31 AM, &quot;Berk Geveci&quot; &lt;<a href="berk.geveci@kitware.com">berk.geveci@kitware.com</a>&gt; wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>(assuming you are using cvs paraview)<BR>
In the programmable filter, you can do something like:<BR>
<BR>
from paraview import numpy_support<BR>
<BR>
input = self.GetInputDataObject(0, 0)<BR>
ar = numpy_support.vtk_to_numpy(input.GetPointData().GetArray(&quot;pressure&quot;))<BR>
ar2 = ar*2<BR>
newArray = nump7_support.numpy_to_vtk(ar2, True)<BR>
newArray.SetName(&quot;pressure times 2&quot;)<BR>
output = self.GetOutputDataObject(0)<BR>
output.GetPointData().AddArray(newArray)<BR>
<BR>
In the future, this should look like:<BR>
output.point_data['pressure times 2'] = input.point_data['pressure'] * 2<BR>
<BR>
-berk<BR>
<BR>
<BR>
On Tue, Sep 9, 2008 at 2:40 PM, Tobias Brandvik &lt;<a href="tbrandvik@gmail.com">tbrandvik@gmail.com</a>&gt; wrote:<BR>
&gt; Thanks for the replies. I've got some experience with Python/NumPy so<BR>
&gt; any pointers on that approach would be appreciated.<BR>
&gt;<BR>
&gt; Tobias<BR>
&gt;<BR>
&gt;<BR>
&gt; --<BR>
&gt; Tobias Brandvik<BR>
&gt; PhD Student<BR>
&gt; Whittle Laboratory<BR>
&gt; 1 JJ Thomson Avenue<BR>
&gt; Cambridge CB3 0DY, UK<BR>
&gt;<BR>
&gt; On Tue, Sep 9, 2008 at 2:51 PM, Berk Geveci &lt;<a href="berk.geveci@kitware.com">berk.geveci@kitware.com</a>&gt; wrote:<BR>
&gt;&gt; The array calculator does not use Python but it is slow nevertheless.<BR>
&gt;&gt; Actually, this could be done much faster using Python/NumPy. This is<BR>
&gt;&gt; currently possible but hard to do (complicated API). We are working on<BR>
&gt;&gt; an easier-to-use interface. &nbsp;If you are adventurous, I can give you<BR>
&gt;&gt; some pointers. Otherwise, C++ custom filter is the way to go.<BR>
&gt;&gt;<BR>
&gt;&gt; -berk<BR>
&gt;&gt;<BR>
&gt;&gt; On Tue, Sep 9, 2008 at 8:58 AM, Tobias Brandvik &lt;<a href="tbrandvik@gmail.com">tbrandvik@gmail.com</a>&gt; wrote:<BR>
&gt;&gt;&gt; Hi,<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt; I've written a CFD solver that uses Paraview in parallel mode with<BR>
&gt;&gt;&gt; hdf5/xdmf. Currently, the application writes out the primary variables<BR>
&gt;&gt;&gt; and lets the user calculate any desired secondary variables using the<BR>
&gt;&gt;&gt; calculator. However, this procedure is very slow -- it seems to be an<BR>
&gt;&gt;&gt; order of magnitude faster to calculate the data in the solver itself<BR>
&gt;&gt;&gt; and have Paraview read it from disk. I suspect this is because the<BR>
&gt;&gt;&gt; calculator expressions get translated to python code, but I might also<BR>
&gt;&gt;&gt; be doing something wrong.<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt; Am I correct in thinking that the easiest way to fix this would be to<BR>
&gt;&gt;&gt; write a custom filter in C++?<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt; Cheers,<BR>
&gt;&gt;&gt; Tobias<BR>
&gt;&gt;&gt;<BR>
&gt;&gt;&gt; --<BR>
&gt;&gt;&gt; Tobias Brandvik<BR>
&gt;&gt;&gt; PhD Student<BR>
&gt;&gt;&gt; Whittle Laboratory<BR>
&gt;&gt;&gt; 1 JJ Thomson Avenue<BR>
&gt;&gt;&gt; Cambridge CB3 0DY, UK<BR>
&gt;&gt;&gt; _______________________________________________<BR>
&gt;&gt;&gt; ParaView mailing list<BR>
&gt;&gt;&gt; <a href="ParaView@paraview.org">ParaView@paraview.org</a><BR>
&gt;&gt;&gt; <a href="http://www.paraview.org/mailman/listinfo/paraview">http://www.paraview.org/mailman/listinfo/paraview</a><BR>
&gt;&gt;&gt;<BR>
&gt;&gt;<BR>
&gt;<BR>
_______________________________________________<BR>
ParaView mailing list<BR>
<a href="ParaView@paraview.org">ParaView@paraview.org</a><BR>
<a href="http://www.paraview.org/mailman/listinfo/paraview">http://www.paraview.org/mailman/listinfo/paraview</a><BR>
<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE>
</BODY>
</HTML>