CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

A few questions about LES filtering in OpenFOAM

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 1 Post By usv001
  • 1 Post By usv001
  • 1 Post By Mahdi2010

Reply
 
LinkBack Thread Tools Display Modes
Old   May 1, 2016, 05:17
Default A few questions about LES filtering in OpenFOAM
  #1
Member
 
章严
Join Date: May 2014
Posts: 33
Rep Power: 5
zhangyan is on a distinguished road
Hello,
In the OpenFOAM source codes,I found "laplace Filter" in the source codes, so I guessed the dynLagrangian must be used accompany with "laplace Filter".

Actually, I am going to implement the dynamic K-E or dynLagrangian SGS model to another software. But I don't know how to implement the "simple Filter".

It seems that implementing laplace Filter is more easier. Could you tell me does the SGS models must be used accompany with particular Filters? For example, dynamicKEqn + simple filter; dynamicLagrangian + laplace Filter.

Another question: If you understand the meaning of "simple Filter", Could you tell me the physical meaning of it?

Please forgive my poor English.

simple Filter:

tmp<volScalarField> filteredField = fvc::surfaceSum
(
mesh().magSf()*fvc::interpolate(unFilteredField)
)/fvc::surfaceSum(mesh().magSf())

laplace Filter:

tmp<volTensorField> filteredField =
unFilteredField() + fvc::laplacian(coeff_, unFilteredField())


Thanks,
Zhang Yan

