<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, "Berk Geveci" <<a href="berk.geveci@kitware.com">berk.geveci@kitware.com</a>> 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("pressure"))<BR>
ar2 = ar*2<BR>
newArray = nump7_support.numpy_to_vtk(ar2, True)<BR>
newArray.SetName("pressure times 2")<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 <<a href="tbrandvik@gmail.com">tbrandvik@gmail.com</a>> wrote:<BR>
> Thanks for the replies. I've got some experience with Python/NumPy so<BR>
> any pointers on that approach would be appreciated.<BR>
><BR>
> Tobias<BR>
><BR>
><BR>
> --<BR>
> Tobias Brandvik<BR>
> PhD Student<BR>
> Whittle Laboratory<BR>
> 1 JJ Thomson Avenue<BR>
> Cambridge CB3 0DY, UK<BR>
><BR>
> On Tue, Sep 9, 2008 at 2:51 PM, Berk Geveci <<a href="berk.geveci@kitware.com">berk.geveci@kitware.com</a>> wrote:<BR>
>> The array calculator does not use Python but it is slow nevertheless.<BR>
>> Actually, this could be done much faster using Python/NumPy. This is<BR>
>> currently possible but hard to do (complicated API). We are working on<BR>
>> an easier-to-use interface. If you are adventurous, I can give you<BR>
>> some pointers. Otherwise, C++ custom filter is the way to go.<BR>
>><BR>
>> -berk<BR>
>><BR>
>> On Tue, Sep 9, 2008 at 8:58 AM, Tobias Brandvik <<a href="tbrandvik@gmail.com">tbrandvik@gmail.com</a>> wrote:<BR>
>>> Hi,<BR>
>>><BR>
>>> I've written a CFD solver that uses Paraview in parallel mode with<BR>
>>> hdf5/xdmf. Currently, the application writes out the primary variables<BR>
>>> and lets the user calculate any desired secondary variables using the<BR>
>>> calculator. However, this procedure is very slow -- it seems to be an<BR>
>>> order of magnitude faster to calculate the data in the solver itself<BR>
>>> and have Paraview read it from disk. I suspect this is because the<BR>
>>> calculator expressions get translated to python code, but I might also<BR>
>>> be doing something wrong.<BR>
>>><BR>
>>> Am I correct in thinking that the easiest way to fix this would be to<BR>
>>> write a custom filter in C++?<BR>
>>><BR>
>>> Cheers,<BR>
>>> Tobias<BR>
>>><BR>
>>> --<BR>
>>> Tobias Brandvik<BR>
>>> PhD Student<BR>
>>> Whittle Laboratory<BR>
>>> 1 JJ Thomson Avenue<BR>
>>> Cambridge CB3 0DY, UK<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>
><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>