wall function implementation, k-epsilon

Miscellaneous discussion topics about Code_Saturne (development, ...)
Post Reply
Ionut G
Posts: 27
Joined: Fri Apr 20, 2018 2:43 pm

wall function implementation, k-epsilon

Post by Ionut G » Fri Apr 27, 2018 10:06 am

Hello,

I want to use a different wall function model, other than the ones that are implemented in Code_saturne, for the velocity field for the k-epsilon turbulence model.
Where I can find a template or a guide how to implement user defined wall functions in Code_saturne?

Thank you,
Ionut

Jean-Francois Wald
Posts: 8
Joined: Fri Apr 27, 2018 2:33 pm

Re: wall function implementation, k-epsilon

Post by Jean-Francois Wald » Fri Apr 27, 2018 3:18 pm

Dear Ionut

There are currently no dedicated user files that enables the user to prescribe user defined wall functions.
It is however possible to modify a wall function or even to add one through sources.

Wall boundary conditions are set in the clptur.f90 file that you 'll find in the src/base directory.
Boundary conditions for the turbulent quantities ( / ) are defined in this routine for each turbulence model.
Turbulence model in the sources are set through the keyword iturb and itytur = iturb / 10.
In your case, the - corresponds to iturb = 20 or 21 (depending if you selected Linear Production or not) and itytur = 2. Looking for tests on those criteria will guide you straight to those BCs.

In this file you'll also find a call to the wall function subroutine

Code: Select all

call wallfunctions                                         &
  ( iwallf, ifac  ,                                        &
    xnuii , xnuit , utau  , distbf, roughness, rnnb, ek,   &
    iuntur, nsubla, nlogla,                                &
    uet   , uk    , yplus , ypup  , cofimp, dplus )
This routine, described in the cs_wallfunctions.c and cs_wallfunctions.h files of the src/base directory, set the boundary conditions for the velocity with or without wall functions. The keyword iwallf passed as an argument contains the information on which wall function should be used :
= 0: no wall functions
= 1: one scale friction velocities (power law)
= 2: one scale friction velocities (log law)
= 3: two scales friction velocities (log law)
= 4: two scales friction velocities (scalable wall functions)
= 5: two scales friction velocities (based on V. Driest analysis)
= 6: two scales rough/smooth wall functions

At this stage, you can either add your own wall function by adding an other routine/iwallf or directly modify the routine you are using (for example if you're using two scales friction velocities - default ones for k-eps models, iwallf = 3 - directly modify the corresponding routine in the cs_wallfunctions.h file).

Jean-Francois

Ionut G
Posts: 27
Joined: Fri Apr 20, 2018 2:43 pm

Re: wall function implementation, k-epsilon

Post by Ionut G » Mon Apr 30, 2018 11:28 am

Thank you very much for the explanation.

I tried to search for the clptur.f90 or the src/base directory, but I could not find them. I need to install some source codes?
I use Code_saturne 5.0.7 on Windows 10 64bit.

If I will write the code in the case directory/SRC folder, will it be taken into account rather than the code that is already implemented in Code_saturne?

Thank you,
Ionut

Jean-Francois Wald
Posts: 8
Joined: Fri Apr 27, 2018 2:33 pm

Re: wall function implementation, k-epsilon

Post by Jean-Francois Wald » Mon Apr 30, 2018 1:42 pm

Dear Ionut,

I'm not familiar with the Windows versions of Code_Saturne.
When dealing with code modification going beyond modification of user subroutine, installing the code through sources (under Linux) and then re-compile/re-build the sources with those advanced modifications is usually preferred.

However, as you mentioned, any Fortran or C file present in the case directory/SRC are compiled. This is also true if you place here source files that are already present in the original sources. So putting here your modified clptur.f90 should do the trick.

Sources are not present in the Program Files/Code_Saturne directory when you install it on Windows but you can get the sources you need via the Code_Saturne github repository.

Jean-François

Ionut G
Posts: 27
Joined: Fri Apr 20, 2018 2:43 pm

Re: wall function implementation, k-epsilon

Post by Ionut G » Wed May 02, 2018 6:32 pm

Thank you very much, Jean-François for the support.

Is there a way to access the pressure gradient from inside the "cs_wall_functions.h"?
I need it to calculate the streamwise pressure gradient (in the flow direction), and some other variables like wall shear stress, dynamic viscosity, density etc, I guess I have to add some headers.

Thank you,
Ionut

Jean-Francois Wald
Posts: 8
Joined: Fri Apr 27, 2018 2:33 pm

Re: wall function implementation, k-epsilon

Post by Jean-Francois Wald » Thu May 03, 2018 8:15 am

Fluid properties such as dynamic viscosity are already passed as argument to the wallfunctions subroutine and are thus accessible in the "cs_wall_functions.h".

I assume you're trying to implement wall functions similar to the UMIST analytical wall functions from Craft et al. (2002) which requires additional terms like convection or pressure gradient at wall cells ?

The easiest way to do that is to compute all the needed variables in the clptur routine and add them as arguments in the wallfunctions routine. Be careful to also change the arguments of the wallfunctions routine in the cs_wall_functions.c/.h which contains the Fortran/C wrapper. Once you've done that, all your desired variables will be accessible in the cs_wall_functions.h file.

Jean-François

Ionut G
Posts: 27
Joined: Fri Apr 20, 2018 2:43 pm

Re: wall function implementation, k-epsilon

Post by Ionut G » Thu May 03, 2018 11:54 am

Jean-Francois Wald wrote:
Thu May 03, 2018 8:15 am
Fluid properties such as dynamic viscosity are already passed as argument to the wallfunctions subroutine and are thus accessible in the "cs_wall_functions.h".

I assume you're trying to implement wall functions similar to the UMIST analytical wall functions from Craft et al. (2002) which requires additional terms like convection or pressure gradient at wall cells ?

The easiest way to do that is to compute all the needed variables in the clptur routine and add them as arguments in the wallfunctions routine. Be careful to also change the arguments of the wallfunctions routine in the cs_wall_functions.c/.h which contains the Fortran/C wrapper. Once you've done that, all your desired variables will be accessible in the cs_wall_functions.h file.

Jean-François
Thank you for your help.

I am trying to implement a wall function developed by Manhart et al. (2008), which requires the pressure gradient in the streamwise direction of the flow.
In the clptur.f90 routine, the pressure gradient is already defined and can be accessed trough a function or it needs to be calculated?

Thank you,
Ionut

Post Reply