CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

LES UPrime2Mean from previously calculated UMean

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 13, 2023, 14:50
Default LES UPrime2Mean from previously calculated UMean
  #1
New Member
 
mjavrincon's Avatar
 
Mario Javier Rincón
Join Date: Dec 2020
Location: Denmark
Posts: 9
Rep Power: 5
mjavrincon is on a distinguished road
Dear community,

I have been trying to calculate the turbulence kinetic energy (TKE) of large eddy simulations (LES) for a while.
I have found that using the fieldAverage utility in OpenFOAM (the standard approach as I have seen) there is a big problem in the calculation of UPrime2Mean. Let me explain by having this code in controlDict:

Code:
functions
{
    fieldAverage
    {
        type            fieldAverage;
        libs            ("libfieldFunctionObjects.so");
        writeControl    writeTime;

        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }
        );
    }
}
The problem is that using directly this approach and starting the simulation, the UMean value used to calculate UPrime2Mean is not converged, thus yielding incorrect data unless a huge simulation is run to compensate for the iterations collected in which UMean is not converged.

As a solution, I have been trying to run first only UMean averaging, and when this field is converged, start the UPrime2Mean calculation, hoping that the convergence of the 2nd order statistics does not take that long.

However, I have not succeeded at doing so since the calculation of UPrime2Mean takes into account the number of time steps already used to calculate UMean and the UPrime2Mean field barely changes from the results obtained in the first iteration.

Have someone managed to fix or use a previous UMean field and use it to calculate UPrime2Mean?

Thank you in advance!

P.S. I have attached a figure of velocity probes in function of simulation time with the instantaneous values and 1st order statistics to show what I mean.
Attached Images
File Type: jpg probesConvergenceU.jpg (150.9 KB, 22 views)
mjavrincon is offline   Reply With Quote

Old   September 5, 2024, 21:00
Default
  #2
New Member
 
Tian-xiong Zhao
Join Date: Nov 2019
Posts: 2
Rep Power: 0
Lanius is on a distinguished road
Hi Mario, I have noticed the same issue. Have you figured out a solution?
I'm thinking using the umean from the last timestep and u from every timestep to calculate the uprime2mean manually, but it will only consider "written" timestep instead of "run" timestep, so I'm not sure if that's a good idea.

Edit: I have done some more tests and found that I was wrong.
The prime2mean value is calculated by the instantaneous value of every timestep, and mean value of the "LAST" step, instead of directly using the prime2mean value from previous timesteps which are based on "PREVIOUS" mean value.

Last edited by Lanius; September 6, 2024 at 15:45.
Lanius is offline   Reply With Quote

Old   September 6, 2024, 12:16
Default
  #3
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 737
Rep Power: 14
Tobermory will become famous soon enough
Quote:
Originally Posted by mjavrincon View Post
The problem is that using directly this approach and starting the simulation, the UMean value used to calculate UPrime2Mean is not converged, thus yielding incorrect data unless a huge simulation is run to compensate for the iterations collected in which UMean is not converged.
You haven't understood the functionObject - it's actually rather clever and extremely efficient in storage (harks back to the days when supercomputer memory was expensive, and very limiting on your DNS/LES simulations, so you had to work hared not to waste it). In a nutshell, the averages (mean and variance) BOTH get better, the longer you average for and the variance is constantly using the latest value of the mean field.

Don't believe me? Here's the derivation. Start with the mean field, and write the mean based on n samples as:

(\overline{\Phi})_n = \frac{1}{n} \sum_{m=1}^n \Phi_m
= \frac{1}{n} [\sum_{m=1}^{n-1} \Phi_m + \Phi_n]
= \frac{n-1}{n} (\overline{\Phi})_{n-1} + \frac{1}{n} \Phi_n

Now substitute \beta = 1/n and you have a compact way of computing the mean based on just the current sample value and the previous value of the mean (i.e. you don't have to store all the previous sample values).

Now buckle up, and let's do the variance. Start with the definition of the perturbation \Phi = \overline{\Phi} + \Phi' from which it is easy to show that \overline{\Phi'^2} = \overline{\Phi^2} - \overline{\Phi}^2. Then:

(\overline{\Phi'^2})_n
 = \frac{1}{n} \sum_{m=1}^n \Phi_m^2 -  (\overline{\Phi})_n^2
 = \frac{1}{n} \sum_{m=1}^{n-1} \Phi_m^2 +\frac{1}{n} \Phi_n^2
-  (\overline{\Phi})_n^2

Now substitute for the summation term using the earlier identity to get:
(\overline{\Phi'^2})_n = \frac{n-1}{n} \{(\overline{\Phi'^2})_{n-1} +  (\overline{\Phi})_{n-1}^2 \}
 +\frac{1}{n} \Phi_n^2 -  (\overline{\Phi})_n^2

and once again you have a method for calculating the latest, best estimate of the variance using the previous value of the variance and the current sample value. The keen-eyed amongst you will have spotted though that the above requires both the previous and current values of the mean. To save having to store another field (the old mean), the functionObject does some fancy footwork - it calls function addMeanSqrToPrime2Mean() that adds the old mean square to the old prime2 field before updating the mean and then updating the prime2 fields. A masterwork of coding.

So the long and short of it is that you just have to keep on sampling, and both the mean and the variance fields will improve.
Tobermory is offline   Reply With Quote

Reply

Tags
fieldaverage, les, statistics, tke, uprime2mean


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
wallHeatFlux utility for an incompressible case Mr.Jingles OpenFOAM Post-Processing 67 April 6, 2023 04:25
dsmcFoam setup hherbol OpenFOAM Pre-Processing 1 November 19, 2021 02:52
The Umean of a flow around a cube calculated in Openfoam looks like instantaneous jiaodanuma OpenFOAM Verification & Validation 4 June 14, 2016 18:16
LiftDrag coefficient in LES fabian_korn OpenFOAM Post-Processing 1 September 22, 2008 03:34
Some Questions about LES. Bin Li Main CFD Forum 2 February 20, 2004 10:58


All times are GMT -4. The time now is 23:35.