1
$\begingroup$

I have two sets of 300 VTK files and I want to get a graph comparing the average difference of the two sets. All files have a structured grid containing a scalar value named phi. At the end, I need a graph showing the average difference of each grid for every grid.

I have computed the difference at each cell using a Programmable Filter with the following code, from a previous question(here):

phi0 = inputs[0].PointData['phi']
phi1 = inputs[1].PointData['phi']
output.PointData.append(phi1-phi0, 'difference')

However, I do not understand how can I compute the average value of the whole grid(sum all differences and divide by the number of cells) and then plot that for every grid I have.

Any suggestions?

$\endgroup$
1
$\begingroup$

The answer to your question is that you can change your Programmable Filter output type to a vtkPolyData and set the Script to:

phi0 = inputs[0].PointData['phi']
phi1 = inputs[1].PointData['phi']
dd = abs(phi1-phi0) #note absolute value here
ss = sum(dd)

points = vtk.vtkPoints()
points.InsertPoint(0, [0, 0, 0])
output.SetPoints(points)
globalsum = vtk.vtkDoubleArray()
globalsum.SetName("sum")
globalsum.InsertValue(0, ss/inputs[0].GetNumberOfPoints())
output.GetPointData().AddArray(globalsum)

This probably won't work in parallel though.

You may want to consider a mesh size independent option though. For this first use one of the calculator filters to create a point data array with value of 1 everywhere and then use the Integrate Variables filter in ParaView to integrate the difference and "1" array result over the entire data set of difference. Then divide the difference result by the 1 array result to get a mesh size independent value.

$\endgroup$
  • $\begingroup$ Your answer put me one step forward from where I was. I used the programmable filter with the script you provided me, and then I used a PlotSelectionOVerTime filter to get the graph I was looking for. Thanks $\endgroup$ – IPA Dec 4 '14 at 5:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.