[Paraview] Sum values of scalar vector

Scott Ripplinger bigbluedart at gmail.com
Thu Nov 29 08:09:12 EST 2012


Christian,

Thanks for getting me started.  And sorry it took me so long to respond.
 I've been moving pretty slow on this project.

Anyway, I've done the following with my script:

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[3]

 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.vtkStringArray()

outputarray.SetName("Surface Coverage")

outputarray.SetNumberOfTuples(1)

outputarray.SetValue(0, "%d" % (Theta))

output.GetRowData().AddArray(outputarray)


First of all, am I getting the z coordinate correctly?  I haven't been able
to find an answer to that in my searching.  Secondly, my end goal is to
plot the value of Theta over time for my dataset.  Do I have the output
stuff done right, and where do I go from there?


Thanks in advance.


-Scott


On Sat, Nov 3, 2012 at 3:53 AM, Christian Richter <christian.richter at ovgu.de
> wrote:

>  Hi,
>
> in a programmable Filter do something like this:
>
>  import math
>  input = self.GetInputDataObject(0, 0)
>  output = self.GetOutputDataObject(0)
>  COUNT=input.GetNumberOfPoints()
>  pd=input.GetPointData()
>  m=0
>  v=0
>  for i in xrange(COUNT):
>   r=pd.GetArray('radius').GetValue(i)
>   v=v+((4.0/3.0)*math.pi*r*r*r)
>   m=m+pd.GetArray('Mass').GetValue(i)
>  outputarray = vtk.vtkStringArray()
>  outputarray.SetName("Text")
>  outputarray.SetNumberOfTuples(1)
>  outputarray.SetValue(0,"N=%d\nV=%1.6f m³\nm=%1.6f kg" % (COUNT,v,m))
>  output.GetRowData().AddArray(outputarray)
>
> Attention: if you save this to a state-file change the ³ to 3 because it
> will not be escaped and you can not load the state anymore.
>
> best wishes,
> Christian
>
> Am 02.11.2012 21:49, schrieb Scott Ripplinger:
>
> I need to sum all the values in a vector of a scalar property.  I've
> struggled understanding the documentation for the python calculator and
> programmable filter, mainly in how to access the point data that I want to
> use.  Any tips will be appreciated.
>
> _______________________________________________
> 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
>
>
>
> _______________________________________________
> 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/20121129/310efd3b/attachment.htm>


More information about the ParaView mailing list