
[Sponsors] 
August 7, 2013, 10:43 
implementing a new wall function

#1 
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 12 
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.
__________________
~roman 

April 8, 2014, 11:00 

#2 
Senior Member
Join Date: Jan 2013
Posts: 284
Rep Power: 6 
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? OFFO 

April 8, 2014, 12:57 

#3 
Senior Member
Join Date: Jan 2013
Posts: 284
Rep Power: 6 
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/OpenFOAM2.1.x/blob/master/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutUSpaldingWallFunction/mutUSpaldingWallFunctionFvPatchScalarField.C 1, in the above source files I quoted, what does the following quantity magUp stand for? Code:
scalarField magUp(mag(Uw.patchInternalField()  Uw)); Code:
const scalarField magGradU(mag(Uw.snGrad())); Any comments are welcome. OFFO 

April 9, 2014, 02:47 

#4  
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 12 
Quote:
__________________
~roman 

April 9, 2014, 02:56 

#5  
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 12 
Quote:
__________________
~roman 

April 9, 2014, 16:46 

#6 
Senior Member
Join Date: Jan 2013
Posts: 284
Rep Power: 6 
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 cellcentered 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 intercell face (and of course also the mu and mut at the intercell 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 nearwall 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 

April 9, 2014, 16:49 

#7  
Senior Member
Join Date: Jan 2013
Posts: 284
Rep Power: 6 
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:


April 10, 2014, 02:54 

#8  
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 12 
Quote:
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.
__________________
~roman 

April 10, 2014, 12:11 

#9  
Senior Member
Join Date: Jan 2013
Posts: 284
Rep Power: 6 
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:


April 11, 2014, 04:54 

#10 
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 12 
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.
__________________
~roman 

August 18, 2015, 11:51 

#11 
New Member
Nihar
Join Date: Oct 2014
Posts: 8
Rep Power: 3 
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 

August 19, 2015, 08:49 

#12 
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 12 
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.
__________________
~roman 

September 7, 2015, 11:53 

#13  
Member
Xinguang Wang
Join Date: Feb 2015
Posts: 31
Rep Power: 3 
Quote:
When I look into the code of kEpsilon.C, I find that only alphat, mut, epsilon have the code of correct the value using wall function, like this:mut_.correctBoundaries(). However, it is hard to find any clue about k, which has different types in the kWallFunction folder. Does it mean that k wall function is not used in solving kEpsilon turbulence modeling? I know that the epsilon and production term in the epsilon wall function have the influence of solving k equations, but the code in kWallFunction do not include in the program, and in the 0 folder, we have to choose a wall function for k. It looks so strange. Thanks 

September 8, 2015, 03:49 

#14  
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 12 
Hi Jason,
the k wall function sets a value at the boundary, which means that the value in the first cell is untouched. It also does not use any values from the first cell to calculate the value k, which by the way is 0. However, nut and epsilon use values from the first cell, and or set values in the first cells, which is why the correction functions from the wallFunction class need to be called. It has to do with the order in which we calculate different values. For example, 1. Update values of epsilon and G in the first cell 2. Solve the epsilon balance equation 3. Solve the k balance equation 4. calculate nut everywhere 5. Correct nut at the wall based on velocity, k and epsilon in the first cell. Quote:
__________________
~roman 

September 8, 2015, 06:01 

#15  
Member
Xinguang Wang
Join Date: Feb 2015
Posts: 31
Rep Power: 3 
Quote:
Thanks for your reply. In the standard wall function, k is assumed to be constant across the nearwall fully turbulence region, and k_v = k_P( the first node, this formula is used in the epsilon wall function). It is sure that k=0 at the wall, however in some more advanced wall functions, k has a distribution, e.g. twolayer model, k=k_v(y/y_v)^2 when y<y_v, and k=by+a when y>y_v. If I want to add this type of wall function in the code, do I need to add k_correctBoundary in the code, or I just need to change the epsilon wall function, where epsilon and production are modified near the wall, which then have influence to the kequation? I think the second way is better, because, as you mentioned above, k=0 at the wall and the distribution of k in the first cell result in the change of epsilon and production term. Hopefully, you can understand what I said. Regards, Jason 

September 8, 2015, 06:42 

#16 
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 12 
Hi Jason,
I understand what you mean. I haven't looked at it in a while, so I am not sure if you have to run this. I suggest you look into the velocity equations, maybe k boundaries are updated there? Otherwise, you might have to make a small diagram and see where which boundary is updated. It shouldn't take too long. If this doesn't work out, there is always the option to program it and you add an echo or similar to the location where the update should occur and see if the part of the code is reached at any point.
__________________
~roman Last edited by romant; September 8, 2015 at 06:43. Reason: spelling 

September 8, 2015, 10:47 

#17  
Member
Xinguang Wang
Join Date: Feb 2015
Posts: 31
Rep Power: 3 
Quote:
what do you mean velocity equations? Do you mean momentum equations? When I look into the code, after solving the momentum equations, there is such code: U.correctBoundaryConditions, then this refer to fixedValueFvPatchField at the wall. However, in this code, there is no clue of k. For my understanding, if it refer to a wall boundary condition, and wall function is used, the first cell of velocity should be modified. But I can not find anything in the code about this. Thanks a lot for your suggestion. Jason 

September 8, 2015, 15:21 

#18 
Senior Member
Roman Thiele
Join Date: Aug 2009
Location: Stockholm, Sweden
Posts: 366
Rep Power: 12 
Hej Jason,
the velocity is not modified in the first cell, because this might introduce instabilities in the equations. instead we use mut or nut to introduce a shear force at the wall which is large enough to created the value of U which we want to introduce in the first cell. please take a look at http://www.cfdonline.com/Forums/ope...tml#post452744 for some information on this. The whole thread could be of interest to you.
__________________
~roman 

September 9, 2015, 07:22 

#19  
Member
Xinguang Wang
Join Date: Feb 2015
Posts: 31
Rep Power: 3 
Quote:
Thank you for your reply. I did some numerical experiment, in which only the k BC is changed, the numerical results shows that the choice of the k wall function do influence the results. Jason 

September 9, 2015, 22:34 

#20 
Senior Member
Huang Xianbei
Join Date: Sep 2013
Location: CAU,China
Posts: 277
Rep Power: 5 
Hi,Roman:
Could you please take a look at my wall function? I implemented a wall function to modify the velocity nearwall. However, no change is seen during the calculation, I don't know why. Could you give me some advice? Xianbei 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Radiation interface  hinca  CFX  15  January 26, 2014 18:11 
Compile problem  ivanyao  OpenFOAM Running, Solving & CFD  1  October 12, 2012 09:31 
channelFoam for a 3D pipe  AlmostSurelyRob  OpenFOAM  3  June 24, 2011 13:06 
Axisymmetrical mesh  Rasmus Gjesing (Gjesing)  OpenFOAM Native Meshers: blockMesh  10  April 2, 2007 14:00 
Quick Question  Wall Function  D.Tandra  Main CFD Forum  2  March 16, 2004 05:29 