# Wall functions - questions about implementation

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

September 20, 2013, 08:22
#21
Senior Member

Roman Thiele
Join Date: Aug 2009
Location: London, UK
Posts: 368
Rep Power: 14
Quote:
 Originally Posted by RodriguezFatz 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 08:24. Reason: books added

April 5, 2014, 04:40
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: 6
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?

 April 5, 2014, 10:08 #23 Senior Member   Join Date: Jan 2013 Posts: 344 Rep Power: 8 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

April 5, 2014, 17:28
#24
Senior Member

Roman Thiele
Join Date: Aug 2009
Location: London, UK
Posts: 368
Rep Power: 14
Quote:
 Originally Posted by openfoammaofnepo 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

where is the the wall shear stress calculated from

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.
__________________
~roman

April 5, 2014, 17:48
#25
Senior Member

Roman Thiele
Join Date: Aug 2009
Location: London, UK
Posts: 368
Rep Power: 14
Quote:
 Originally Posted by MaLa 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

 April 5, 2014, 18:27 #26 Senior Member   Join Date: Jan 2013 Posts: 344 Rep Power: 8 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

April 7, 2014, 03:06
#27
Senior Member

Roman Thiele
Join Date: Aug 2009
Location: London, UK
Posts: 368
Rep Power: 14
Quote:
 Originally Posted by openfoammaofnepo 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.
__________________
~roman

 April 7, 2014, 03:19 #28 Senior Member     Philipp Join Date: Jun 2011 Location: Germany Posts: 1,297 Rep Power: 20 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.

 April 7, 2014, 07:15 #29 Senior Member   Join Date: Jan 2013 Posts: 344 Rep Power: 8 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

April 7, 2014, 08:01
#30
Senior Member

Roman Thiele
Join Date: Aug 2009
Location: London, UK
Posts: 368
Rep Power: 14
Quote:
 Originally Posted by openfoammaofnepo 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

and

where the last part can just be calculated from

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

 April 7, 2014, 08:05 #31 Senior Member   Join Date: Jan 2013 Posts: 344 Rep Power: 8 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.

April 7, 2014, 08:11
#32
Senior Member

Roman Thiele
Join Date: Aug 2009
Location: London, UK
Posts: 368
Rep Power: 14
Quote:
 Originally Posted by openfoammaofnepo 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.
__________________
~roman

 April 7, 2014, 18:50 #33 Senior Member   Join Date: Jan 2013 Posts: 344 Rep Power: 8 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

 April 8, 2014, 02:42 #34 Senior Member     Roman Thiele Join Date: Aug 2009 Location: London, UK Posts: 368 Rep Power: 14 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

December 18, 2016, 21:13
Wall Function Implementation in OpenFOAM
#35
Senior Member

Ovi
Join Date: Oct 2012
Location: Sydney, Australia
Posts: 161
Rep Power: 7
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 () 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 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 lies within the accepted bounds of applicability.
b) is calculated based on the flow variables and S-A transport equation as . Additionally, corrections are to be made.
c) Wall-function corrections .
d) The velocity field isn't affected by this but the value of is taken from calcUTau and this is where the Newton-Raphson solver resides.
e) This new is also used for the calculation of new value.

2) Based on the above, how is the wall-function viscosity which is being computed from the 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 and after the wall-function is applied, is it basically ?

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

 December 27, 2016, 22:43 #36 Senior Member     Ovi Join Date: Oct 2012 Location: Sydney, Australia Posts: 161 Rep Power: 7 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

 July 17, 2017, 10:01 #37 New Member   Martin Join Date: Oct 2013 Location: Newcastle Posts: 19 Rep Power: 6 Hi Ovi, did you get any more information on the specifics of this wall function? Regards, Martin

July 19, 2017, 00:55
#38
Senior Member

Ovi
Join Date: Oct 2012
Location: Sydney, Australia
Posts: 161
Rep Power: 7
Quote:
 Originally Posted by mahtin360 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

 August 12, 2017, 16:36 #39 New Member   Amir Join Date: Jan 2017 Posts: 13 Rep Power: 3 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

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post syler3321 Fluent UDF and Scheme Programming 2 September 20, 2014 12:37 Attesz CFX 7 January 5, 2013 04:32 cristobal OpenFOAM 2 May 6, 2011 04:10 HFLUENT Fluent UDF and Scheme Programming 0 April 27, 2011 12:03 vkrastev OpenFOAM 2 January 24, 2010 18:45

All times are GMT -4. The time now is 22:36.