CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Computation of kinetic energy of the flow (https://www.cfd-online.com/Forums/openfoam/94233-computation-kinetic-energy-flow.html)

feldy77 November 9, 2011 20: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 07:16

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

feldy77 November 10, 2011 15: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
Yuri

feldy77 November 10, 2011 15: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*
(sqr(U.internalField()[patchI].component(vector::X))+
sqr(U.internalField()[patchI].component(vector::Y))+
sqr(U.internalField()[patchI].component(vector::Z)))
*mesh.V()[patchI];
}
This is of course right for non-slip boundary conditions.
Yuri


All times are GMT -4. The time now is 18:32.