[ Moderator note - Moved from here: http://www.cfd-online.com/Forums/mai...-do-you-3.html ]

Last edited by wyldckat; May 1, 2016 at 15:01. Reason: see "Moderator note"
zhangyan is offline   Reply With Quote

Old   May 4, 2016, 09:50
Default
  #2
Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 51
Rep Power: 3
usv001 is on a distinguished road
Hi Zhang Yan,

I am trying to figure out LES implementation in OpenFOAM myself but I'll still try to give an answer. Please correct me if I am wrong.

simpleFilter
If you look at the code, you will see that the unFilteredField is first interpolated from the cell centers to the cell faces using 'fvc::interpolate'. Then, the filteredField is simply the area-weighted average of the interpolated values using 'fvc::surfaceSum'.

laplaceFilter
I am not so sure about this but I'll try. I'm borrowing some ideas from image processing since that's all the relevant information that I could find on Laplace filters.

Let's say you have a random signal, u which has high frequency noise that you wish to filter/smooth. We can derive the finite difference Laplace operator for the signal as:
\nabla^2 u = \frac{u_{i-1} - 2u_i + u_{i+1}}{\Delta^2}
According to the code, the Laplacian is first multiplied by 'coeff_' which is proportional to V^{2/3} and, hence, has the dimensions of \Delta^2. This result is then added to the unFilteredField. Let's try to do that by letting the proportionality parameter 'widthCoeff_' as 4:
\tilde{u_i} = u_i +\frac{ \Delta^2}{4}  \left(  \frac{u_{i-1} - 2u_i + u_{i+1}}{\Delta^2} \right)  = \frac{u_{i-1} + 2u_i + u_{i+1}}{4}
As it can be seen, the result is an average over the adjacent cells.

Conclusion
I think filtering operation can be viewed as smoothing or averaging operation. I would love to know if I am getting any of this wrong. Also, I am not too sure as to the role of 'widthCoeff_' and would like to know more as well.

As to which filter to use with which dynamic SGS model, I think it does not really matter. Any filter should be fine as long as you define the relevant '<LESFilter>Coeffs'. However, according to this, the laplace filter is not generally used. Not too sure why.

Anyway, hope this helps you.
yuan_neu likes this.
usv001 is offline   Reply With Quote

Old   May 4, 2016, 10:11
Default
  #3
Member
 
章严
Join Date: May 2014
Posts: 33
Rep Power: 5
zhangyan is on a distinguished road
Thank you very much!
Since it's too late today (in my country), I will study your admirable answer carefully tomorrow.
zhangyan is offline   Reply With Quote

Old   May 7, 2016, 02:53
Default
  #4
Member
 
章严
Join Date: May 2014
Posts: 33
Rep Power: 5
zhangyan is on a distinguished road
Quote:
Originally Posted by usv001 View Post
Hi Zhang Yan,

I am trying to figure out LES implementation in OpenFOAM myself but I'll still try to give an answer. Please correct me if I am wrong.

simpleFilter
If you look at the code, you will see that the unFilteredField is first interpolated from the cell centers to the cell faces using 'fvc::interpolate'. Then, the filteredField is simply the area-weighted average of the interpolated values using 'fvc::surfaceSum'.

laplaceFilter
I am not so sure about this but I'll try. I'm borrowing some ideas from image processing since that's all the relevant information that I could find on Laplace filters.

Let's say you have a random signal, u which has high frequency noise that you wish to filter/smooth. We can derive the finite difference Laplace operator for the signal as:
\nabla^2 u = \frac{u_{i-1} - 2u_i + u_{i+1}}{\Delta^2}
According to the code, the Laplacian is first multiplied by 'coeff_' which is proportional to V^{2/3} and, hence, has the dimensions of \Delta^2. This result is then added to the unFilteredField. Let's try to do that by letting the proportionality parameter 'widthCoeff_' as 4:
\tilde{u_i} = u_i +\frac{ \Delta^2}{4}  \left(  \frac{u_{i-1} - 2u_i + u_{i+1}}{\Delta^2} \right)  = \frac{u_{i-1} + 2u_i + u_{i+1}}{4}
As it can be seen, the result is an average over the adjacent cells.

Conclusion
I think filtering operation can be viewed as smoothing or averaging operation. I would love to know if I am getting any of this wrong. Also, I am not too sure as to the role of 'widthCoeff_' and would like to know more as well.

As to which filter to use with which dynamic SGS model, I think it does not really matter. Any filter should be fine as long as you define the relevant '<LESFilter>Coeffs'. However, according to this, the laplace filter is not generally used. Not too sure why.

Anyway, hope this helps you.


Hi,
According to your reply, I got my answer about simple filter:
filteredField = sum(A_i * S_i) / sum(S_i)
A_i is face value after interpolate, S_i is face area.
Is it right?

Besides, I have another question:
If I use simple filter as the test filter for a dynamic SGS model,
as a test filter, how does simple filter show the double width compared to the first filter?

Last edited by zhangyan; May 7, 2016 at 06:51.
zhangyan is offline   Reply With Quote

Old   May 8, 2016, 09:34
Default
  #5
Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 51
Rep Power: 3
usv001 is on a distinguished road
Hi there,

Yup, I have the same idea of the simple filter.

I am reading up on filtering myself (I am new to LES/OpenFOAM as well) but here is what I think is happening:

The filtering of the original LES equations is implicit in OpenFOAM, i.e. the finite volume method (grid+discretization) itself acts as a filter! This is known as implicit LES. So, when you apply any dynamic model, it performs a further filtering process, the test filter.

The factor of two does appear in the code. For example, for the 'homogeneousDynSmagorinsky' model:

Code:
const volSymmTensorField MM
    (
        sqr(delta())*(filter_(mag(D)*(D)) - 4*mag(filter_(D))*filter_(D))
    );
Notice the factor '4'. That is the result of...
MM_{ij} = \Delta^2 \left[ \widetilde{D_{ij}\sqrt{D_{ij} D_{ij}}} - \frac{\Delta_t^2}{\Delta^2} \widetilde{D_{ij}}{\sqrt{\widetilde{D_{ij}} \widetilde{D_{ij}}}} \right] where {\Delta_t}/{\Delta} = 2.

Hope this helps.
fumiya likes this.

Last edited by usv001; May 8, 2016 at 09:37. Reason: Error in formula
usv001 is offline   Reply With Quote

Old   May 8, 2016, 10:05
Default
  #6
Member
 
章严
Join Date: May 2014
Posts: 33
Rep Power: 5
zhangyan is on a distinguished road
Thanks for your explanation!
Now I am implementing dynamic procedure to KIVA (the software I'm using).
In KIVA, velocity is stored on the vertices.
So one of the face(bottom) value is : 0.25(u1+u2+u3+u4).
Code:
     7/--------/|6
     /        / |
    / |      /  |
   /        /   |
 8/--------/5   |
  |   |    |    |
  |        |    |
  |  3|-  -| -  |2
  |   /    |   /
  |        |  /
  | /      | /
  |        |/
 4----------1
However, when I am calculate the filter_Sij.
You know, I must interpolate Sij to the cell faces.
For example, S11=dudx, in KIVA, dudx=0.25*(u3+u4+u7+u8-u1-u2-u5-u6)/delta_X

I know velocity is stored on the vertice, but I don't know where Sij is stored.
So I don't know how to interpolate Sij to the cell faces.
Do you have any idea?
zhangyan is offline   Reply With Quote

Old   July 13, 2017, 09:08
Default
  #7
Member
 
Mahdi
Join Date: Jul 2012
Posts: 48
Rep Power: 7
Mahdi2010 is on a distinguished road
Quote:
Originally Posted by usv001 View Post
Hi there,

Yup, I have the same idea of the simple filter.

I am reading up on filtering myself (I am new to LES/OpenFOAM as well) but here is what I think is happening:

The filtering of the original LES equations is implicit in OpenFOAM, i.e. the finite volume method (grid+discretization) itself acts as a filter! This is known as implicit LES. So, when you apply any dynamic model, it performs a further filtering process, the test filter.

The factor of two does appear in the code. For example, for the 'homogeneousDynSmagorinsky' model:

Code:
const volSymmTensorField MM
    (
        sqr(delta())*(filter_(mag(D)*(D)) - 4*mag(filter_(D))*filter_(D))
    );
Notice the factor '4'. That is the result of...
MM_{ij} = \Delta^2 \left[ \widetilde{D_{ij}\sqrt{D_{ij} D_{ij}}} - \frac{\Delta_t^2}{\Delta^2} \widetilde{D_{ij}}{\sqrt{\widetilde{D_{ij}} \widetilde{D_{ij}}}} \right] where {\Delta_t}/{\Delta} = 2.

Hope this helps.

I agree with this statement that normal LES models use implicit filtering in OpenFOAM.
Also dynamic models use explicit filter (with different choices for shape and size) as the test filter. But if you check the code for one of the dynamic models like "Dynamic Smagorinsky" they use the same delta that is used in normal "Smagorinsky" which is implicit. Isn't it contradictory?

Because as you showed in the equation above, the factor 4 appears because the test filter width (explicit) is twice the grid filter (implicit), but what we see as the delta in both
models is grid size (i.e. cuberoot ---> deltaCoeff_*pow(mesh().V(), 1.0/3.0) )
and this delta coefficient is always 1 in every "LESProperties". Do you have any comment on that?
Mahdi2010 is offline   Reply With Quote

Old   July 13, 2017, 11:17
Default
  #8
Member
 
Join Date: Sep 2015
Location: Singapore
Posts: 51
Rep Power: 3
usv001 is on a distinguished road
Hello Mahdi,

My understanding is that if you don't use any SGS model, then you are letting the inherent numerical dissipation to play its place. So, under this definition the Smagorinsky model is not an implicit LES but an explicit one - you specify an SGS model. So, I see no issues in the SGS models (Smagorinsky and its dynamic counterpart) using the same delta. The only thing that matters is that the test filter width \Delta_t must be larger than the normal filter width \Delta. However, I am no expert in this area. So, correct me if I wrong about any of this.

Cheers,
USV
usv001 is offline   Reply With Quote

Old   July 13, 2017, 14:33
Default
  #9
Member
 
Mahdi
Join Date: Jul 2012
Posts: 48
Rep Power: 7
Mahdi2010 is on a distinguished road
Quote:
Originally Posted by usv001 View Post
Hello Mahdi,

My understanding is that if you don't use any SGS model, then you are letting the inherent numerical dissipation to play its place. So, under this definition the Smagorinsky model is not an implicit LES but an explicit one - you specify an SGS model. So, I see no issues in the SGS models (Smagorinsky and its dynamic counterpart) using the same delta. The only thing that matters is that the test filter width \Delta_t must be larger than the normal filter width \Delta. However, I am no expert in this area. So, correct me if I wrong about any of this.

Cheers,
USV
This is true that the test filter must be larger, but as far as I understand from different posts in forum, in OpenFOAM the normal filter (implicit, grid) is operating by the discretization of equation. I mean in a normal/static LES, the grid acts as filter by means of discretization. So it uses \Delta x for as the filter width, or not?
That's why we do not see any "filter" in the formulation of, for instance, Smagorinsky.
But when you check the code of "dynSmagorinsky" or "dynOneEddy", the term "filter" is clearly seen in the code. This is of course the "test" filter, and its type is usually chosen "simple". But it uses the same width. So, the crucial condition of "\Delta_t > \Delta" doesn't get satisfied. Isn't it a problem?
Or you mean the \Delta in the turbulence model and filter width are two different entities?
fumiya likes this.
Mahdi2010 is offline   Reply With Quote

Old   July 16, 2017, 08:21
Default
  #10
Senior Member
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 213
Blog Entries: 1
Rep Power: 11
fumiya is on a distinguished road
Hi Mahdi,

I have the same question and am thinking in the following manner.
In the simple filter, the fvc::interpolate function is used to calculate the filtered field,
so the neighbour cells' values are considered in the test filtering operation and \Delta_t > \Delta is satisfied.

Best regards,
Fumiya
__________________
fumiya is online now   Reply With Quote

Old   July 16, 2017, 08:40
Default
  #11
Member
 
Mahdi
Join Date: Jul 2012
Posts: 48
Rep Power: 7
Mahdi2010 is on a distinguished road
Quote:
Originally Posted by fumiya View Post
Hi Mahdi,

I have the same question and am thinking in the following manner.
In the simple filter, the fvc::interpolate function is used to calculate the filtered field,
so the neighbour cells' values are considered in the test filtering operation and \Delta_t > \Delta is satisfied.

Best regards,
Fumiya
You are right about the role of interpolation function, however
it is still unclear to me how to determine the width of filter/stencil.
In other words, is the width now twice the grid size? Because by interpolation
I still see the delta_t = grid size. Or I am mistaken?
Mahdi2010 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
LES filter in OpenFOAM openfoammaofnepo OpenFOAM Programming & Development 1 October 23, 2014 07:27
implicit and explicit filtering in LES kkpal OpenFOAM 0 February 19, 2014 03:27
Molecular viscosity calculation in LES on OpenFOAM babakflame OpenFOAM 0 January 26, 2014 05:13
Frequently Asked Questions about Installing OpenFOAM wyldckat OpenFOAM Installation 0 January 1, 2014 20:21
Serious bug in LES interface fs82 OpenFOAM Bugs 21 November 16, 2009 09:15


All times are GMT -4. The time now is 01:40.