Okay, I've done a little more work on this and the following is what I have so far:<div><br></div><div><p style="margin:0px"><font size="1">import math</font></p><p style="margin:0px"><font size="1"><br></font></p>
<p style="margin:0px"></p>
<p style="margin:0px"><font size="1">r = inputs[0].PointData['d']/2</font></p>
<p style="margin:0px"><font size="1">SurfArea = math.pi*r*r</font></p><p style="margin:0px"><font size="1"><br></font></p>
<p style="margin:0px"></p>
<p style="margin:0px"><font size="1">z = inputs[0].Points[:,2]</font></p>
<p style="margin:0px"><font size="1">h = 0.00015 - abs(z - 0.00015) - r</font></p>
<p style="margin:0px"><font size="1">H0 = h/r</font></p><p style="margin:0px"><font size="1"><br></font></p>
<p style="margin:0px"></p>
<p style="margin:0px"><font size="1">numPoints = inputs[0].GetNumberOfPoints()</font></p>
<p style="margin:0px"><font size="1">SurfCvg = 0</font></p>
<p style="margin:0px"><font size="1">for i in range(numPoints):</font></p>
<p style="margin:0px"><font size="1"> if H0[i] < 0.002:</font></p>
<p style="margin:0px"><font size="1"> SurfCvg = SurfCvg + SurfArea[i]</font></p><p style="margin:0px"><font size="1"><br></font></p>
<p style="margin:0px"></p>
<p style="margin:0px"><font size="1">Theta = SurfCvg/(0.010*0.001*2)</font></p><p style="margin:0px"><font size="1"><br></font></p>
<p style="margin:0px"></p>
<p style="margin:0px"><font size="1">output.RowData.append(Theta, 'Theta')</font></p><p style="margin:0px"><font size="1"><br></font></p><p style="margin:0px">The output is set to vtkTable. When I try running this, though, I get the following error message repeated three times:</p>
<p style="margin:0px"><br></p><p style="margin:0px"></p><p style="margin:0px"><span style="font-family:Courier;font-size:8.25pt;color:rgb(128,0,0)">ERROR: In ..\..\..\..\src\VTK\Filtering\vtkDemandDrivenPipeline.cxx, line 827</span></p>
<p style="margin:0px"><span style="font-family:Courier;font-size:8.25pt;color:rgb(128,0,0)">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.</span></p>
<p style="margin:0px"><span style="font-family:Courier;font-size:8.25pt;color:rgb(128,0,0)"><br></span></p><p style="margin:0px"><font color="#000000" face="arial, helvetica, sans-serif">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.</font></p>
<p style="margin:0px"><font color="#000000" face="arial, helvetica, sans-serif"><br></font></p><p style="margin:0px"><font color="#000000" face="arial, helvetica, sans-serif">-Scott</font></p><p></p><p style="margin:0px">
<font size="1"><br></font></p></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 30, 2012 at 10:18 AM, Berk Geveci <span dir="ltr"><<a href="mailto:berk.geveci@kitware.com" target="_blank">berk.geveci@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Output should be vtkTable. By the way, if you have numpy installed, this could be done much more efficiently and in less code. See<div>
<br></div><div><a href="http://paraview.org/Wiki/ParaView/Users_Guide/Python_Programmable_Filter" target="_blank">http://paraview.org/Wiki/ParaView/Users_Guide/Python_Programmable_Filter</a><br>
</div><div><a href="http://paraview.org/Wiki/ParaView/Users_Guide/Python_Calculator" target="_blank">http://paraview.org/Wiki/ParaView/Users_Guide/Python_Calculator</a><br></div><div><br></div><div>You may also want to check the numpy documentation.</div>
<div><br></div><div>In general, if your data is medium to large, you want to avoid for loops over all cells/points in Python.</div><div><br></div><div>Best,</div><div>-berk</div><div class="gmail_extra"><br><br><div class="gmail_quote">
<div><div class="h5">
On Thu, Nov 29, 2012 at 11:35 PM, Scott Ripplinger <span dir="ltr"><<a href="mailto:bigbluedart@gmail.com" target="_blank">bigbluedart@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
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:<div>
<br></div><div><p style="margin:0px"><font size="1">import math</font></p>
<p style="margin:0px"><font size="1">input = self.GetInputDataObject(0,0)</font></p>
<p style="margin:0px"><font size="1">output = self.GetOutputDataObject(0)</font></p>
<p style="margin:0px"><font size="1">numPoints = input.GetNumberOfPoints()</font></p>
<p style="margin:0px"><font size="1">points = input.GetPointData()</font></p>
<p style="margin:0px"></p>
<p style="margin:0px"><font size="1">SurfCvg = 0</font></p>
<p style="margin:0px"><font size="1">for i in xrange(numPoints):</font></p>
<p style="margin:0px"><font size="1"> d = points.GetArray('d').GetValue(i)</font></p>
<p style="margin:0px"><font size="1"> coords = input.GetPoint(i)</font></p>
<p style="margin:0px"><font size="1"> z = coords[2]</font></p>
<p style="margin:0px"><font size="1"> h = 0.00015 - abs(z - 0.00015) - 0.5*d</font></p><p style="margin:0px"><span style="font-size:x-small"> H0 = 2*h/d</span><br></p>
<p style="margin:0px"><font size="1"> if (H0 < 0.002):</font></p>
<p style="margin:0px"><font size="1"> SurfCvg = SurfCvg + 0.25*math.pi*d*d</font></p>
<p style="margin:0px"></p>
<p style="margin:0px"><font size="1">Theta = SurfCvg/(0.01*0.001)</font></p>
<p style="margin:0px"></p>
<p style="margin:0px"><font size="1">outputarray = vtk.vtkFloatArray()</font></p>
<p style="margin:0px"><font size="1">outputarray.SetNumberOfValues(1)</font></p>
<p style="margin:0px"><font size="1">outputarray.SetValue(0, Theta)</font></p>
<p style="margin:0px"><font size="1">output.GetRowData().AddArray(outputarray)</font></p><p style="margin:0px"><font size="1"><br></font></p><p style="margin:0px">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.</p>
<span><font color="#888888">
<p style="margin:0px"><br></p><p style="margin:0px">-Scott</p></font></span></div>
<br></div></div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>