[Paraview] Integrate a scalar over a volume

Hal Canary hal at cs.unc.edu
Thu Aug 16 14:27:47 EDT 2012


On 08/15/2012 07:10 PM, Jean Hertzberg wrote:
> I am trying to integrate a scalar over a 3D volume. I was surprised to
> find that the Integrate Variables filter does not do this; when
> integrating a scalar variable of 1 over a cube of size 1 X 1 X 1,
> Integrate Variables returns the value of 6. The documentation says it
> will integrate over lines and surfaces only. Suggestions please.
>
> Additional context: I am working with velocity field data, read in via
> the Ensight format. I have calculated vorticity, and vorticity
> magnitude, and I want the integral of the vorticity magnitude in a
> volume defined by an extracted subset.


If your data is a Uniform Rectilinear Grid (vtkImageData), then the 
volume integral is approximated by the sum of the scalar field 
multiplied by the spacing.  You could put the following into a 
Programmable Filter:

	scalar_array = numpy.array(inputs[0].PointData['RTData'])
	space = inputs[0].GetSpacing()
	print scalar_array.sum() * space[0] * space[1] * space[2]

(I tested it out on an extracted subset of a wavelet.)


More information about the ParaView mailing list