Sunteți pe pagina 1din 35

Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.

0 New Wall Functions Implementation Case Test

Implementation of a Complete Wall Function


for the Standard k- Turbulence Model
in OpenFOAM 4.0

Shengnan Liu

Offshore Technology,
Department of Mechanical and Structural Engineering and Materials Science
University of Stavanger,
Stavanger, Norway

2016-12-05

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 1 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Contents

Introduction on Near-wall Physics

Wall Function Implementation for Standard k  Model in


OpenFOAM 4.0

New Wall Function Implementation for Standard k  Model in


OpenFOAM 4.0

Test Cases (Verification)

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 2 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

1 Introduction on Near-wall Physics

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 3 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Influence of the wall


Wall effects are common seen in practical flows such as channel flow, pipe
flow and flow around all kinds of structures. Some effects of the wall are
shown here.
Low Reynolds number - the turbulence Reynolds number
Rel = k 2 /(v) decreases as the wall is approached.

High shear rate - the highest mean shear rate < U >/y occurs at
the wall. The velocity changes from the no-slip condition at the wall
to its stream value.

Wall blocking - the impermeability condition V=0 (at y=0) is


considered and it affects the boundary layer flow.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 4 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Near Wall Treatment


In numerical simulation, two ways can be chosen for wall treatment.
DNS resolves eddies in all
scales. It required very
fine mesh in the near-wall
region so that it can be
integrated.

RANS and LES involve


the model to simplify the
simulation. They
introduce the wall
http://www.bakker.org/dartmouth06/engs150/10rans.pdf
function to give first layer
cell information.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 5 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Wall Function Profile

Linear viscous
sub-layer (y + < 5)-
Dominated by
viscous shear
Buffer layer
(5 < y + < 30) -
Mix of viscous layer
and inertial layer
Log-law layer
(30 < y + < 100) -
Both viscous and
Wall functions for different layers turbulent effects are
y + = (u y)/; u+ = u/u , important
http://www.computationalfluiddynamics.com.au/tag/wall-functions/

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 6 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Viscous Layer (y + < 5)

The fluid very close to the wall is dominated by viscous shear in absence of
the turbulent shear stress effects. In this region u+ = y + , T = f C k 2 /
(Jones and Launder (1972) ), f = 1 exp(0.0002y + 0.00065y +2 )
(Rodi and Mansour (1993) ), the following equation set is used in the
viscous near wall region:

y = u y/
+


+
u = u/u



u+ = y +


(1)
k = u2 / C
p



 = C3/4 k 3/2 /y






T = f C k 2 /

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 7 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Buffer Layer (5 < y + < 30)


The intersection of viscous and log-law wall funnction is at y + = 11. That
is, y + < 11 linear approximation is more accurate and after y + > 11 the
logarithmic approximation works better. Considering both the linear and
logarithmic approximation by a weighting factor = (y + 5)/25 (Ong et
al., (2009)).The equation set is:

y = u y/
+


u+ = u/u






1
u+ =



( ln(Ey+ ) ) + ( 1

y+
) (2)
2
p



k = u / C

 = C3/4 k 3/2 /y





T = f C k 2 /

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 8 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Log-law Layer (30 < y + < 100)

In this region viscous and turbulent effects are both important. The
relationship between y + and u+ is logarithmic, the equation set to be used
in the log-law region is:

y = u y/
+


u+ = u/u






u+ = 1 ln(Ey + )



p (3)
2



k = u / C

 = C3/4 k 3/2 /y





T = f C k 2 /

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 9 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

3 Wall Functions Implementation


for Standard k  Turbulence
Model in OpenFOAM 4.0

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 10 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Overview on k  model
The k  belongs to the two-equation models(Launder and Spalding
(1972); Rodi (1993)).

k k T k ui uj ui
+ uj = ( ) + T ( + )  (4)
t xj xj k xj xj xi xj
  T   ui uj ui 2
+ uj = ( ) + C1 T ( + ) C2 (5)
t xj xj  xj k xj xi xj k
Model transport equations are solved for two turbulence quantities.
Turbulent kinetic energy k, which determines the energy in the
turbulence.
Turbulent dissipation , which determines the rate of dissipation of
the turbulent kinetic energy.
The turbulent viscosity is specified as T = C k 2 / and C1 = 1.44,
C2 = 1.92, C = 0.09, k = 1.0,  = 1.3.
Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 11 / 35
Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

k  turbulence model code in OpenFOAM 4.0

The k  turbulence calculation process is:


