[Paraview] Calculator speed

Weirs, V Gregory vgweirs at sandia.gov
Thu Sep 11 13:18:06 EDT 2008


Dig it.

Is numpy_support documented anywhere?

Thanks,
Greg


On 9/11/08 10:31 AM, "Berk Geveci" <berk.geveci at kitware.com> wrote:

(assuming you are using cvs paraview)
In the programmable filter, you can do something like:

from paraview import numpy_support

input = self.GetInputDataObject(0, 0)
ar = numpy_support.vtk_to_numpy(input.GetPointData().GetArray("pressure"))
ar2 = ar*2
newArray = nump7_support.numpy_to_vtk(ar2, True)
newArray.SetName("pressure times 2")
output = self.GetOutputDataObject(0)
output.GetPointData().AddArray(newArray)

In the future, this should look like:
output.point_data['pressure times 2'] = input.point_data['pressure'] * 2

-berk


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20080911/78d191f5/attachment-0001.htm>


More information about the ParaView mailing list