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

Wall functions - questions about implementation

Register Blogs Community New Posts Updated Threads Search

Like Tree18Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 20, 2013, 09:22
Default
  #21
Senior Member
 
romant's Avatar
 
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21
romant is on a distinguished road
Quote:
Originally Posted by RodriguezFatz View Post
So what you are saying is that omega and epsilon wall functions have to change the cell value itself, so thay need to be explitcitly called and "overwrite" the calculated cell value. Whereas the k boundary condition defines the value at the cell's boundary and thus just changes theboundary condition of the wall cell but not the value in the first cell. Thus, k boundary condition changes something that is more hidden in the solving routine.
Is that correct?
Yes, most of the wall functions in OpenFOAM, with the exception of the kqRWallFunction, manipulate either the first cell value, or the wall value (in the case of the mut or nut wall functions) and this needs to be explicitly calculated and performed for every cell or cell face.

For more information on wall functions and how they are used you can also take a look at Pope, Turbulent Flows, 2000, pp 442-443 and Versteeg and Malalasekera, An introduction to computational fluid dynamics: The finite volume method, pp. 276-277
__________________
~roman

Last edited by romant; September 20, 2013 at 09:24. Reason: books added
romant is offline   Reply With Quote

Old   April 5, 2014, 05:40
Default su and sp treatment when epsilon gets redined in the first cell
  #22
Member
 
Manan
Join Date: Oct 2013
Location: Göteborg
Posts: 37
Rep Power: 13
MaLa is on a distinguished road
Hello

I have a question related to what is being discussed in this thread.
Say for example, I wish to set epsilon in the first cell as a function of k in the first cell. Is simply calling the appropriate wall function sufficient to implement that?

From what I understand,

Quote:

epsilon_.boundaryField().updateCoeffs()
^calls the relevant epsilon wall function.

Subsequent to this, the solving happens. But what I wonder is, shouldn't the sp and the su terms for the first cell also be modified so that the solver does not overwrite the newly calculated first cell values for epsilon?

For example, if we consider a 1D discretised equation:

ap*eps_p=ae*eps_e+aw*eps_w+su (1)
ap=ae+aw-sp

Now if I set sp and su such as:

su (@first_cell_next_to_wall)=1e10*epsilon_new
sp (@first_cell_next_to_wall)=-1e10

(where epsilon_new is the new value calculated as a function of k)

then,
sp>>aw, sp>>ae. su>>ae, su>>aw. Hence eq. 1 gives

-sp*eps_p=su => eps_p=su/-sp=1e10*epsilon_new/1e10=epsilon_new
Shouldn't such a treatment as above also be there?

Please let me know if I haven't made myself clear. Thanks.
MaLa is offline   Reply With Quote

Old   April 5, 2014, 11:08
Default
  #23
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Hi All,

I have a question about the wall functions implemented in Openfoam. Theoretically, when wall function is used, the velocity at the wall is not zero and instead the velocity there is the friction velocity which is solved from the log-law or linear law. (If the zero velocity is emposed there, then it is equivalent to the non-slip boundary condition.) Then the wall shear stress is obtained tau_w=rho*u_tau**2. Then this wall shear stress can be used for the discretization of the momentum equations in the finite volume appraoch. However, in openfoam's specifications, when wall function is applied, the velocity at the wall is still (0 0 0).

Why can we still use (0 0 0) for the wall velocity here?

Thank you in advance.

OFFO
openfoammaofnepo is offline   Reply With Quote

Old   April 5, 2014, 18:28
Default
  #24
Senior Member
 
romant's Avatar
 
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21
romant is on a distinguished road
Quote:
Originally Posted by openfoammaofnepo View Post
Hi All,

I have a question about the wall functions implemented in Openfoam. Theoretically, when wall function is used, the velocity at the wall is not zero and instead the velocity there is the friction velocity which is solved from the log-law or linear law. (If the zero velocity is emposed there, then it is equivalent to the non-slip boundary condition.) Then the wall shear stress is obtained tau_w=rho*u_tau**2. Then this wall shear stress can be used for the discretization of the momentum equations in the finite volume appraoch. However, in openfoam's specifications, when wall function is applied, the velocity at the wall is still (0 0 0).

Why can we still use (0 0 0) for the wall velocity here?

