[Paraview] Need help with programmable filter output

Berk Geveci berk.geveci at kitware.com
Fri Nov 30 11:18:51 EST 2012


Output should be vtkTable. By the way, if you have numpy installed, this
could be done much more efficiently and in less code. See

http://paraview.org/Wiki/ParaView/Users_Guide/Python_Programmable_Filter
http://paraview.org/Wiki/ParaView/Users_Guide/Python_Calculator

You may also want to check the numpy documentation.

In general, if your data is medium to large, you want to avoid for loops
over all cells/points in Python.

Best,
-berk


On Thu, Nov 29, 2012 at 11:35 PM, Scott Ripplinger <bigbluedart at gmail.com>wrote:

> I am attempting to run an analysis on some data which requires summing up
> some numbers down to a single value for the whole domain for each time
> step.  I'm having trouble figuring out how to get the output and what VTK
> classes and functions to use.  Here is what I have so far:
>
> import math
>
> input = self.GetInputDataObject(0,0)
>
> output = self.GetOutputDataObject(0)
>
> numPoints = input.GetNumberOfPoints()
>
> points = input.GetPointData()
>
> SurfCvg = 0
>
> for i in xrange(numPoints):
>
>  d = points.GetArray('d').GetValue(i)
>
>  coords = input.GetPoint(i)
>
>  z = coords[2]
>
>  h = 0.00015 - abs(z - 0.00015) - 0.5*d
>
>  H0 = 2*h/d
>
>  if (H0 < 0.002):
>
>   SurfCvg = SurfCvg + 0.25*math.pi*d*d
>
> Theta = SurfCvg/(0.01*0.001)
>
> outputarray = vtk.vtkFloatArray()
>
> outputarray.SetNumberOfValues(1)
>
> outputarray.SetValue(0, Theta)
>
> output.GetRowData().AddArray(outputarray)
>
>
> I'm not even sure what to use as the output data set type.  In the end I
> need to plot (or export as a table) the value of "Theta" across all my time
> steps.  Any guidance would be appreciated.
>
>
> -Scott
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20121130/5135d3ea/attachment-0001.htm>


More information about the ParaView mailing list