Okay, I've done a little more work on this and the following is what I have so far:
import math r = inputs[0].PointData['d']/2 SurfArea = math.pi*r*r z = inputs[0].Points[:,2] h = 0.00015 - abs(z - 0.00015) - r H0 = h/r numPoints = inputs[0].GetNumberOfPoints() SurfCvg = 0 for i in range(numPoints): if H0[i] < 0.002: SurfCvg = SurfCvg + SurfArea[i] Theta = SurfCvg/(0.010*0.001*2) output.RowData.append(Theta, 'Theta') The output is set to vtkTable. When I try running this, though, I get the following error message repeated three times: ERROR: In ..\..\..\..\src\VTK\Filtering\vtkDemandDrivenPipeline.cxx, line 827 vtkPVDataRepresentationPipeline (000000001444A130): Input for connection index 0 on input port index 0 for algorithm vtkGeometryRepresentation(000000001279BFE0) is of type vtkTable, but a vtkDataSet is required. Do I need to manually define my SurfCvg and SurfArea variables as vtkTable types? I'm just a bit lost at this point, but feeling closer. -Scott On Fri, Nov 30, 2012 at 10:18 AM, Berk Geveci <berk.gev...@kitware.com>wrote: > 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 > <bigblued...@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 >> >> >
_______________________________________________ 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