Thank you in advance.

OFFO
You can use 0 for the velocity, because the shear velocity is not a velocity in this sense. It is calculated as
u_{\tau}=\sqrt{\frac{\tau_w}{\rho}}
where \tau_w is the the wall shear stress calculated from
\tau_w = \mu\partial u / \partial y |_{y=0}
As you can see from that it is not the velocity at the wall, but the velocity gradient at the wall that plays a role.
kiddmax likes this.
__________________
~roman
romant is offline   Reply With Quote

Old   April 5, 2014, 18:48
Default
  #25
Senior Member
 
romant's Avatar
 
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21
romant is on a distinguished road
Quote:
Originally Posted by MaLa View Post
Hello

I have a question related to what is being discussed in this thread.
Say for example, I wish to set epsilon in the first cell as a function of k in the first cell. Is simply calling the appropriate wall function sufficient to implement that?

From what I understand,

^calls the relevant epsilon wall function.

Subsequent to this, the solving happens. But what I wonder is, shouldn't the sp and the su terms for the first cell also be modified so that the solver does not overwrite the newly calculated first cell values for epsilon?

For example, if we consider a 1D discretised equation:

ap*eps_p=ae*eps_e+aw*eps_w+su (1)
ap=ae+aw-sp

Now if I set sp and su such as:

su (@first_cell_next_to_wall)=1e10*epsilon_new
sp (@first_cell_next_to_wall)=-1e10

(where epsilon_new is the new value calculated as a function of k)

then,
sp>>aw, sp>>ae. su>>ae, su>>aw. Hence eq. 1 gives

-sp*eps_p=su => eps_p=su/-sp=1e10*epsilon_new/1e10=epsilon_new
Shouldn't such a treatment as above also be there?

Please let me know if I haven't made myself clear. Thanks.

I think when you look into the code you can see that you don't need the newly calculated epsilon in the first cell anymore, after you have solved the system. http://foam.sourceforge.net/docs/cpp/a10359_source.html

The only part where you need to use epsilon again is in line 329 and following to calculate mut, however, in the case of wall functions, mut will be set in the first cell anyway and therefore it doesn't matter if your epsilon is wrong or not. So epsilon in the first cell only needs to be correct before we solve epsilon, not after.
__________________
~roman
romant is offline   Reply With Quote

Old   April 5, 2014, 19:27
Default
  #26
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Dear Roman,

Thank you for your reply. In the practical CFD implementations, if we use cell centered finite volume method as is done in the OF, the velocity gradient is needed to calculate the numerical flux for the diffusion term in the momentum equations. Is this understanding correct?

Is the following line of reasoning correct:
1, use the log law or linear linear law to get the friction velocity
2, use the equation you mentioned to predict the wall shear stress, which can be used for the momentum equation discretizations.

Is the above understanding correct? Thank you. I am working on the wall function implementations and thus would like to have these knowledge for my work. Thanks.

OFFO
openfoammaofnepo is offline   Reply With Quote

Old   April 7, 2014, 04:06
Default
  #27
Senior Member
 
romant's Avatar
 
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21
romant is on a distinguished road
Quote:
Originally Posted by openfoammaofnepo View Post
Dear Roman,

Thank you for your reply. In the practical CFD implementations, if we use cell centered finite volume method as is done in the OF, the velocity gradient is needed to calculate the numerical flux for the diffusion term in the momentum equations. Is this understanding correct?

Is the following line of reasoning correct:
1, use the log law or linear linear law to get the friction velocity
2, use the equation you mentioned to predict the wall shear stress, which can be used for the momentum equation discretizations.

Is the above understanding correct? Thank you. I am working on the wall function implementations and thus would like to have these knowledge for my work. Thanks.

OFFO
I think your first assumption is correct.

For the other parts:
1. you use the log law or the linear law to find the velocity in the first point away from the wall away from the grid, not he friction velocity. This velocity can then be used to calculate the wall shear stress as you know the velocity at the wall (either no slip, partial slip or whatever you define).

I describe here http://www.cfd-online.com/Forums/ope...-function.html how the nut wall function works, which is the wall function for the velocity. Since setting the velocity in the first point is a bad choice (it will be overwritten), setting a source on the wall strong enough to make the velocity in the first grid point exactly what you need it much better.