Calculate turbulent kinetic energy production term G by
epsilon .boundaryFieldRef().updateCoeffs() and correct the value of
G at first layer mesh by updateCoeffs() function of .
With the updated G, the  equation is revised by
epsEqn.ref().boundaryManipulate(epsilon .boundaryFieldRef()); .
Solve  equation and obtain the updated  field.
Solve k equation using the new , and k field is renewed.
Calculate T , and update the T at wall by correctNut();.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 12 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

k wall functions in OpenFOAM 4.0


kqRWallFunction is used for high Reynolds numbers and
kLowReWallFunction can be used for both low Reynolds numbers and high
Reynolds numbers.

Type name kqRWallFunction kLowReWallFunction


Available scope
Log-law region Viscous and log-law region
(first layer cell)
Foam::kqRWallFunction- Foam::kLowReWall-
Class
FvPatchField FunctionFvPatchField
Foam::zeroGradient Foam::fixedValue
Inherit from
FvPatchField FvPatchField
Other references zeroGradient fixedValue
Table: Available k wall functions in OpenFoam 4.0

* new k wall function is modified based on this

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 13 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Code framework of kLowReW allF unction in OpenFOAM 4.0

yPlusLam function is used to calculate the


intersection of viscous layer and log-law layer

updateCoeffs() is the main function of calculating


k.

(Ck /ln(y + ) + Bk ) C kc ,
p

