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

Why Uprime2mean is minus in some grids?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By gregor
  • 1 Post By anon_a
  • 1 Post By gregor

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 30, 2011, 06:14
Question Why Uprime2mean is minus in some grids?
  #1
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
Dear Foamers,
I need mean value of u'u', v'v' and w'w' to reach to u' , v' and w'.
when uprime2mean in controlDict switched on these values were written in time folders.
But i don't know why they are minus in some grids.
Any suggestion?
maysmech is offline   Reply With Quote

Old   July 1, 2011, 06:03
Default
  #2
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
If it is mean of U'U', it should be positive, shouldn't it?
maysmech is offline   Reply With Quote

Old   July 1, 2011, 07:45
Default
  #3
Member
 
Gregor Olenik
Join Date: Jun 2009
Location: http://greole.github.io/
Posts: 89
Rep Power: 17
gregor is on a distinguished road
how can i delete a post ?

Last edited by gregor; July 1, 2011 at 08:11.
gregor is offline   Reply With Quote

Old   July 3, 2011, 08:06
Default
  #4
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
Any suggestion?
maysmech is offline   Reply With Quote

Old   July 6, 2011, 08:56
Default
  #5
New Member
 
Vadims Geza
Join Date: Apr 2010
Location: Latvia
Posts: 9
Rep Power: 16
Vadims.geza is on a distinguished road
as I know, uprime2mean is a symmetric tensor, thus with 6 components. cross components (say, U'W') can be negative. check if You are observing right components.

Best Regards
Vadims.geza is offline   Reply With Quote

Old   July 6, 2011, 09:02
Default
  #6
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
You are right.
its 6 components are: U'U U'V' U'W' V'V' V'W' W'W'
As you say U'W' can be negative but my problem is U'U' is negative in some grids !
maysmech is offline   Reply With Quote

Old   January 23, 2012, 20:00
Default
  #7
Member
 
pooyan
Join Date: Nov 2011
Posts: 62
Rep Power: 14
sam1364 is on a distinguished road
Hi Maysam,

Did you get any answer from your question?! do you know how uprime2Mean is calculated? I have problem to find out how this parameter is calculated.

Thanks,
Pooyan
sam1364 is offline   Reply With Quote

Old   January 24, 2012, 02:21
Default
  #8
Disabled
 
Join Date: Mar 2011
Posts: 174
Rep Power: 15
anon_a is on a distinguished road
Call this a stupid question but I have to ask:

prime2Mean is calculated in src/postProcessing/functionObjects/field/fieldAverage/fieldAverage/fieldAverageTemplates.C
with the following code

Code:
scalar alpha = 0.0;
scalar beta = 0.0;
if (faItems_[i].timeBase())
{
    alpha = (totalTime_[i] - dt)/totalTime_[i];
    beta = dt/totalTime_[i];
}
else                                                                                                                             
{
    alpha = scalar(totalIter_[i] - 1)/scalar(totalIter_[i]);
    beta = 1.0/scalar(totalIter_[i]);
}
prime2MeanField =
    alpha*prime2MeanField
 + beta*sqr(baseField)
  - sqr(meanField);
Shouldn't the last lines be like this?
Code:
prime2MeanField =
    alpha*prime2MeanField
 + beta*sqr(baseField)
  - beta*sqr(meanField);
Or is this just in my head? I never understood...
anon_a is offline   Reply With Quote

Old   January 24, 2012, 08:59
Default
  #9
Member
 
Gregor Olenik
Join Date: Jun 2009
Location: http://greole.github.io/
Posts: 89
Rep Power: 17
gregor is on a distinguished road
Quote:
Originally Posted by anon_a View Post
[/CODE]Shouldn't the last lines be like this?
Code:
prime2MeanField =
    alpha*prime2MeanField
 + beta*sqr(baseField)
  - beta*sqr(meanField);
Or is this just in my head? I never understood...

No it shouldn't

they're using the following identy:

1/(n)sum^n(phi_i-<phi>)^2=1/n*sum^n(phi_i^2)-<phi>^2 , where <.> is an averaged value

http://en.wikipedia.org/wiki/Computa...r_the_variance

Edit: added missing 1/n
solefire likes this.

Last edited by gregor; January 24, 2012 at 11:28.
gregor is offline   Reply With Quote

Old   January 24, 2012, 09:57
Default
  #10
Disabled
 
Join Date: Mar 2011
Posts: 174
Rep Power: 15
anon_a is on a distinguished road
Yes, I am aware of this identity (by the way, you missed 1/(n) in the first sum of the RHS).
However, I have to insist that there is something wrong.
I attach a small pdf with my derivations, can you find the error?
Attached Files
File Type: pdf variance.pdf (61.4 KB, 236 views)
sxpsxp007 likes this.
anon_a is offline   Reply With Quote

