CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   Computation of kinetic energy of the flow (

feldy77 November 9, 2011 21:15

Computation of kinetic energy of the flow
Hi foamers,
I am really puzzled about how tocompute the overall kinetic energy of the flow, i mean I(1/2*U^2)dV, where I is an integral over the given volume.
I understand that I have to sum over all subvolumes but I do not even know how to start . Please help me

nimasam November 10, 2011 08:16

volScalarField ke=0.5*(U&U);
dimensionedScalar ketotal = sum(ke*mesh.V());

feldy77 November 10, 2011 16:15

Dear nimasam,
Thank you very much for your answer it was very useful.
Just a small comment,
It is better just to compute the Ek just by

dimensionedScalar ketotal = sum(0.5*(U&U)*mesh.V());

In this way you do not need to construct an additional volScalar field
which can save alot of memory

feldy77 November 10, 2011 16:43

Thinking about the issue once agin, the last change does not reduce the
memory consumption since U&U opration still consumpts the same amount of memory as if volScalarfield is defined explicitly. I would recommend another way , which is longer but allows you to save the memory:

forAll (mesh.C().internalField(), patchI)

Ekin_= Ekin_+0.5*
This is of course right for non-slip boundary conditions.

All times are GMT -4. The time now is 13:41.