CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Mathematical meaning of window averaging in fieldAverage functionObject

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 15, 2020, 12:47
Default Mathematical meaning of window averaging in fieldAverage functionObject
  #1
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 736
Rep Power: 14
Tobermory will become famous soon enough
I have been taking a look at the fieldAverage functionObject, for time averaging fields during a simulation. The basic implementation is cunningly coded to use the minimum amount of storage, by calculating the mean and variance at the new time step using the latest data and the mean from the old time step. You can show through some simple algebra that this provides an exact estimation of the mean and variance, based on the complete sample set.

Now, my question is, what do you get when you use the "window" function?

In an ideal world, for a window size of w samples, it would be the average over the last w samples, but this is clearly impossible to calculate without storing w samples, since you can't simply discard the (n-w)'th sample. But does the window function give something that approximates this? Let's take a look.

The algorithm for the mean value of n samples (see fieldAverageTemplates.C) is: \overline{U}_n = (1-\beta)\overline{U}_{n-1} + \beta U_n, where \beta = \delta t/T=1/n (assuming no windowing and equal spaced samples) and \overline{U}_{n-1} is the average of the first n-1 samples. Expanding out \overline{U}_{n-1}, you can show that this reduces to \overline{U}_n = (1/n) \sum_{i=1}^n{U_i}, as desired.

Now, if windowing is active with a window size of w, then when the number of samples exceeds the window size the following limit is applied: \beta = \delta t/w = 1/m, where m is now a constant. Let's take an example with a window size of 2 samples (m=2 here):

\overline{U}_1 =U_1
\overline{U}_2 =\frac{1}{2}(U_1 + U_2)
\overline{U}_3 =\frac{1}{4}(U_1 + U_2) + \frac{1}{2}U_3
\overline{U}_4 =\frac{1}{8}(U_1 + U_2) + \frac{1}{4}U_3  + \frac{1}{2}U_4
\overline{U}_5 =\frac{1}{16}(U_1 + U_2) + \frac{1}{8}U_3  + \frac{1}{4}U_4  + \frac{1}{2}U_5

etc. - you can see the pattern. My question is - what the heck is this quantity? It clearly slowly diminuishes the effect of the earlier samples, but the average is slightly biased to the most recent samples (that's exaggerated in the above example; for larger values of m, then 1 -\beta \approx 1 and the biasing is less strong). It's certainly not a balanced average of the recent w samples.

So what is the physical meaning of the windowed average, and when might you want to use it?
Tobermory is offline   Reply With Quote

Old   December 31, 2022, 05:38
Default
  #2
New Member
 
navid toussi
Join Date: Nov 2015
Posts: 20
Rep Power: 10
navidmt is on a distinguished road
Very good thread! Have you got the answer? If so, would you mind sharing it here? Thanks
navidmt is offline   Reply With Quote

Old   December 31, 2022, 10:44
Default
  #3
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 736
Rep Power: 14
Tobermory will become famous soon enough
Given the silence from the community on this one, I think it's safe to assume that there probably is no clear meaning to the quantity and I'm not sure why/when you would ever want to use it.

Here's my interpretation of the quantity: start off with the initial definition:
\overline{U}_n = (1-\beta)\overline{U}_{n-1} + \beta U_n
and rearrange:
(\Delta \overline{U})_n = \overline{U}_n - \overline{U}_{n-1} = \beta (U_n - \overline{U}_{n-1} )
and now you see that the change in the average value is the weighted difference between the new instantaneous value and the old mean, with the weight being \beta = 1/m.

This can be visualised in the following chart, for a sequence of n=20 and window values of m = 2, 5 and 10. The chart shows the factors on the U_i values in the arithmetic sequence (refer back to my original post) ... as can be seen, there's no real meaning to the result - it's not an average of the last m values, which was what I originally thought it might be aiming to provide. It's just a complex mash of all of the previous values, with higher weighting to the more recent values.

So, all in all - unless someone can provide a justification, my advice is to ignore it.
Attached Images
File Type: png Screenshot 2022-12-31 144151.png (13.1 KB, 47 views)
Tobermory is offline   Reply With Quote

Reply


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
Time averaging of new variable using fieldAverage Mirage OpenFOAM Post-Processing 6 November 9, 2019 22:30
Averaging a field created by a functionObject me3840 OpenFOAM Post-Processing 2 October 3, 2018 12:58
fieldAverage - window and periodicRestart mechkween OpenFOAM 1 April 17, 2018 04:19
fieldAverage fails to continue averaging the fields FernandoSoares OpenFOAM Programming & Development 6 December 8, 2015 16:43
Starting field averaging using libFunctionObject after certain time eelcovv OpenFOAM Programming & Development 25 December 7, 2015 23:28


All times are GMT -4. The time now is 20:19.