y + > yP lusLam
kw = { (6)
2400 Cf /Ce2 ps2 C kc ,
p

y + < yP lusLam
Code Framework

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 14 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

 wall functions in OpenFOAM 4.0


epsilonWallFunction is used for high Reynolds numbers and
epsilonLowReWallFunction can be used for both low Reynolds numbers
and high Reynolds numbers.

Type name epsilonWallFunction epsilonLowReWallFunction


Available scope
Log-law region Viscous and log-law region
(first layer cell)
Foam::epsilonWallFunction- Foam::epsilonLowReWall-
Class
FvPatchField FunctionFvPatchField
PN C 3/4 k3/2
PN C 3/4 k3/2 c = N1 f =i ( yic )
Formula c = N1 f =i ( yic ) PN c
c = N1 f =i ( 2ky2 )
i
Foam::fixedInternalValue- Foam::epsilonWallFunction-
Inherit from
FvPatchField FvPatchScalarField
Table: Available epsilon wall functions in OpenFoam 4.0

* new epsilon wall function is modified based on this


Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 15 / 35
Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Code framework of epsilonW allF unction in OpenFOAM 4.0

setMaster function will set all


the near wall cell as
master(value is 1), if it is master
cell, then wall function is used,
else it will call turbulence
internal function to calculate G
and epsilon and then update the
coefficient.
If not, it will call turbulence
internal function to calculate G
and epsilon and then update the
coefficient.
Code Framework

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 16 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

nut wall functions in OpenFOAM 4.0

There are many T wall functions in OpenFOAM 4.0 which are all based
on one virtual base class nutWallFunction.

Calculate from U k
nutUWallFunction nutkWallFunction
nutURoughWallFunction nutkRoughWallFunction
Type name
nutUSpaldingWallFunction nutLowReWallFunction
nutUTabWallFunction nutkAtmRoughFunction
Table: Available T wall functions in OpenFoam 4.0

* new nut wall function is modified based on this

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 17 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Code framework of nutkW allF unction in OpenFOAM 4.0

The value of nut is calculated in


calcNut();
y +
T = ( ln(Ey + ) 1)

Then nut will be return back to


updateCoeffs().

Code Framework

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 18 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

4 New Wall Functions Implementation for


Standard k  Turbulence Model in
OpenFOAM 4.0

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 19 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Modifications to existing wall functions

The new implemented wall functions are built based on Ong et al. (2009)
(i.e. Ong wall function), code are modified based on kLowReWallFunction,
epsilonWallFunction and nutkWallFunction.

Here list the basic process of modification.


Change work directory to wall function directory.
Copy the required wall function files in the same folder.
Modify the .C and .H files.
Compile the library.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 20 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Modifications to k wall function

Change the .H and .C files names to the new wall function names.
Change all the key words from kLowReW allF unction to
kOngW allF unction.
Define two member functions to calculate u in buffer layer and
log-law region.
Modify updateCoeffs(), set k to three section functions according to
y+.
Save files.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 21 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Equations used in calcUTau

Eyu u
f 2(u ) = exp( ) = 0 (y + > 30) (7)
u

The apply Newton iteration to f2,

f 2(un )
un+1 = un
f 20 (un )
(8)
Ey u u
f 20 (un ) = + 2 exp( )
un un

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 22 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Equations used in calcUTau2

(yu / 5)yu / (30 yu /)ln(Eyu /)


f 1(u ) =
25yu /ln(Eyu /)

(9)
u
(5 <= y + <= 30)
u
The apply Newton iteration to f1,

f 1(un )
un+1 = un
f 10 (un )
(2yun / 5 + ln(Eyun /))y (30 yun /)
f 10 (un ) =
25(yun /)un ln(Eyun /)
((5 yun /)yun / + (30 yun /)ln(Eyun /))(y + ln(Eyun /)y) 1

25(yun /ln(Eyun /))2 u
(10)

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 23 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Modifications to epsilon wall function

The  expression in epsilonOngWallFunction is the same with which in


epsilonWallFunction. So the epsilonOngWallFunction is just a simple
wrapper of epsilonWallFunction.
Change the .H and .C files names to the new wall function names.
Change all the key words from epsilonW allF unction to
epsilonOngW allF unction.
Save files.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 24 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Modifications to nut wall function

The main modification to nut is the calculation equation of nut.


Change the .H and .C files names to the new wall function names.
Change all the key words from nutkW allF unction to
nutOngW allF unction.
Modify the main function calcNut(), change the nut expression to:
T = f C k 2 /
f = 1 exp(0.0002y + 0.00065y +2 )
Save files.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 25 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Compile new wall functions


First change the working directory to turbulenceModels/Make:
cd $FOAM_SRC/TurbulenceModels/turbulenceModels/Make
Open the files file, add the following statement inside under the
wallFunctions = derivedFvPatchFields/wallFunctions accordingly.
$(nutWallFunctions)/nutOngWallFunction\
/nutOngWallFunctionFvPatchScalarField.C
$(epsilonWallFunctions)/epsilonOngWallFunction\
/epsilonOngWallFunctionFvPatchScalarField.C
$(kqRWallFunctions)/kOngWallFunction\
/kOngWallFunctionFvPatchScalarField.C
Then change the last line LIB =
$(FOAM LIBBIN)/libturbulenceModels to LIB = $(FOAM USER
LIBBIN)/ libturbulenceModels

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 26 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Compile new wall functions

Touch the change of wall functions:


Compile the turbulence model by the following commands.
cd $FOAM_SRC/TurbulenceModels
wmake libso turbulenceModels/derivedFvPatchFields
/wallFunctions/nutWallFunctions/nutOngWallFunction
wmake libso turbulenceModels/derivedFvPatchFields\
/wallFunctions/kqRWallFunctions/kOngWallFunction
wmake libso turbulenceModels/derivedFvPatchFields/wall\
Functions/epsilonWallFunctions/epsilonOngWallFunction
./Allwmake
After compiling successfully, restart the terminal window and prepare
for the case Test.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 27 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

5 Test Cases (Verification)

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 28 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Test Case 1

The main improvement of Ong wall function is including the buffer layer
inside. Set first layer cell in the buffer layer.

Figure: Test case set up

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 29 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Results of Case 1
Use simpleF oam for the simulation. Results are shown as follows.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 30 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Test Case 2
Set first layer cell in buffer layer. Set fully developed boundary layer flow
(can be calculted according to the Ong wall function equations) on the
inlet pathes, and compare the velocity profile of inlet and outlet.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 31 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Test Case 2
The nonuniform setting for U , k,  and T are required in 0 folder. In
addition, boundaryData folder is required in constant folder. The inlet
velocity pofile calculated from Ong wall function is shown in Figure 4.

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 32 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Test Case 2

The inlet setting for k,  and T are based on Ong et al., (2010) :

k = max{C( 1/2)(1 y/y f )2 u2 , 0.0001U


2
}
C (3/4)ky 3/2
= (11)
l
k 2
T = C

where U is the velocity of infinity. y f is the height of first layer cell. The
expression of l is:

l = min{ky(1 + 3.5y/y f )1 , C y} (12)

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 33 / 35


Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Test Case 2
The results show that the Ong wall functions keep the velocity profile
stable. The new wall function is developed successfully.

Shengnan Liu Figure: Inlet and outlet velocity profile


New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 34 / 35
Introduction on Near-wall Physics Wall Functions in OpenFOAM 4.0 New Wall Functions Implementation Case Test

Many Thanks to Prof. Hakan Nilsson, Prof. Muk Chen Ong


and All of You!

Questions?

Shengnan Liu New Wall Function Implementation in OpenFOAM 4.0 2016-12-05 35 / 35

S-ar putea să vă placă și