Take a look at the references given in the mentioned post and also in this thread. These are:
  • Pope, Turbulent Flows, 2000, pp 442-443
  • Versteeg and Malalasekera, An introduction to computational fluid dynamics: The finite volume method, pp. 276-277
They are very helpful when it comes to understanding wall function implementations and how wall functions work.
Bernhard likes this.
__________________
~roman
romant is offline   Reply With Quote

Old   April 7, 2014, 04:19
Default
  #28
Senior Member
 
RodriguezFatz's Avatar
 
Philipp
Join Date: Jun 2011
Location: Germany
Posts: 1,297
Rep Power: 27
RodriguezFatz will become famous soon enough
Manan, I thought about the same thing. As far as I understand it, this is done with the "boundaryManipulate" function, called before solving.
I found it in "src/finiteVolume/lnInclude/fvMatrix.C". It calls a "manipulateMatrix"-function for all the boundary patches. This function can be found in the wall function file. Here I am lost, because I don't know which of the functions (from which .C file) "setValues(...)" and "manipulateMatrix" is called. But this pretty much looks like the right spot!
Cheers,
Philipp.
__________________
The skeleton ran out of shampoo in the shower.
RodriguezFatz is offline   Reply With Quote

Old   April 7, 2014, 08:15
Default
  #29
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Dear Roman,

Thank you so much for your reply about the wall function implementations. Very helpful for me.

About the following:

Code:
1. you use the log law or the linear law to find the velocity in the first point away from the wall away from the grid, not he friction velocity.
My opinion is: the velocity at the first interior grid nodes (cell centroids if cell centered FVM is applied) is from the outer flow calculations like LES and RANS. The height of that nodes is always known. Having these two quantities and the law of wall (like log-law), we can get the friction velocity from iterative solutions of the law of wall.

Please directly point out if what I am saying is not correct.
Thank you.
OFFO
openfoammaofnepo is offline   Reply With Quote

Old   April 7, 2014, 09:01
Default
  #30
Senior Member
 
romant's Avatar
 
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21
romant is on a distinguished road
Quote:
Originally Posted by openfoammaofnepo View Post
Dear Roman,

Thank you so much for your reply about the wall function implementations. Very helpful for me.

About the following:

Code:
1. you use the log law or the linear law to find the velocity in the first point away from the wall away from the grid, not he friction velocity.
My opinion is: the velocity at the first interior grid nodes (cell centroids if cell centered FVM is applied) is from the outer flow calculations like LES and RANS. The height of that nodes is always known. Having these two quantities and the law of wall (like log-law), we can get the friction velocity from iterative solutions of the law of wall.

Please directly point out if what I am saying is not correct.
Thank you.
OFFO
Of course the velocity in the first interior grid point is calculated through the solution of the velocity field. In the law of the wall / or any other wall function, you would like to set the velocity in the first grid point, because you know the velocity in that point based on theory. This is where the extra source term for the calculations comes in, in the case of openfoam, this source term is inserted into the momentum equation through nut/mut at the wall, as mut/nut at the wall are generally zero, due to the fact that k is zero.

I am not sure what you mean with calculating the friction velocity, because it results directly from the solution without having to know the law of the wall. As the friction velocity is
u_{\tau}=\sqrt{\tau_w/\rho}
and
\tau_w=\mu \left( \frac{\partial u}{\partial y}\right)_{y=0}
where the last part can just be calculated from
\tau_w = \mu \left( \frac{u_P - u_w}{y_p} \right)

As you can see there is not need to calculate the shear velocity using the law of the wall and iterations
__________________
~roman
romant is offline   Reply With Quote

Old   April 7, 2014, 09:05
Default
  #31
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Ok, thanks. But in your line of reasoning, what did you mean by setting the velocity in the first grid point? Besides, how was the u_w obtained? I think if we calculate the tau_w directly from the third equations you provided, there will be some inaccuracies. Please comment if any. Thanks.
openfoammaofnepo is offline   Reply With Quote

Old   April 7, 2014, 09:11
Default
  #32
Senior Member
 