Old   January 24, 2012, 11:13
Default
  #11
Member
 
Gregor Olenik
Join Date: Jun 2009
Location: http://greole.github.io/
Posts: 89
Rep Power: 17
gregor is on a distinguished road
i will look through equations when i find some time, in the meanwhile you can have a look at my document.

But i think the problem is that you don't consider the mean value as a "on the fly value" so you can not simply use N<x>^2=(N-1)x^2+x^2 since you need for sigma^2_pr <x>^2_{N-1} instead <x>^2_N

Gregor

PS: And be aware that actually two steps are performed

1. removing the old mean value in addMeanSqrToPrime2Mean<scalar, scalar> in fieldAverage.C Line 175

2. evaluating the variance using current mean value calculatePrime2MeanFields<scalar, scalar> in fieldAverage.C Line192
Attached Files
File Type: pdf test.pdf (75.7 KB, 209 views)
solefire likes this.

Last edited by gregor; January 24, 2012 at 12:08.
gregor is offline   Reply With Quote

Old   January 24, 2012, 12:20
Default
  #12
Disabled
 
Join Date: Mar 2011
Posts: 174
Rep Power: 15
anon_a is on a distinguished road
Sorry but there seem to be many errors in your derivations:
- In your calculations, you take (1) (which, I assume, is your interpretation of the OF expression) as correct, while I am trying to see if it can be proven.
- Where did the term <phi>_{i-1}^2 in (1) come from? It does not exist in OF.
- The substitution in (2) was performed incorrectly, terms like (n-1)/n and <phi>_{i-2}^2 are missing in the parenthesis.
- Where did sigma_{i-2} go in (3)?
- Where did the sum come up in (4)?
and so on...

EDIT: I now see your point about the existence of <phi>_{i-1}^2 after your note about addMeanSqrToPrime2Mean.
To be honest, this confuses me even more.
anon_a is offline   Reply With Quote

Old   January 24, 2012, 12:41
Default
  #13
Member
 
Gregor Olenik
Join Date: Jun 2009
Location: http://greole.github.io/
Posts: 89
Rep Power: 17
gregor is on a distinguished road
Quote:
Originally Posted by anon_a View Post
Sorry but there seem to be many errors in your derivations:
- In your calculations, you take (1) (which, I assume, is your interpretation of the OF expression) as correct, while I am trying to see if it can be proven.
So do it the other way round and look if can derive it from the algorithm

Quote:
Originally Posted by anon_a View Post
- Where did the term <phi>_{i-1}^2 in (1) come from? It does not exist in OF.
look what happens in the addMeanSqrToPrime2Mean function.

Quote:
Originally Posted by anon_a View Post
- The substitution in (2) was performed incorrectly, terms like (n-1)/n and <phi>_{i-2}^2
are missing in the parenthesis.
sigma_{i-1} = sigma_{i-2} + <phi>^2_{i-1}

thats the step performed in addMeanSqrToPrime2Mean in fieldAverageTemplates.C line 264

Code:
prime2MeanField += sqr(meanField);
Quote:
Originally Posted by anon_a View Post
- Where did sigma_{i-2} go in (3)?
like if have written i assume it to be zero (which might not be true for i-2 but has to be for i=0 and since all the old mean values are canceled out for every timestep it should be ok)

Quote:
Originally Posted by anon_a View Post
- Where did the sum come up in (4)?
you could write (3) as

sigma = alpha * phi^2_old + beta*phi^2 - <phi>_i^2

which is

sigma = <phi^2>_i - <phi>_i^2

or

sigma = 1/n sum(phi_i^2) - <phi>_i^2 .

I know its not nice and there are many typos but may be you still see the point

Gregor

Last edited by gregor; January 24, 2012 at 13:10.
gregor is offline   Reply With Quote

Old   January 24, 2012, 12:56
Default
  #14
Member
 
Gregor Olenik
Join Date: Jun 2009
Location: http://greole.github.io/
Posts: 89
Rep Power: 17
gregor is on a distinguished road
Quote:
Originally Posted by anon_a View Post
EDIT: I now see your point about the existence of <phi>_{i-1}^2 after your note about addMeanSqrToPrime2Mean.
To be honest, this confuses me even more.
You could try it by evaluting it manually. The point is you want to have a variance every time step but your final mean value is unknown, therefore you take the current mean value. But once you use the current mean value the old mean values has to be taken out.
gregor is offline   Reply With Quote

