CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   implementing a new wall function (http://www.cfd-online.com/Forums/openfoam-programming-development/121898-implementing-new-wall-function.html)

romant August 7, 2013 10:43

implementing a new wall function
 
I would like to implement a new wall function in OpenFOAM, however, I need to understand the existing wall function implementation first. I would like to know if I understand the current implementation.

at first we have the stresses near the wall

(nu + nut) dUdy_wall = tau_w / rho

where I can now rewrite to

nu_t = tau_w / rho * (dUdy)^-1 - nu= tau_w / rho (U_P / y_P)^-1 - nu

where U_P and y_P are the velocity in the first point from the wall from the field solution and the distance to the first point from the wall, respectively.

I think tau_w can then be replaced with (Versteeg and Malalasekera)

tau_w = rho (c_mu^1/4) (k_P^1/2) U_P kappa / (ln(E yPlus))

or in other version using yPlus=(c_mu^1/4) (k_P^1/2) y_P / nu this becomes

nu_t = nu (yPlus kappa / ln(E yPlus) - 1 )
(OF nutkWallFunction)

As far as I understand I only need to replace the tau_w in the above derivation and have implemented an alternative wall function. I know that I also need to apply different terms to the epsilonwall function and the k wall function if needed. However, I had a harder time understanding the implementation of the momentum term that in Versteeg and Malalasekera is just given as tau_w * A_cell = S and should be somehow introduced in the momentum equation.

The question is now, did I correctly understand the implementation and is it really just necessary to replace tau_w in the above expression in order to get a different wall function and is the replacement of dUdy = U_P/y_P correctly applied.

openfoammaofnepo April 8, 2014 11:00

Dear Roman,

Thank you for your help with my questions in another thread. Your above derivations are correct and helpful. At this stage, actually I have the same question with you:

Code:

How mutw (I am looking at the compressible RAS mutUWallFunction) affects the discretization of the momentum equations?
Do you have further understanding about this issue?

OFFO

openfoammaofnepo April 8, 2014 12:57

Dear Roman,

About your last arguments, I think it is correct: the wall shear stress is calculated in different ways in different models. For example, in the following wall function:

Code:

https://github.com/OpenFOAM/OpenFOAM-2.1.x/blob/master/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutUSpaldingWallFunction/mutUSpaldingWallFunctionFvPatchScalarField.C
The wall shear stress is obtained from friction velocity, which is from the Newton iteration from Spalding's Law. About the wall function mutUSpaldingWallFunction in Openfoam, I have the following questions:

1, in the above source files I quoted, what does the following quantity magUp stand for?

Code:

scalarField magUp(mag(Uw.patchInternalField() - Uw));
2, About the velocity gradient normal to the wall, dU/dy, in OF it is equal to:

Code:

const scalarField magGradU(mag(Uw.snGrad()));
So in Openfoam, the dU/dy is set to be the normal gradient at the walls. If I am not making a mistake, this calculation very much depends on the near wall resolutions. If the first node is far from the wall (large yPlus, actually this always the case for most the wall functions in LES), there will be some inaccuracies if we still predict the dU/dy like that.

Any comments are welcome.

OFFO

romant April 9, 2014 02:47

Quote:

Originally Posted by openfoammaofnepo (Post 484691)
Dear Roman,

Thank you for your help with my questions in another thread. Your above derivations are correct and helpful. At this stage, actually I have the same question with you:

Code:

How mutw (I am looking at the compressible RAS mutUWallFunction) affects the discretization of the momentum equations?
Do you have further understanding about this issue?

OFFO

I am not sure what you mean by this. However, when you look at the momentum equation in OpenFOAM, you can see that there is something like (mut+mu)=muEff, which is the effective viscosity. This is where mutw, will be inserted into the equation.

romant April 9, 2014 02:56

Quote:

Originally Posted by openfoammaofnepo (Post 484709)
Dear Roman,

About your last arguments, I think it is correct: the wall shear stress is calculated in different ways in different models. For example, in the following wall function:

Code:

https://github.com/OpenFOAM/OpenFOAM-2.1.x/blob/master/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutUSpaldingWallFunction/mutUSpaldingWallFunctionFvPatchScalarField.C
The wall shear stress is obtained from friction velocity, which is from the Newton iteration from Spalding's Law. About the wall function mutUSpaldingWallFunction in Openfoam, I have the following questions:

1, in the above source files I quoted, what does the following quantity magUp stand for?

Code:

scalarField magUp(mag(Uw.patchInternalField() - Uw));
2, About the velocity gradient normal to the wall, dU/dy, in OF it is equal to:

Code:

const scalarField magGradU(mag(Uw.snGrad()));
So in Openfoam, the dU/dy is set to be the normal gradient at the walls. If I am not making a mistake, this calculation very much depends on the near wall resolutions. If the first node is far from the wall (large yPlus, actually this always the case for most the wall functions in LES), there will be some inaccuracies if we still predict the dU/dy like that.

Any comments are welcome.

OFFO

  1. magUp stands for the magnitude of the velocity in point P, the first point away from the wall. It uses the relative velocity difference between the velocity in P ( mag(Uw.patchInternalField() ) and the velocity at the wall ( Uw ). This is done in case there is a moving wall, or partial slip at the wall.
  2. This is correct, a larger y+ leads to larger errors in the predictions (but it is not really bad if your y+ is within limits of applicability). I am not sure what the applicability for the Spalding wall function is, as I am usually calculating things in RANS or U-RANS, where the applicability for the law of the wall is about y+=30 to 150, something even a little bit higher. The gradient is actually only used to set the "correction" source to get the right velocity in point P, as you can see in post #1 . It shouldn't have such a large influence. However, as previously said, you always also have to look at the applicability range of the wall function.

openfoammaofnepo April 9, 2014 16:46

Dear Romant,

Thank you for your continuous help. In my understanding, the reason why we need to model the wall stress lies in the following implementations:

if we use cell-centered finite volume discretization just used in OF, we will integrate the NS equation over the all the control volumes. For the diffusion terms (molecular diffusion + turbulent diffusion) in momentum equations, the contribution of each face from diffusive fluxes to each cell (the quantities are stored at the cell cnetroids) is linked to the gradient at the inter-cell face (and of course also the mu and mut at the inter-cell faces). If this face just coincides with the wall, so this gradient is the wall shear stress (or drag).

So the following problem is how to model the wall shear stress. From the above line of reasoning, the two terms (molecular diffusion + turbulent diffusion) will have the numerical flux contributions to the near-wall cell. The following issues are: how to predict the gradient corresponding to the molecular diffusion + turbulent diffusion.

My ultimate question is: why in openfoam, the wall function only applies to the mut, which corresponding to the turbulent diffusion?

Thank you so much. Please correct if what I am saying has some problems.
OFFO


Quote:

Originally Posted by romant (Post 484843)
I am not sure what you mean by this. However, when you look at the momentum equation in OpenFOAM, you can see that there is something like (mut+mu)=muEff, which is the effective viscosity. This is where mutw, will be inserted into the equation.


openfoammaofnepo April 9, 2014 16:49

For Spalding wall function, they claimed that that equation can be used for the whole boundary layers: viscous sublayer, buffer layer and turbulence regions.

Quote:

Originally Posted by romant (Post 484846)
  1. magUp stands for the magnitude of the velocity in point P, the first point away from the wall. It uses the relative velocity difference between the velocity in P ( mag(Uw.patchInternalField() ) and the velocity at the wall ( Uw ). This is done in case there is a moving wall, or partial slip at the wall.
  2. This is correct, a larger y+ leads to larger errors in the predictions (but it is not really bad if your y+ is within limits of applicability). I am not sure what the applicability for the Spalding wall function is, as I am usually calculating things in RANS or U-RANS, where the applicability for the law of the wall is about y+=30 to 150, something even a little bit higher. The gradient is actually only used to set the "correction" source to get the right velocity in point P, as you can see in post #1 . It shouldn't have such a large influence. However, as previously said, you always also have to look at the applicability range of the wall function.


romant April 10, 2014 02:54

Quote:

Originally Posted by openfoammaofnepo (Post 485039)
Dear Romant,

My ultimate question is: why in openfoam, the wall function only applies to the mut, which corresponding to the turbulent diffusion?
OFFO

It is only used for mut, because mut is 0 at the wall, which is why it can be used for something else entirely, like inserting a source term. As far as I can see this is the whole reason behind this. Of course, one could have probably solved in a different way, but in my opinion, this is an elegant solution. It re-purposes something that already exists and does not introduce another term that might not be used in all equations.
For RANS, there are also wall functions for alphat (temperature wall function) and also to set the turbulent production and dissipation (epsilon wall function).

Quote:

Originally Posted by openfoammaofnepo (Post 485040)
For Spalding wall function, they claimed that that equation can be used for the whole boundary layers: viscous sublayer, buffer layer and turbulence regions.

Then I think it shouldn't be a problem to use it for the whole range.

openfoammaofnepo April 10, 2014 12:11

Hi Romant,

Thank you for your very helpful suggestions and comments. Did you have any experience in using/implementing LES wall function in OF? How are their performances?

best regards,
OFFO

Quote:

Originally Posted by romant (Post 485121)
It is only used for mut, because mut is 0 at the wall, which is why it can be used for something else entirely, like inserting a source term. As far as I can see this is the whole reason behind this. Of course, one could have probably solved in a different way, but in my opinion, this is an elegant solution. It re-purposes something that already exists and does not introduce another term that might not be used in all equations.
For RANS, there are also wall functions for alphat (temperature wall function) and also to set the turbulent production and dissipation (epsilon wall function).



Then I think it shouldn't be a problem to use it for the whole range.


romant April 11, 2014 04:54

Unfortunately, I don't have any experience with wall functions for LES. I have only worked with wall functions for RANS models and also implemented some for RANS.

Nero_CMU August 18, 2015 11:51

Dear Roman

I too am trying to implement a new wall function in OpenFOAM and have similar doubt as you. Were you able to find if it's necessary to introduce the new tau_w term in the momentum equation for the new wall function to take effect?

Regards
Nihar

romant August 19, 2015 08:49

Quote:

Originally Posted by Nero_CMU (Post 560048)
Dear Roman

I too am trying to implement a new wall function in OpenFOAM and have similar doubt as you. Were you able to find if it's necessary to introduce the new tau_w term in the momentum equation for the new wall function to take effect?

Regards
Nihar

There is no need to implement the new tau_w into the momentum equation by any means. Boundary conditions mut...WallFunction and nut...WallFunction take care of this. At the wall nut and mut are 0, therefore, you can reuse these values at the wall for other purposes, for example for introducing the tau_w wall shear stress into the momentum equation. So, if you now look at post #1, you see that it is fairly easy to implement a new wall function. Just take any of the simpler wall function models and replace tau_w in that model with the one that you calculate and you obtain a new wall function.


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