romant's Avatar
 
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21
romant is on a distinguished road
Quote:
Originally Posted by openfoammaofnepo View Post
Ok, thanks. But in your line of reasoning, what did you mean by setting the velocity in the first grid point? Thank you.
Wall functions predict the velocity in the first grid point based on theory. However, it is very hard to just prescribe the velocity in the first grid point and keep it fixed. In order to achieve the predicted velocity in the first grid point and not "fix" and thereby destabilize the differential equation (look at Pope, 2000 for this one), we generally introduce a source term, which in openfoam is introduced through the nut/mut wall function.
Bernhard likes this.
__________________
~roman
romant is offline   Reply With Quote

Old   April 7, 2014, 19:50
Default
  #33
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Thank you for your explanation, Roman.

In Openfoam, when we use wall function for both RANS and LES, the velocity at the walls are zero. So here the non-slip velocity is still applied. Can the slip velocity boundary conditions be used in Openfoam?

best regards,
OFFO
openfoammaofnepo is offline   Reply With Quote

Old   April 8, 2014, 03:42
Default
  #34
Senior Member
 
romant's Avatar
 
Roman Thiele
Join Date: Aug 2009
Location: Eindhoven, NL
Posts: 374
Rep Power: 21
romant is on a distinguished road
Hej,

when you take a look here http://www.openfoam.org/docs/cpp/ all the way at the bottom, there is a link to boundary conditions. It will take you to the boundary conditions that can be found in OpenFOAM togther (not the wall function, these are separate because they are part of the specific turbulence models). Take a look there. You can find wall boundary conditions and all the explanations how to use them, i.e. how to set them up in the variable files. Under wall boundaries there is something called a partial slip, and there should of course also be a complete slip (otherwise partial can be used as complete slip and no slip based on how large the partial slip is).
__________________
~roman
romant is offline   Reply With Quote

Old   December 18, 2016, 21:13
Question Wall Function Implementation in OpenFOAM
  #35
Senior Member
 
Crank-Shaft's Avatar
 
Ovi
Join Date: Oct 2012
Location: Sydney, Australia
Posts: 166
Rep Power: 14
Crank-Shaft is on a distinguished road
Hello OpenFOAM community,

I know I am reviving a very old thread, but I thought I'd try this before possibly starting a new thread.


I have recently started using OpenFOAM and have found all the different types of solvers, tools and post-processing utilities very useful and well documented. As a researcher in turbulence modelling, I am currently learning about and implementing wall functions for compressible RANS. Having explored the documentation and the source code, I've improved my understanding of the nutUSpaldingWallFunction. This is being used for the eddy-viscosity transport equation at the solid walls and I've decided to use a boundaryFoam solver to establish ideal boundary layers and assess the wall-function performance on coarse grids (30<y+<100) relative to fully-resolved fine grid results.

1) I want to get a clear understanding of the changes being made to the transport equations.

From my understanding, upon application of the nutUSpaldingWallFunction, a correction friction velocity is calculated from the Newton-Raphson solver, then the corrective eddy-viscosity is computed. So essentially, the velocity field should remain unchanged and there is a higher effective viscosity which is applied at the wall-adjacent cells to account for the lower velocity gradient (due to the coarser grid resolution) and thus achieve the corrected wall shear stress. Using the wallShearStress function I found that the results from y+ 30 grid with the wall-function being as close as 3-4% of the fully-resolved wall shear stress result and that is well within acceptable bounds especially for larger, industrial-scale problems.

From the source code, nutUSpaldingWallFunction.C this is the algorithm being used -
a) calcNut() requires corrections, since the user selected wall-function BC and the y+ lies within the accepted bounds of applicability.
b) \nu_{t} is calculated based on the flow variables and S-A transport equation as \nu_{t}=f_{v1}\tilde{\nu}. Additionally, corrections are to be made.
c) Wall-function corrections \nu_{t}=(u_{\tau})^{2}/(d{U}/d{y})-\nu.
d) The velocity field isn't affected by this but the value of u_{\tau} is taken from calcUTau and this is where the Newton-Raphson solver resides.
e) This new u_{\tau} is also used for the calculation of new y^{+} value.

2) Based on the above, how is the wall-function viscosity which is being computed from the u_{\tau} related to the eddy-viscosity in the S-A transport equation? Does anyone have a good academic reference for this?

From my understanding, the wall-function should only affect the first wall-adjacent cells and the flux calculation at the walls. The momentum terms require \nu+\nu_{t} and after the wall-function is applied, is it basically \nu+\nu_{t}+\nu_{WF}?

