Time averaged values

Hello forum,

I am trying to get the mean values of an unsteady flow. So far I tried the following code:

for (i=1; i<=iterations; i++)
{
t +=dt; // update the time step
up[ ]=u[ ]; // Problem variables
PROBLEM; //Call to solve the problem equation
sumu[ ] += u[ ];
}
umean[ ] = sumu[ ]/iterations;

The problem is that “sumu[ ] += u[ ]” doesn’t seem to work as I expected. For example if at iteration “n”, the maximum velocity is 1 m/s and at iteration “n+1”, the maximum velocity is 2 m/s, I get a maximum velocity of 5 m/s.

I attached the equation of the time integral which I want to apply now in this case in order to get the mean/time-averaged values. Unfortunately I didn’t manage to implement it.
image

Could you, please, help me to get the mean values?

Regards,
Robert

That should work, do you do some kind of mesh adaptation?

Hello prj, and thank you for the fast answer. No, I don’t adapt the mesh.