Jean Hertzberg | 16 Aug 2012 01:10
Picon
Favicon

Integrate a scalar over a volume

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.

Thanks

-Jean

 

<div><div class="WordSection1">
<p class="MsoNormal">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.<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">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.<p></p></p>
<p class="MsoNormal">Thanks<p></p></p>
<p class="MsoNormal">-Jean <p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
</div></div>
Hal Canary | 16 Aug 2012 20:27
Picon
Favicon
Gravatar

Re: Integrate a scalar over a volume

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

Gmane