Old   January 24, 2012, 13:25
Default
  #15
Disabled
 
Join Date: Mar 2011
Posts: 174
Rep Power: 15
anon_a is on a distinguished road
Well, I thought about it on the way home.
It's quite simple now that you told me about addMeanSqr.
You can add and substract (N-2)/(N-1) (<x>)^2 in my last equation and the OF expression is obtained.

Thanks for your help, patience and time, it is clear now!
I assume that this square is added in the beginning to avoid numerical errors, cancellations of significant digits and so on, right?
anon_a is offline   Reply With Quote

Old   January 24, 2012, 13:36
Default
  #16
Member
 
Gregor Olenik
Join Date: Jun 2009
Location: http://greole.github.io/
Posts: 89
Rep Power: 17
gregor is on a distinguished road
Yes i guess it is the same reason why you calculate the average by

<phi> = alpha*<phi>_{i-1} + beta * phi

instead of using

phiS += phi

phiA = phi/N

to avoid big numbers.

Sorry if wasn't that clear. Explaining something easy is an art
gregor is offline   Reply With Quote

Old   August 10, 2012, 00:52
Default
  #17
aka
New Member
 
Getnet
Join Date: Aug 2011
Location: LSU
Posts: 20
Rep Power: 15
aka is on a distinguished road
Quote:
Originally Posted by gregor View Post
You could try it by evaluting it manually. The point is you want to have a variance every time step but your final mean value is unknown, therefore you take the current mean value. But once you use the current mean value the old mean values has to be taken out.
Hi Gregor,
You said "The point is you want to have a variance every time step but your final mean value is unknown, therefore you take the current mean value." I understand most of your derivations however, I am still confused on the idea of using the "current mean value" instead of the "final mean value". For the variance, we need the final mean value and using the current mean value may have a significant effect for strongly separated flows. I also see a difference on the last term of your derivation on the "test.pdf" file. You used <phi>_i^2 on the last term in equation (2) however <phi>^2 is coming on your equation (3). It seems you are going from the current mean to the final mean value. I appreciate your help on this part. It took me some time to get convinced with the way "prim2Mean" is calculated in OpenFOAM.

Thanks a lot!
aka is offline   Reply With Quote

Old   August 13, 2012, 05:45
Default
  #18
Member
 
Gregor Olenik
Join Date: Jun 2009
Location: http://greole.github.io/
Posts: 89
Rep Power: 17
gregor is on a distinguished road
Quote:
Originally Posted by aka View Post
I understand most of your derivations however, I am still confused on the idea of using the "current mean value" instead of the "final mean value".
For the variance, we need the final mean value and using the current mean value may have a significant effect for strongly separated flows.
In step 1 in the pdf file you plug in the old variance and the old mean value gets cancelled out. This means you are alway using the current mean value. The current mean value is correct but only up to the current (i-th) time step. In the next time step you update the mean value, take out the effect of the old (which is not valid anymore) value and calculate the variance using the new current mean value. However on the long run your mean value should converge and therefore shouldnt change anymore, because if your mean value is not converged there is no chance that your variances are converged.

Quote:
Originally Posted by aka View Post
I also see a difference on the last term of your derivation on the "test.pdf" file. You used <phi>_i^2 on the last term in equation (2) however <phi>^2 is coming on your equation (3). It seems you are going from the current mean to the final mean value.
I agree that the document is very sloppy written. The point is, that your current mean value is the final value for your time series up to time i.

Last edited by gregor; August 13, 2012 at 10:19.
gregor is offline   Reply With Quote

Old   August 22, 2012, 04:33
Default
  #19
aka
New Member
 
Getnet
Join Date: Aug 2011
Location: LSU
Posts: 20
Rep Power: 15
aka is on a distinguished road
Thanks Gregor . I appreciate it.
aka is offline   Reply With Quote

Old   November 14, 2012, 08:31
Default
  #20
Member
 
Aru
Join Date: Feb 2012
Location: Chennai, India
Posts: 40
Rep Power: 14
arunsmec is on a distinguished road
UPrime2mean has 6 components 0,1,2...5. Among these which are <uu>, <v v> and <ww>?
arunsmec 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 step at coarse grids D3sT Main CFD Forum 0 December 6, 2010 12:15
A question about dynamic overset grids JXIA Main CFD Forum 4 January 10, 2008 04:50
Reloading grids in Pre Pascale Fonteijn CFX 1 July 7, 2003 14:33
Minus Volume of cells di bonga CFX 2 April 8, 2001 14:38
UDF Face Fluxes & Partitioned Grids Greg Perkins FLUENT 0 April 6, 2001 02:50


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