I am interested in the shear stress and also the force coefficients which are calculated from solid walls.
Attached Files
File Type: c nutUSpaldingWallFunctionFvPatchScalarField.C (6.3 KB, 13 views)
__________________
--
Mechanical Engineering
Sydney, Australia


Crank-Shaft is offline   Reply With Quote

Old   December 27, 2016, 22:43
Default
  #36
Senior Member
 
Crank-Shaft's Avatar
 
Ovi
Join Date: Oct 2012
Location: Sydney, Australia
Posts: 166
Rep Power: 14
Crank-Shaft is on a distinguished road
Hey everyone,

Can someone please direct me to some resources which describe the theory behind implementation of this nutUSpaldingWallFunction?

Any assistance is greatly appreciated.

Thank you
__________________
--
Mechanical Engineering
Sydney, Australia


Crank-Shaft is offline   Reply With Quote

Old   July 17, 2017, 11:01
Default
  #37
New Member
 
Martin
Join Date: Oct 2013
Location: Newcastle
Posts: 21
Rep Power: 13
mahtin360 is on a distinguished road
Hi Ovi,
did you get any more information on the specifics of this wall function?

Regards,
Martin
mahtin360 is offline   Reply With Quote

Old   July 19, 2017, 01:55
Default
  #38
Senior Member
 
Crank-Shaft's Avatar
 
Ovi
Join Date: Oct 2012
Location: Sydney, Australia
Posts: 166
Rep Power: 14
Crank-Shaft is on a distinguished road
Quote:
Originally Posted by mahtin360 View Post
Hi Ovi,
did you get any more information on the specifics of this wall function?

Regards,
Martin
Hey Martin,

I just used a combination of looking at the source code, reading the entry in the online OpenFOAM documentation and running appropriate 1D boundary layer profiles using incompressible/boundaryFoam/ to understand how the wall-function which results in a modified friction velocity can be incorporated into the near-wall cells to correct the shear stresses. However, I am not entirely clear about how this affects the eddy-viscosity terms.
__________________
--
Mechanical Engineering
Sydney, Australia


Crank-Shaft is offline   Reply With Quote

Old   August 12, 2017, 17:36
Default
  #39
Member
 
Amir
Join Date: Jan 2017
Posts: 32
Rep Power: 9
albet is on a distinguished road
Hi Foamers,

I have a question about the standard wall function.
I read that at high Reynolds number in the closest cell to the wall we should calculate the k by this equation:

k= sqr (utau)/Cmu25

but I have seen that everywhere it is recommended to use

kqRWallFunction

that in fact gives the zeroGradient boundary condition.

Maybe my question is completely wrong but could anybody help me to understand this?

Regards,
Amir
albet is offline   Reply With Quote

Old   October 10, 2018, 12:03
Default
  #40
New Member
 
meihuazhang
Join Date: Oct 2018
Posts: 8
Rep Power: 8
meihua is on a distinguished road
Quote:
Originally Posted by openfoammaofnepo View Post
Dear Roman,

Thank you for your reply. In the practical CFD implementations, if we use cell centered finite volume method as is done in the OF, the velocity gradient is needed to calculate the numerical flux for the diffusion term in the momentum equations. Is this understanding correct?

Is the following line of reasoning correct:
1, use the log law or linear linear law to get the friction velocity
2, use the equation you mentioned to predict the wall shear stress, which can be used for the momentum equation discretizations.

Is the above understanding correct? Thank you. I am working on the wall function implementations and thus would like to have these knowledge for my work. Thanks.

OFFO
I think the above thinking is correct. But I have a question, how to apply the wall shear stress into the momentum equation discretizations as a boundary condition?
meihua 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
UDF Wall functions in Fluent syler3321 Fluent UDF and Scheme Programming 2 September 20, 2014 13:37
Water subcooled boiling Attesz CFX 7 January 5, 2013 04:32
wall functions and boundary conditions in OF 1.7.1 cristobal OpenFOAM 2 May 6, 2011 05:10
UDF for wall slipping HFLUENT Fluent UDF and Scheme Programming 0 April 27, 2011 13:03
k-omega simulation without wall functions vkrastev OpenFOAM 2 January 24, 2010 18:45


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