theory

Download theory

If you can't read please download the document

Upload: mina-ya-alimadad

Post on 29-Jun-2015

215 views

Category:

Documents


6 download

TRANSCRIPT

EDF R&D

Fluid Dynamics, Power Generation and Environment Department Single Phase Thermal-Hydraulics Group 6, quai Watier F-78401 Chatou Cedex Tel: 33 1 30 87 75 40 Fax: 33 1 30 87 79 16

FEBRUARY 2010

Code Saturne documentation Code Saturne 2.0.0-rc1 Theory and Programmers Guide

contact: [email protected]

http://www.code-saturne.org/

c EDF 2010

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 2/312

ABSTRACT

Code Saturne solves the Navier-Stokes equations for 2D, 2D axisymmetric, or 3D, steady or unsteady, laminar or turbulent, incompressible or dilatable ows, with or without heat transfer, and with possible scalar uctuations. The code also includes a Lagrangian module, a semi-transparent radiation module, a gas combustion module, a coal combustion module, an electric module (Joule eect and electric arc) and a compressible module. In the present document, the gas combustion, coal combustion, electric and compressible capabilities of the code will be referred to as particular physics. The code uses a nite volume discretization. A wide range of unstructured meshes, either hybrid (containing elements of dierent types) and/or non-conform, can be used. This document constitutes the theory and developers guide associated with the kernel of Code Saturne. Combustion, electric and compressible modules are also presented. To make the documentation immediately suitable to the developers needs, it has been organized into sub-sections corresponding to the major steps of the algorithm and to some important subroutines of the code. In each sub-section (for each subroutine), the function of the piece of code considered is indicated. Then, a description of the discretisation follows. Finally, and more oriented towards the developers, details of the implementation are provided and a list of open problems is given (improvements, limitations...). To make it easier for the developers to keep the documentation up to date during the development process, the les have been associated physically with the release of the code (each release of the code includes a directory containing the whole documentation). In practice, the users of Code Saturne can access the documentation at the following location $CS HOME/doc/NOYAU/. The general command info cs [theory] also provides this information. Code Saturne is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Code Saturne is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

SOMMAIRE

I

Introduction

5

II1- Sous-programme bilsc2 2- Sous-programme clptur 3- Sous-programme clptrg 4- Sous-programme clsyvt 5- Sous-programme codits 6- Sous-programme condli 7- Sous-programme covo 8- Sous-programme gradmc 9- Sous-programme gradrc 10- Sous-programme inimas 11- Sous-programme itrmas/itrgrp 12- Sous-programme matrix 13- Sous-programme navsto 14- Sous-programme preduv 15- Sous-programme recvmc

Module de base

2122 32 52 64 72 78 94 112 118 128 132 134 140 150 162

3

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 4/312

16- Sous-programme resolp 17- Sous-programme turbke 18- Sous-programme turrij 19- Sous-programme viscfa 20- Sous-programme visort 21- Sous-programme vissec 22- Sous-programme vortex

164 174 180 194 196 200 204

III1- Sous-programme cfbl** 2- Sous-programme cfener 3- Sous-programme cfmsvl 4- Sous-programme cfqdmv 5- Sous-programme cfxtcl

Module compressible

210212 230 236 242 246

IV1- Sous-programme elec**

Module lectrique e

266268

V1- Sous-programme Introduction

Module combustion

286288 292 300 306 312

2- Sous-programme Gas combustion 3- Sous-programme cpbase 4- Sous-programme fubase 5- Sous-programme Thermodynamics

Part I

Introduction

5

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 6/312

Introduction1.1 Disclaimer

Code Saturne is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Code Saturne is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.1

1.2

Aims of the document

This chapter constitutes an introduction to the theory and developers guide associated with the kernel of Code Saturne. The system of equations considered consists of the Navier-Stokes equations, with turbulence and passive scalars. First, the continuous equations for mass, momentum, turbulence and passive scalars are presented. Then, information related to the time scheme is supplied. Finally, the spatial discretisation is detailed: it is based on a co-located2 nite volume scheme for unstructured meshes. To make the documentation immediately suitable to the developers needs, it has been organized into sub-sections corresponding to the major steps of the algorithm and to some important subroutines of the code. In each sub-section (for each subroutine), the function of the piece of code considered is indicated. Then, a description of the discretisation follows. Finally, and more oriented towards the developers, details of the implementation are provided and a list of open problems is given (improvements, limitations...). Several accessibility levels have been dened for the documentation, so that it is possible to choose the information level best suited to the intended use. At the present time, on UNIX and Linux platforms, free access is granted to all information (level called Complet). The most restrictive level provides only the function of the subroutines (Fonction level). The intermediate level provides the function of the subroutines and the associated discretisation (Discret level). During the development process of the code, the documentation is naturally updated as and when required by the evolution of the source code itself. Suggestions for improvement are welcome. In particular, it will be necessary to deal with some transverse subjects (such as parallelism, periodicity or memory management) which were voluntarily left out of the rst versions, to focus on the algorithms and their implementation. To make it easier for the developers to keep the documentation up to date during the development process, the les have been associated physically with the release of the code (each release of the code includes a directory containing the whole documentation). In practice, the users of Code Saturne will nd the documentation at the following location (UNIX and Linux server at MFEE): $CS HOME/doc/NOYAU/Postscripts/Base, The general command info cs [noyau] also provides this information.1 You should have received a copy of the GNU General Public License along with Code Saturne; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 2 All the variables are located at the centres of the cells.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 7/312

1.3

Continuous equations

This section presents the continuous equations. It is no substitutes for the specic sub-sections of this documentation: the purpose here is mainly to provide an overview before more detailed reading. In the following, stands for the density, u for the velocity eld. A mass source term, , may present, but in most cases the right-hand side of the Masss equation is = 0 Mass div(u) = (I.1.1)

In fact, to compute a given unknown (and in particular for the velocity prediction), the equation + div(u) = is used to re-write the term as follows: div(u) + . The possible t t t variations in time of the density are however not taken into account in the pressure correction step.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide (u) + div( u u) = div() + ST K u t div(u) = 0

Code Saturne documentation Page 8/312

Momentum

(I.1.2)

[ ST K u ] stands for the additional momentum Source Terms which may be prescribed by the user (head loss, ui contribution associated with a user-prescribed mass source term...). K is a positive diagonal tensor, by denition (derived, for example, from the diagonal source term of the head loss tensor). For laminar ow, is the stress tensor: = P Id (I.1.3)

where is the viscous stress tensor, dened from = l (dynamic molecular viscosity) and S (strain rate tensor) as: 2 = 2 S tr(S) Id 3 with S= 1 (grad u + t grad u) 2 (I.1.4)

For turbulent ow, also accounts for the turbulent Reynolds stress tensor (correlations of the velocity uctuations arising from the non linear convective term). The modelling of the latter depends upon the turbulence model adopted: - with an eddy-viscosity model (EVM) such as the k model, the closure requires a turbulent viscosity t . With formally the same denition for as in equation (I.1.4), but with = l + t , reads: 2 = (P + k)Id (I.1.5) 3 - with the LES approach, the denition for remains the same as for the EVM, above, but the turbulent viscosity t now accounts only for the sub-grid eects. - with a Dierential Reynolds Stress Model (DRSM), the components of the Reynolds stress tensor R are solved as extra variables during the simulation, and are readily available for the momentum equation, so one obtains, with = l in the denition of (equation (I.1.4)) : = P Id R (I.1.6)

In the following, only three standard types of turbulence models are described, as representatives of the types of equations that need to be dicretised. A more detailed description of available turbulence models is described in section (?? Turbulence Models??)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 9/312

Equations for the variables k and (standard k model)

t (k) + div u k ( + )grad k = P + G + k i + STk t k t 2 () + div u ( + )grad = C1 [P + (1 C3 )G] C2 + i + T S t k k P is the production term created by mean shear: P = Rij = t = t ui ui uj 2 uk 2 ui = t + + t ij + kij xj xj xi 3 xk 3 xj ui uj ui 2 2 + t (divu)2 kdiv(u) xj xi xj 3 3 2 2 2 2 2 u v w u v u w v 2 +2 +2 + + + + + x y z y x z x z 2 t (divu)2 3 1 t gi t xi

(I.1.7)

+

w y

2

2 kdiv(u) 3

G is the production term created by gravity eects: G = The turbulent viscosity is: t = C

k2 . ST ( = k or ) stands for the additional source terms prescribed by the user (in rare cases only). The constants of the model are given below: C C1 C2 k 0, 09 1, 44 1, 92 1 1, 3

C3 = 0 if G

0 (unstable stratication) and C3 = 1 if G

0 (stable stratication).

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 10/312

Equations for the Reynolds stress tensor components Rij and (LRR model)

(R ) + div(u R grad R ) = P + G + + d ij ij ij ij ij ij ij ij t 2 () + div [u (grad )] = d + C1 [P + G ] C2 t k k

i +Rij + STRij

(I.1.8)

+i + ST

P stands for the turbulence production tensor associated with mean ow strain-rate and G is stands for the production- tensor associated with buoyancy eects: Pij = Rik ui uj + Rjk xk xk and Gij = 3 C k (ri gj + rj gi ) 2 t (I.1.9)

withk moreover, P

= =

1 Rll andri = Rik 2 xk 1 1 Pkk and G = max(0, Gkk ) 2 2

(I.1.10) (I.1.11)

is the term representing pressure-velocity correlations: ij = ij,1 + ij,2 + ij,3 + ij,w 2 2 withij,1 = C1 (Rij kij ) , ij,2 = C2 (Pij P)ij k 3 3 (I.1.12) 1 and ij,3 = C3 (Gij ij Gkk ) 3 (I.1.13)

The term ij,w is called wall echo term (by default, it is not accounted for : see turrij). The dissipation term, ij , is considered isotropic: ij = The turbulent diusion terms are : dij = CS k Rij ( Rkm ) xk xm and d = C xk k Rkm xm (I.1.15) 2 ij 3 (I.1.14)

i In the rare event of masse sources, Rij and i are the corresponding injection terms. STRij and ST are also rarely used additional source terms that can prescribed by the user.

C C C1 C2 C1 0, 09 0, 18 1, 44 1, 92 1, 8

C2 0, 6

C3 CS 0, 55 0.22

C1 0, 5

C2 0, 3

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 11/312

Denition of t for LES Smagorinsky model t = (Cs )2 With Sij the ltered strain rate tensor components: Sij = 1 2 ui uj + xj xi (I.1.17) 2Sij Sij (I.1.16)

Here, ui stands for the ith resolved velocity component3 . C is the Smagorinsky constant. Its theoretical value is 0.18 for homogenous isotropic turbulence, but the value 0.065 is classic for channel ow. is the lter width associated with the nite volume formulation (implicit ltering which corresponds 1 to the integration over a cell). The value recommended for hexahedral cells is: = 2 || 3 where || is the volume of the cell. Classic dynamic model (??this should be moved to chapter turbulence models??)

A second lter is introduced: it is an explicit lter with a characteristic width superior to that of the implicit lter (). If a is a discrete variable dened over the computational domain, the variable obtained after applying the explicit lter to a is noted a. Moreover, with: Lij = ui uj ui uj ij = ui uj ui uj Tij = ui uj ui uj Germano identity reads: Lij = Tij ij Both dynamic models described herafter rely on the estimation of the tensors T and as functions of the lter widths and of the strain rate tensor (Smagorinsky model). The following modelling is adopted4 : 1 Tij ij Tkk = 2C 2 |Dij |Dij 3 1 2 ij ij kk = 2C |Dij |Dij 3 u stands for the implicit-ltered value of a variable u dened at the centres of the cells and u represents the explicit-ltered value associated with the variable u. It follows that the numerical computation of Lij is possible, since it requires the explicit ltering to be applied to implicitly ltered variables only (i.e. to the variables explicitly computed). On the following assumption: C = C3 In the case of implicit ltering, the discretisation in space introduces a spectral low pass lter: only the structures larger that twice the size of the cells are accounted for. Those structures are called the resolved scales, whereas the rest, ui ui , is referred to as unresolved scales or sub-grid scales. The inuence of the unresolved scales on the resolved scales have to be modelled. 4 ij stands for the Kroeneker symbol.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 12/312

and assuming that C is only slightly non-uniform, so that it can be taken out of the explicit ltering operator, the following equation is obtained: 1 Lij ij Lkk = C(ij ij ) 3 with: ij = 22 |Dij |Dij ij = 2 |Dij |Dij Since we are left with six equations to determine one single variable, the least square method is used5 . With: Eij = Lij C(ij ij ) the value for C is obtained by solving the following equation: Eij Eij =0 C Finally: C= with Mij = ij ij This method allows to calculate the Smagorinsky constant dynamically at each time step and at each cell. However, the value obtained for C can be subjected to strong variations. Hence, this approach is often restricted to ows presenting one or more homogeneous directions (Homogeneous Isotropic Turbulence, 2D ows presenting an homogeneous spanwise direction...): indeed, in such cases, the model can be (and is) stabilized by replacing C by an average value of C computed over the homogeneous direction(s). For a general case (without any homogeneous direction), a specic averaging is introduced to stabilize the model: for any given cell of the mesh, the averaged Smagorinsky constant is obtained as an average of C over the extended neighbourhood of the cell (the set of cells that share at least one vertex with the cell considered). More precisely, the average value (also denoted C hereafter) is calculated as indicated below: Mij Lij Mkl Mkl Mij Lij Mkl Mkl2

C=

5L kk

has no eect for incompressible ows.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 13/312

Equations for the scalars Two types of transport equations are considered: advection of a scalar with additional source terms: (a) + div ((u) a) div (Kgrad a) = T Sa + ai tconvection diusion

(I.1.18)

advection of the variance a2 with additional source terms :i (a2 ) + div (( u) a2 ) div (K grad a2 ) = T Sa2 + a2 g t convection

t +2 (grad a)2 a2 t Rf kproduction and dissipation

diusion

(I.1.19)

The two previous equations can be unied formally as: (f ) + div (( u)f ) div (Kgrad f ) = T Sf + f i + Tspd t with: Tspd = 0 for f = a, for f = a2 (I.1.21) (I.1.20)

t (grad a)2 a2 2 t Rf k

T Sf represents the additional source terms that may be prescribed by the user.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 14/312

1.4

Discretisation in time

At rst, the physical properties of the ow are computed (density, viscosity, specic heat...): indeed, they may depend upon the variables (such as the temperature for example). The time scheme is a -scheme: =1 = 1/2 for an implicit rst order Euler scheme for second order Crank-Nicolson scheme (I.1.22)

For the second order scheme, the time step is assumed to be constant. A fractional step scheme is used to solve the mass and momentum equations (Chorin). The rst step (predictor step) provides predicted velocity components: they are determined sequentially and without coupling between each other. The mass equation is taken into account during the second step (corrector step): a pressure Poisson equation is solved and the mass uxes at the cell faces are updated. If required, the equations for the turbulent variables are solved (turbulent kinetic energy and dissipation or Reynolds stresses and dissipation), using a -scheme again. For the k model, an additional step is carried out to couple the source terms. For the Reynolds stress model, the variables (turbulent stresses and dissipation) are solved sequentially, without coupling. Next, the equations for the scalars (enthalpy, temperature, tracers, concentrations, mass fractions...) are solved, also with a -scheme. Finally, all the variables are updated and another time step may start. The general equation for advection (valid for the velocity components, the turbulent variables and the scalars) is re-written as follows in a condensed form; the mass equation ( + div(u) = ) has been t used to split the time derivative: f + div (( u)f ) div (Kgrad f ) = Si (, ) f + Se (, ) + div ( u) f t In this equation: : represents the physical properties (, K, t , ...) : represents the variables of the problem (u, k, , ...) Si (, ) f : represents the linear part of the source terms Se (, ) : includes all other source terms div ( u) f : is the term associated with mass accumulation (I.1.23)

The time at which the dierent quantities are evaluated is indicated below: : the time considered is dened by the time scheme applied to the physical properties. ( u): the time considered is dened by the time scheme applied to the mass ux. Se (, ): the time considered is dened by the time scheme applied to the explicit source terms. If = 1/2, or if an extrapolation is used, the time step t is constant in time and uniform in space.

1.4.1

Physical properties

The physical properties of the ow (density, viscosity, specic heat...) are: - either explicit, dened at the time step n. - or extrapolated at n + using the Adam-Bashforth time scheme (in this case, the time step is assumed to be constant). Under a more general form, this reads: n+ = (1 + ) n n1 (I.1.24)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 15/312

= 0 = 1/2 = 1

standard explicit formulation second order extrapolation at n + 1/2 rst order extrapolation at n + 1

(I.1.25)

1.4.2

Mass ux

For the mass ux, three time schemes are available. The mass ux may be: - explicit, taken at time step n for the momentum equations and updated with its value at time step n + 1 for the equations for turbulence and scalars (standard scheme). - explicit, taken at time step n for the momentum equations and also for the equations for turbulence and scalars. - taken at n + F (second order if F = 1/2). To solve the momentum equations, ( u)n2+F and ( u)n1+F are known. Hence, the value at n + F is obtained as a result of the following extrapolation: ( u)n+F = 2 ( u)n1+F ( u)n2+F (I.1.26) At the end of this phase (after the pressure correction step), ( u)n+1 is known and the following interpolation is used to determine the mass ux at n + F that will be adopted for the equations for turbulence and scalars: ( u)n+F = 1 1 F ( u)n+1 + ( u)n1+F 2 F 2 F (I.1.27)

1.4.3

Source terms

As for the physical properties, the explicit source terms are: - explicit: [Se (, )]n = Se (n+ , n ) - extrapolated at n + S using the Adams-Bashforth scheme: [Se (, )]n+S = (1 + S ) Se (n , n ) S Se (n1 , n1 ) (I.1.29) (I.1.28)

By default, to be consistent and preserve the order of convergence in time, the implicit source terms are discretized with the same scheme as that used for convection-diusion of the unknown considered, i.e. taken at n + : [Si (, ) f ]n+ = Si (n+ , n ) [ f n+1 + (1 ) f n ] (I.1.30) Note: The implicit source terms taken also at n + for S = 0, while for S = 0, the implicit source terms are taken at n + 1 , this to enhance stability.

1.4.4

General discrete form

For the sake of clarity, it is assumed hereafter that, unless otherwise explicitly stated, the mass ux is taken at n + F and the physical properties are taken at n + , with F and dependant upon the specic schemes selected for the mass ux and the physical properties respectively.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 16/312

Under a general form, the discrete counterpart of equation (I.1.23) at n + reads: n+1 (f f n ) + div (( u)f n+ ) div (Kgrad f n+ ) = t n+ n+ [Si (, ) f ] + [Se (, )] S + div ( u) f n+ Using the standard -scheme f n+ = f n+1 + (1 ) f n , the equation reads: n+1 (f f n ) + div (( u)f n+1 ) div (Kgrad f n+1 ) = t (1 ) div (( u)f n ) + (1 ) div (Kgrad f n )+ n+ Si (, n ) f n+1 + (1 ) f n + [Se (, )] S + div ( u) ( f n+1 + (1 ) f n ) (I.1.31)

(I.1.32)

For numerical reasons, the system is solved in an iterative and incremental manner, with the help of the series f n+1,k+1 = f n+1,k+1 f n+1,k (with, by denition, f n+1,0 = f n ). In particular, this method allows to treat implicitly a portion of the advection-diusion terms associated correction terms for non orthogonal meshes. Hence, the system actually solved reads: Si (, n ) div ( u) (f n+1,k+1 f n+1,k ) t ROVSDT + div (( u) (f n+1,k+1 f n+1,k )) div (Kgrad (f n+1,k+1 f n+1,k )) = div (( u) f n+1,k ) + div (Kgrad f n+1,k ) (1 ) div (( u) f n ) + (1 ) div (Kgrad f n ) n+1,k SMBRS f n ) + Si (, n ) f n+1,k + (1 ) f n (f t n+ +div ( u) ( f n+1,k + (1 ) f n ) + [Se (, )] S

(I.1.33)

Whatever the equation considered (momentum equation, equations for turbulence or scalars,...) the system representation is always the same: a right-hand side (stored in the vector-array SMBRS) and a vector-array ROVSDT for the part linear with respect to f n+1,k+1 .

The vector-array ROVSDT is computed by the subroutine covofi for the scalars, by preduv for the velocity and by turbke or turrij for the turbulence. The vector-array SMBRS is not computed at one go, but in two successive steps.

The rst part is calculated by the subroutines covofi, preduv, turbke and turrij (respectively for the scalars, the velocity and the turbulence). At that point, the vector SMBRS is dened as follows: SMBRS = Si (, n ) f n + div ( u) f n + [Se (, )]n+S

(I.1.34)

then, the calculation of SMBRS is complemented at each sub-iteration during the resolution of the equation by the subroutine codits as follows: SMBRS = SMBRS ROVSDT (f n+1,k f n ) div (( u) f n+1,k ) + div (Kgrad f n+1,k ) (1 ) div (( u) f n ) + (1 ) div (Kgrad f n ) (I.1.35)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 17/312

1.5

Discretisation in space

Within the framework of the nite volume approach, the equations are integrated over each cell of the mesh (or control volume i ). This section is limited to a brief description of the way the terms appearing in the equations are integrated. Specic attention is devoted to the calculation of gradients, since it is a major characteristic of the co-located nite volume method (all the variables are associated with the same point, namely the cell centre6 ). The terms of order 0 (i.e. the terms that are not a space derivative) are integrated to introduce their average over the cell. For example, g becomes |i |i g. In this expression, |i | is the volume of cell i and i denotes the average of over the control volume (the cell) i . For less clumsy notations, |i |i g is simply written as |i |i g. When reconstructions (in fact Taylor series) are required to reach a higher order in space, the average value i is assumed to be associated with the centre I of i . The divergence terms (or ux terms, or again conservative terms) are integrated using the Green relation to introduce cell faces values (and so, uxes appear naturally). For example, a term such pij Sij . In this expression, pij is the average of p on the interface between as div(p) becomes7jN eibr(i)

the neighbouring cells i and j. The summation is carried out for j N eibr(i), that is, all cells in the neighbourhood of i thus sharing a cell face with it. As for the cell-average above, the overbar is pij Sij . The value pij is assumed to be associated with omitted: the sum is simply writtenjN eibr(i)

the centre F of the face ij when reconstructions are needed to reach a higher order in space. The precision of the value pij determines the precision of the calculation of div(p). For pij , it is possible to take a non-centred and non-interpolated value (upwind scheme for convection) or a linear interpolation between the values at the centres I and J of the neighbouring cells. Both methods are relatively straighforward but may lack consistence and precision for arbitrary meshes (and in particular on non-orthogonal meshes). A higher order in space may be reached if reconstruction techniques are used. The idea is to compute the value for pij more precisely: to do so, p is interpolated at Fij (the centre of the face) using the values for p at I and J and... the gradients of p calculated at I and J. The reader will notice that it is precisely the calculation of the space derivatives8 of p that motivated the need for a good interpolation of p at Fij . Hence, the computation of the space derivatives of p requires to solve a system: this is done in an iterative manner. Doing so allows to calculate the cell gradient of the variables. It is important to keep in mind that the cell gradient of a given variable represents the gradient of the variable in the cell and that it is obtained from the values of the variable interpolated at the cell faces. Similarly, the terms written as divergence of gradient are integrated to introduce face values. One has to calculate the gradient at each face (or face gradient) in the direction normal to the face. This concept of face gradient is extremely important. The face gradient normal to a face can be easily calculated with just the values at the centres of the two cells that share the face (points I and J on gure I.1.1), but this method is limited to orthogonal meshes. For consistence and to reach a higher order in space, the values of the variables at points I and J have to be used. These are calculated by a Taylor series from the values at I and J and from the cell gradient previously determined.

6 The centre of a cell is a geometric point associated with the cell and located preferably inside the cell. Nevertheless, the word centre shall not be taken literally, especially in the case of polyhedral P that do not have a regular shape. cells P 7 If the cell i is at the domain boundary, the sum becomes pij Sij + pbik Sbik , with bik referring to the jV ois(i) k(i)

faces of the cell i which are at the domain boundary. 8 The rst derivatives in space are required to obtain div(p) in each cell.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 18/312

Sij

i I F O

J J

Sb

ik

I

1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0F 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0

I

I

i

j

Figure I.1.1: Identication of the geometric entities for internal (left) and boundary faces (right).

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 19/312

1.6

Calling tree

Each sub-section of this document is associated with an important subroutine. The full list of the subroutines described here is the following: bilsc2 clptur clsyvt codits condli covofi gradmc gradrc inimas itrmas matrix navsto preduv recvmc resolp turbke turrij viscfa visort vissec. The table 1 presents their sequence within a time step. This calling tree is only partial. In particular, it does not account for the number of calls to each subroutine. Also, for the sake of clarity, no reference has been made to the subroutines dedicated to the gradient calculation (gradmc, gradrc), which are called very often. For the same reason, the calls to bilsc2 (advection uxes) and matrix (matrix calculation) which are made from within codits (treatment of an advection equation with source terms) have not been reported. The sub-sections where important information can be found are indicated below:

Calculation of gradients gradrc gradmc Least square method recvmc gradmc Convective schemes bilsc2 Wall-laws (for velocity and temperature) clptur condli System solve (incremental method) codits Calculation of the values at the faces (not exhaustive) viscfa visort Finally, for the reader wishing to become more familiar with the methods implemented in Code Saturne, it is recommended to begin with the study of the advection equation for a scalar (covofi) which is solved iteratively using an incremental method (codits). It will then be useful to look at navsto which briey presents the solution of the system made up of the mass and momentum equations.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 20/312

Calculation of the physical properties Boundary Conditions condli clptur turbulent conditions at the wall clsyvt symmetry conditions for the vectors and the tensors Navier-Stokes solution navsto Velocity prediction preduv vissec momentum source terms related to the transposed gradient of the velocity viscfa calculation of the viscosity at the faces codits iterative solution of the system using an incremental method Pressure correction resolp viscfa calculation of the time step at the faces... visort ...according to the selected options matrix calculation of the Poisson equation matrix inimas initialisation of the mass ow rate itrmas update of the mass ow rate Velocity correction standard method or... recvmc least square method k model turbke viscfa preliminary steps before... bilsc2 ...source terms coupling viscfa calculation of the viscosity at the faces codits iterative solution of the systems using an incremental method Reynolds stress model turrij visort calculation of the viscosity at the faces codits iterative solution of the systems using an incremental method Equations for the scalars covofi viscfa calculation of the viscosity at the faces codits iterative solution of the systems using an incremental method Table 1: Partial and simplied calling tree associated with the successive stages within a time step.

Part II

Module de base

21

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 22/312

1- Sous-programme bilsc21.1 Fonction

In this subroutine, called by codits and turbke, the contributions to the explicit budget of the reconstructed (on non-orthogonal meshes and if the user chooses to) convective and diusive terms of the right-hand side of a convection/diusion equation for a scalar a are computed. These terms write 1 : B (( u)n , a) = div( (u)n a) + div( grad a)convective part diusive part

(II.1.1)

with , u, and a the variables at time tn .

1.2

Discretization

1.2.1 Convective PartUsing the notations adopted in the subroutine navsto, the explicit budget corresponding to the integration over a cell i of the convective part div( ( u)n a) of B can be written as a sum of the numerical uxes F ij calculated at the faces of the internal cells, and the numerical uxes F bik calculated at the boundary faces of the computational domain . Lets take V ois(i) the set of the centres of the neighbouring cells of i and b (i) the set of the centres of the boundary faces of i (if they exist). Thus we can write div((u)n a) d =i jV ois(i)

F ij ((u)n , a) +kb (i)

F bik ((u)n , a)

with : F ij ((u)n , a) = (u)n . S ij ij F bik ((u)n , a) = (u)nik . S bik b a f,ij (II.1.2)

af bik

(II.1.3)

where a f,ij and af bik represent the values of a at the internal and boundary faces of i , respectively. reprsentent les valeurs aux faces internes et de bord respectivement. e Before presenting the dierent convection schemes available in Code Saturne, we dene: FJ dened at the internal faces only and IJ = uK + (grad u)K . KK at the rst order in space, for K = I or J ij =

uK

The value of the convective ux F ij depends on the numerical scheme. Three dierent types of convection schemes are available in this subroutine:1 They appear on the right-hand side of the incremental system for cell I of the momentum prediction step: EM(uk+1 , I) = E(un+1/2,k , I) (see navsto for more details)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers GuideSij1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0F 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0

Code Saturne documentation Page 23/312

I

i I F O

J J

Sb

ik

I

i

I

j

Figure II.1.1: Denition of the geometric entities for internal (left) and a boundary faces (right).

a 1st order upwind scheme:upstream F ij ((u)n , a) = F ij ((u)n , a) aI si (u)n . S ij 0 ij a f,ij = a si (u)n . S < 0 J ij ij

o` : u

a centered scheme:centered ((u)n , a) F ij ((u)n , a) = F ij

with : a f,ij = ij aI + (1 ij )aJ a Second Order Linear Upwind scheme (SOLU):SOLU F ij ((u)n , a) = F ij ((u)n , a) a + IF . (grad a) si (u)n . S I 0 I ij ij with : a f,ij = a + JF . (grad a) si (u)n . S < 0 J J ij ij

The value of F bik is calculated as : af bik = aI if (u)nik . S bik 0 b a bik if (u)nik . S bik < 0 b

a bik is the boundary value directly computed from the prescribed boundary conditions. Remark 1

When a centered scheme is used, we actually write (to ensure rst order discretization in space for a) a f,ij = ij aI + (1 ij )aJ + A factor 1 is used for numerical stability reasons. 2 1 [(grad a)I + (grad a)J ] . OF 2

Remark 2 A slope test (which may introduce non-linearities in the convection operator) allows to switch from1 Extrapolation

of the upwind value at the faces centre.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 24/312

the centered or SOLU scheme to the rst order upwind scheme (without blending). Additionally, in standard mode a f,ij is computed as a weighted average between the upstream value and the centered value (blending), according to users choice (variable BLENCV in the subroutine usini1).

1.2.2 Diusive PartSimilarly, the diusive part writes :

div( grad a) d =i jV ois(i)

D ij ( , a) +kb (i)

D bik (, a)

with: D ij ( , a) = ij and : D bik ( , a) = bik a bik a I S bik IF (II.1.5) aJ aI S ij IJ (II.1.4)

using the same notations as before, and with S ij and S bik being the norms of vectors S ij , S bik and S bik , a bik , respectively.

1.3

Implementation

In the following, the reader is reminded of the role of the variables used in the dierent tests: IRCFLP, from array IRCFLU ; indicates for the considered variables wether or not the convective and diusive uxes are reconstructed = 0 : no reconstruction = 1 : reconstruction ICONVP, from array ICONV ; indicates if the considered variables is convected or not. = 0 : no convection = 1 : convection IDIFFP, from array IDIFF ; indicates if the diusion of the considered variables is taken into account or not. = 0 : no diusion = 1 : diusion IUPWIN indicates locally, in bilsc2 (to avoid unnecessary calculations) whether a pure upwind scheme is chosen or not for the considered variables to be convected. = 0 : no pure upwind = 1 : pure upwind is used ISCHCP, from array ISCHCV ; indicates which type of second order convection scheme is used on orthogonal meshes for the considered variable to convect (only useful if BLENCP > 0 ). = 0 : we use the SOLU scheme (Second Order Linear Upwind ) = 1 : we use a centered scheme In both cases the blending coecient BLENCP needs to be given in usini1. BLENCP, from array BLENCV ; indicates the percentage of centered or SOLU convection scheme that one wants to use. This weighting coecient is between 0 and 1. ISSTPP, from array ISSTPC ; indicates if one wants to remove the slope test that switches the convection scheme from second order to upwind if the test is positive. = 0 : a slope test is systematically used = 1 : no slope test

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 25/312

1.3.1 Computation of the gradient G c,i of variable aThe computation of the gradient of variable a is necessary for the computation of the explicit budget. grdcel is called everytime this gradient is needed, and it is stored in the array (DPDX, DPDY, DPDZ). The computation of the gradient is necessary in the following situations: if the convection is activated with a non pure upwind scheme (ICONVP = 0 and IUPWIN = 0) and, if we want to reconstruct the uxes (IRCFLP = 1), or if we want to use the SOLU scheme (ISCHCP = 0), or if we use the slope test (ISSTPP = 0), or : if there is diusion and we want to reconstruct the uxes (IDIFFP = 0 and IRCFLP = 1). In all other cases, the array (DPDX, DPDY, DPDZ) is set to zero.

1.3.2 Computation of the upwind gradient G amont of variable a c,iG amont refers to the upwind gradient of variable a, for cell i . It is stored in the array (DPDXA, DPDYA, DPDZA). c,i We also dene the scalars a amont and a amont as: ij bik |i | G upwind c,idef

=

a upwind S ij + ijjV ois(i) kb (i)

a upwind S bik bik

(II.1.6)

After initializing it to zero, G amont is only computed when the user wishes to compute a convecc,i tion term with a centered or SOLU method, and a slope test. For each cell i , the face values aIF (variable PIF) and aJF (variable PJF), are computed as: aIF = aI + IF . (grad a) I aJF = aJ + JF . (grad a) J Depending on the sign sn of the mass ux (u)n . S ij , we give aIF or aJF the value a upwind of the ij ij ij expression a upwind S ij . ijjV ois(i)

a upwind = ij

aI + IF . (grad a) I si sn = 1 ij aJ + JF . (grad a) J si sn = 1 ij

The boundary terms are computed in a classic manner as follows (keeping the same notations as in the other subroutines): a upwind S bik bik =kb (i)

(INC A b,ik + B b,ik aI ) S bik INC A b,ik + B b,ik aI + B b,ik II . G c,i S bikkb (i)

kb (i)

=

(A b,ik , B b,ik )kb (i) are stored in the arrays (COEFAP, COEFBP). The vector II is stored in the array (DIIPBX, DIIPBY, DIIPBZ). The surfaces (S bik )kb (i) are stored in the array SURFBO .

1.3.3 Summation of the numerical convective and diusive uxesThe contributions to the explicit budget [div( (u)n a) + div( grad a)] are computed and added to the right-hand side array SMBR, which has already been initialized before the call to BILSC2 (with the explicit source terms for instance, etc.). The variable FLUX gathers the convective and diusive parts of the numerical uxes. It is computed in a classic manner, rst on the internal faces, and then on the boundary faces. The indices i and j

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 26/312

are represented by II and JJ, respectively. In order to take into account (when necessary) the sign sn of the mass ux (u)n . S ij , the following ij ij equations are used : = b+ + b with b+ = max (b, 0), b = min (b, 0) = b+ b 1 = [ b + | b| ] 2 1 = [ b |b | ] 2 In this subroutine, b represents the mass ux FLUMAS(IFAC) on an internal face IFAC (FLUMAB(IFAC) for a boundary face IFAC) ; b+ is stored in FLUI and b in FLUJ. for an internal face ij (IFAC) We calculate : F ij ((u)n , a) jV ois(i) jV ois(i)

For any real b, we have : b | b| + b b

D ij ( , a) =jV ois(i)

(u)n . S ij ij

a f,ij ij

aJ aI S ij IJ

The above sum corresponds to the numerical operation: FLUX = ICONVP . [ FLUI . PIF + FLUJ . PJF ] + IDIFFP . VISCF(IFAC) . [ PIP PJP ] (II.1.7)

The above equation does not depend on the chosen convective scheme, since the latter only aects the quantities PIF (face value of a used when b is positive) and PJF (face value of a used when b is S ij ngative). PIP represents aI , PJP aJ and VISCF(IFAC) ij e . IJ The treatment of diusive part is identical (either with or without reconstruction). Consequently, only the numerical scheme relative to the convection diers. for a boundary face ik (IFAC) We compute the terms : F bik ((u)n , a) kb (i) kb (i)

D bik (, a) =kb (i)

(u)nik . S bik b

af bik bik

a bik a I S bik IF

with: aI a b1ik a bik The coecients (A b,ik , B b,ik )kb (i) = aI + II . G c,i = INC A b,ik + B b,ik aI = INC Adif f + B dif f aI b,ik b,ik represent the boundary conditions2

resp.(Adif f , B dif f )kb (i) b,ik b,ik

associated with a (resp. the diusive uxes of a). The above sum corresponds to the numerical operation:: FLUX = ICONVP . [ FLUI . PVAR(II) + FLUJ . PFAC ] + IDIFFP . VISCB(IFAC) . [ PIP PFACD ] where PFAC represents a b1ik , PIP aI , PFACD a bik and VISCB(IFAC) bik (II.1.8)

S bik . IF This treatment is common to all schemes, because boundary values only depend on boundary conditions, and because a very simplied expression of F bik is used (upwind) 3 . We still have to compute, when the convection option is activated (ICONVP = 1), the values of variables PIF and PJF, for any internal face IFAC between cell i and j .2 see clptur for more details. The dierence is actually only eective when the k model is used, and for the velocity only. 3 Actually, a 0, a b1ik otherwise. is aI if (u)n . S bik f b bik ik

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 27/312

Calculation of the ux in pure upwind IUPWIN = 1In this case, there is no reconstruction since only the values PVAR(II) and PVAR(JJ) at the cell centres are needed. PIF = PVAR(II) (II.1.9) PJF = PVAR(JJ) The variable INFAC counts the number of calculations in pure upwind, in order to be printed in the listing le. In order to obtain the global numerical ux FLUX (convective + diusive) associated, the following operations are performed : calculation of vectors II and JJ, calculation of the face gradient (DPXF, DPYF, DPZF) with the half-sum of the cell gradients G c,i et G c,j , calculation of the reconstructed (if necessary) values aI and aJ (variables PIP and PJP, respectively) given by : 1 (II.1.10) aK = aK + IRCFLP . KK . ( G c,i + G c,j ) K = I et J 2 calculation of the quantities FLUI and FLUJ, calculation of the ux FLUX using (II.1.7). The computation of the sum in SMBR is straight-forward, following (II.1.1) 4 .

Calculation of the ux with a centered or SOLU scheme (IUPWIN = 0)The two available second order schemes on orthogonal meshes are the centered scheme and the SOLU scheme. In both cases, the following operations are performed: calculation of the vector II, the array (DIIPFX, DIIPFY, DIIPFZ) and the vector JJ, the array (DJJPFX, DJJPFY, DJJPFZ) calculation of the face gradient (DPXF, DPYF, DPZF) ha-sum of the cell gradients G c,i and G c,j , calculation of the possibly reconstructed (if IRCFLP = 1) values aI and aJ (variables PIP and PJP, respectively) given by : aK = aK + IRCFLP . KK . 1 ( G c,i + G c,j ) 2 K = I and J (II.1.11)

calculation of FLUI and FLUJ. without slope test (ISSTPP = 1) with a centered scheme (ISCHCP = 1) The values of the variables PIF and PJF are equal, and calculated using the weighting coecient ij as follows: PIF = ij . PI + (1 ij ) . PJ (II.1.12) PJF = PIF with a SOLU scheme (ISCHCP = 0) After calculating the vectors IF and JF , the values of the variables PIF and PJF are computed as follows: PIF = PI + IF . G c,i (II.1.13) PJF = PJ + JF . G c,j PIF and PJF are systematically reconstructed in order to avoid using pure upwind, i.e. this formulae is applied even when the user chooses not to reconstruct (IRCFLP = 0). with slope test (ISSTPP = 0)4 taking

into account the negative sign of B .

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 28/312

The procedure is quite similar to the one described in the previous paragraph. There is, in addition to hte previous procedure, a slope test that makes under certain conditions the scheme switch locally (but systematically) from the chosen centered or SOLU scheme to a pure upwind scheme. calculation of the slope test Equation (II.1.6) writes on an internal cell i , with sn = sgn (u)n . S ij : ij ij |i | G upwind c,i =jV ois(i)

a upwind S ij ij 1 n ( s +1 ) 2 ij 1 n ( s +1 ) 2 ij aIF + 1 n ( s 1 ) aJF 2 ij S ij

=jV ois(i)

=jV ois(i)

( aI + IF . (grad a) I ) + 1 ( sn 1 ) ( aI + JF . (grad a) J ) S ij ij 2

On a cell i with neighbours (j )jV ois(i) , the classic slope test consists in locating where a variable a is non-monotonic by studying the sign of the scalar product of the cell gradients of G c,i and G c,j . If this product is negative, we switch to an upwind scheme, if it is positive, we use a centered or SOLU scheme. Another technique which also ensures the monotonicity of the solution is to apply this criterion to the upwind gradients G amont or to their normal projection on face ( G amont . S kl ). c,k c,k We then study the sign of the product G amont . G amont or of the product ( G amont . S ij ) . ( G amont . S ij ) . c,i c,j c,i c,j The slope test implemented is based on the rst quantity, G amont . G amont (the second one was abanc,i c,j donned because it was found to be less general). The choice of a slope test based on G amont . G amont c,i c,j comes from the following line of argument in one-dimension 5 : Lets take p a second order in x polynomial function. Its value at points I 1, I, I + 1 of coordinates xI1 , xI and xI+1 are pI1 , pI , and pI+1 , respectively. To simplify, we suppose that I is the origin O ( xI = 0 ), and that the grid spacing h is constant, which results in xI+1 = xI1 = h. Additionally, we suppose that the velocity is orientated from point I towards point I + 1, i.e. sn = 1. Therefore we ij consider the points I 1, I and I + 1 for the face ij which is located between I and I + 1. The sign of the product p (xI1 ) . p (xI+1 ) inidicates the monotonicity of function p. If this product it positive, the function is monotonic and we use a centered or a SOLU scheme, otherwise, we switch to an upwind scheme. By identifying the polynomial coecients using the equations p (xI1 ) = pI1 , p (xI ) = pI , p (xI+1 ) = pI+1 , we obtain : p (xI1 ) p (xI+1 ) or after simplication : p (xI1 ) = G c,i + p (xI+1 ) = G c,i pI+1 pI h pI+1 pI G amont c,i h G amont c,i (II.1.15) pI+1 pI1 2h pI+1 pI1 =+ 2h =+ + pI pI1 pI+1 pI h h pI pI1 pI+1 pI h h

(II.1.14)

We know that : pI+1 pI representes the upwind derivative at point I + 1, directly accessible by the values of p in h the neighbouring cells of face ij, pI+1 pI1 represents the centered derivative (in nite volume) at point I, namely G c,i , 2h5 Information

on the second derivative would permit to study more nely the behaviour and the strong variations of

a.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 29/312

pI pI1 represents the value of the upwind derivative (in nite volume) at point I, namely G amont . c,i h The slope test relative to p (xI1 ) . p (xI+1 ) reduces to studying the sign of T P 1d : T P 1d = pI+1 pI pI+1 pI ] . G c,i [ G amont ] c,i h h pI+1 pI 2 = |G c,i |2 ( G amont ) c,i h G c,i + [ G amont c,i

(II.1.16)

Using a similar line of argument, a possible extension to higher dimensions consists in replacing the values G c,k and G amont by ( G c,k . S kl ) eand ( G amont . S kl ) respectively. After simplications, this c,k c,k leads us to the formulae T P + : 3d T P + = (G c,i . S ij )2 (G amont . S ij c,i 3d aJ aI S ij )2 IJ (II.1.17)

for (u)n . S ij > 0. ij Similarly, we can deduce a T P associated with (u)n . S ij < 0, dened by : ij 3d T P = (G c,j . S ij )2 (G amont . S ij c,j 3d aJ aI S ij )2 IJ (II.1.18)

We introduce the variables TESTI, TESTJ and TESTIJ computed as: TESTI = G amont . S ij c,i TESTJ = G amont . S ij c,j TESTIJ = G amont . G amont c,i c,j

(II.1.19)

The quantity TESQCK corresponding to T P 3d , is computed dynamically, depending on the sign of the mass ux sn . ij consequently : if (u)n . S ij > 0 and ij if (G c,i . S ij )2 (G amont . S ij c,iTESQCK

aJ aI S ij )2 < 0 or (G amont . G amont ) < 0, c,i c,j IJ

or : if (u)n . S ij < 0 and ij if (G c,j . S ij )2 (G amont . S ij c,jTESQCK

aJ aI S ij )2 < 0 or (G amont . G amont ) < 0, c,i c,j IJ

then we switch to a pure upwind scheme: PIF PJF and INFAC is incremented. otherwise : the centered or the SOLU scheme values values are used as before : with a centered scheme (ISCHCP = 1) The values of the variables PIF and PJF are equal and calculated using the weighting coefcient ij : PIF = ij . PI + (1 ij ) . PJ (II.1.21) PJF = PIF = PVAR(II) = PVAR(JJ) (II.1.20)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 30/312

with a SOLU scheme (ISCHCP = 0) After calculating the vectors IF and JF , the values of the variables PIF and PJF are computed as follows: PIF = PI + IF . G c,i (II.1.22) PJF = PJ + JF . G c,j PIF and PJF are systematically reconstructed in order to avoid using pure upwind, i.e. this formulae is applied even when the user chooses not to reconstruct (IRCFLP = 0).

Wether the slope test is activated or not, when the centered or the SOLU schemes are activated, a blending coecient (BLENCP) between 0 and 1, provided by the user, enables to blend, if desired, the chosen scheme and the pure upwind scheme following the formulae: PIF PJF = BLENCPP IF (centre = BLENCPP JF(centre ou SOLU ) ou SOLU )

+ (1 BLENCP) PII + (1 BLENCP) PJJ

(II.1.23)

calculation of FLUI and FLUJ, calculation of the ux FLUX using equation (II.1.7). The computation of the sum in SMBR is straight-forward, following (II.1.1)6 Remark For more information on the convection schemes and the slope test in Code Saturne (version 1.1), the reader is referred to EDF internal report EDF HI-83/04/020 (F. Archambeau, 2004).

6 taking

into account the negative sign of B .

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 31/312

1.4

Points to treat

Convection scheme Upwind scheme As all rst-order schemes, it is robust, but introduces severe numerical diusion. Centered or SOLU scheme This type of schemes can generate numerical oscillations, that can cause the calculation to blow up. It can also lead to physical scalars taking unphysical values. Considering these limitations, other schemes are currently being tested and implemented in order to improve the quality of the schemes available to the users. Diusion scheme The formulae : D ij ( , a) = ij is second-order accurate only for ij = aJ aI S ij IJ

(II.1.24)

1 . A possible correction may be to write : 2 aJ aI 1 G f,ij . S ij = (grad a) ij = . S ij + ( ij ) [(grad a)I (grad a)J ] . S ij (II.1.25) 2 IJ with a gradient limiter and a computation of ij which does not alter the order of accuracy. Implementation In order to improve the CPU time, an eort on loops can be done. More particularly, there is a test IF inside of a loop on variable IFAC that needs to be checked. Calculation of the gradient used during the reconstruction of the diusive uxes Why do we use aI or aJ 1 ( G c,i + G c,j ) instead of G c,k , for k = i or for k = j in the reconstructed values 2 of (II.1.10) and (II.1.11)?

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 32/312

2- Sous-programme clptur

2.1

Function

This subroutine is dedicated to the calculation of the wall boundary conditions. The notations introduced in CONDLI for the general boundary conditions will be used. The wall boundary conditions refer to all the boundary conditions for the velocity, the turbulent variables (k, , Rij ), the temperature when it has a prescribed value at the wall (or the enthalpy and more generally the VarScalaires1 to treat at the wall by using a similarity law for the associated boundary layer). For the VarScalaire in particular, when the boundary conditions at the wall are of Neumann type (homogeneous or not), they are treated in condli and dont present them here. In particular, the boundary conditions of the VarScalaires are not treated here because their treatment at the wall is of homogeneous Neumann type. We present the calculation of the pair of coecients Ab and Bb which are used during the computation of certain discretized terms of the equations to solve, and which allow in particular to determine a value associated with the boundary faces fb,int (at a point located at the centre of the boundary face, the barycentre of its vertices) using the formulae fb,int = Ab + Bb fI (fI is the value of the variable at point I , the projection of the centre of the boundary cell onto the line normal to the boundary face and passing through its centre : see gure II.2.1).Bord du domaine de calcul Sb Domaine de calcul I I y fI F f b,int

Coefficients dechange h int h b

11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 fb,ext 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000 11111111 00000000himp,ext

n normale sortante de norme 1

fimp,ext

Figure II.2.1: Boundary cell.

2.2

Discretisation

Notations1 As in condli the VarScalaire are any solution of a convection-diusion equation apart from the velocity, the pressure and the turbulent variables k, and Rij . More specically, the name VarScalaire can refer to the temperature, the enthalpy or a passive scalar.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 33/312

The velocity of the wall is noted v p . We assume it is projected onto the plane tangent to the wall (if it is not, then the code projects it). The velocity of the uid is noted u. Index I, I or F denotes the point at which the velocity is estimated. The component tangent to the wall writes u . The uid velocity in the coordinate system attached to the wall (relative velocity) writes ur = u v p . The orthonormal coordinate system attached to the wall writes R = ( , n, b). n = n is the unit vector orthogonal to the wall and directed towards the interior of the com putational domain. = 1 [ur (ur . n)] is the unit vector parallel to the projection of the relative I I ur (ur . n) I I r velocity at I , uI , in the plane tangent to the wall (i.e. orthogonal to n) : see gure II.2.1.

b is the unit vector which completes the positively oriented coordinate system. The dimensionless limit distance which separates the viscous sublayer from the logarithmic region + writes ylim . Its value is 1/ (with = 0, 42) in general (to ensure the continuity of the velocity gradient) and 10.88 in LES (to ensure the continuity of the velocity). In the case of the two velocity scale model, - uk is the friction velocity at the wall obtained from the turbulent kinetic energy. We write u ur ,I + the friction velocity at the wall calculated from the equation = f (yk ). u+ + - yk represents a dimensionless wall distance, yk =

uk I F ( is the molecular kinematic viscosity taken at the centre I of the boundary cell). The function f gives the ideal shape of the velocity 1 prole. It is piecewisely approximated by the logarithmic law f (z) = f1 (z) = ln(z) + 5, 2 for + z > ylim and by the linear law f (z) = f2 (z) = z otherwise.

- The two velocity scale uk and u are simple to compute but their computation requires the knowledge of the turbulent kinetic energy kI at the centre of cell adjoint to the boundary face (with the Rij model, we use half the trace of the Reynolds stress tensor). - The two velocity scale model is the default model in Code Saturne. It often permits, and in particular in cases with heat transfer, to reduce the eects of certain aws associated to the k model. Later on, we will use u and uk for the boundary conditions of the velocity and scalars (in particular the temperature). Two velocity scale model 1 1 4 2 uk = C kI r 1 u,I + + + = ln(yk ) + 5, 2 for yk > ylim u u is solution of r u,I + + + = yk for yk ylim u uk I F + with C = 0, 09 yk = and = 0, 42 In the case of the one velocity scale model, we write u the only friction velocity at the wall solution of the equation a dimensionless wall distance y + = ur ,I = f (y + ). y + represents u

(II.2.1)

u I F ( is the molecular kinematic viscosity taken at the centre I

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 34/312

of the boundary cell). The function f gives the ideal shape of the velocity prole, as in the case of the two velocity scale model. One can note that this friction velocity, calculated using a more complicated approach (Newton method), can however be obtained without making any reference to the turbulent variables (k, , Rij ). For convenience in the case of the one velocity scale model, we write uk = u . Later on, we will use u and uk for the boundary conditions of the velocity and scalars (in particular the temperature). Mod`le ` une chelle de vitesse e a e uk = u r 1 u,I = ln(y + ) + 5, 2 u u solution de r u,I = y+ u u IF avec y + = et = 0, 42

+ pour y + > ylim

(II.2.2)

pour y

+

+ ylim

Remark : Hereafter, we provide three exemples based on the two velocity scale model. In this way, one can implement a specic wall function : u,I = g(y + ) u by simply imposing u = u,I /g(y + ). It is also possible to use a rough-wall wall function such as : u,I 1 y = ln( ) + 8, 5 u where is the height of the roughness elements at the wall : one just has to impose u = 1 y u,I / ln( ) + 8, 5 , y being deduced from y + , available as an argument, by the equation + . y=y uk Even a more general correlation could be used of Colebrook type : u = udeb / 4 2log10 2, 51 + + 3, 7 DH 2 2DH

+ where DH is the hydraulic diameter made dimensionless using uk , , udeb the mean streamwise velocity and the relative roughness. DH

Boundary conditions for the velocity in k We rst consider the boundary conditions used in the case of calculation using the k model. Indeed these cases are the most complex and general. The boundary conditions are necessary to prescribe at the boundary the correct tangential stress = I u uk in the momentum equation2 (I is the density at the centre of cell I). The term which requires boundary conditions is the one containing the velocity derivative in the normal direction to the wall3 : (I + t,I )grad u n. It appears on the right-hand side of the usual momentum equation (see bilsc2 and preduv).2 Proposition de modication des conditions aux limites de paroi turbulente pour le Solveur Commun dans le cadre du mod`le k standard, rapport EDF HI-81/00/019/A, 2000, M. Boucker, J.-D. Mattei. e 3 The transpose gradient term is treated in vissec and thus will not be considered here.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 35/312

In the case where the k model tends to surestimate the production of turbulent kinetic energy, the length scale of the model, Lk , can become signicantly larger than the maximum theoretical length scale of the turbulent boundary layer eddies Ltheo . We write : k2 Lk = C L theo = I F3

(II.2.3)

In the case where Lk > Ltho , we thus have t,I > lm with t,I the turbulent viscosity of the e t k model at point I and lm = I Ltheo uk the turbulent viscosity of the mixing length model. t Additionally, the tangential stress can write by making the turbulent viscosity appear : = I u u k = u I I F u k I Flm t

(II.2.4)

The viscosity scale introduced in the stress thus contradicts the one deduced from the neighbouring turbulence calculated by the model. Consequently we prefer to write the stress, by using the velocity scale of the k model when it is lower than the limit Ltho : e = u max(lm , t,I ) t I F (II.2.5)

One can then use this value to calculate the diusive ux which depends upon it in the Navier-Stokes equations : (I + t,I )grad u n = . But the velocity gradient (face gradient) is computed in the code as : (I + t,I )grad u n = (I + t,I ) (uF uI ) IF (II.2.7) (II.2.6)

Using (II.2.6) and (II.2.7) we obtain the value of uF to be prescribed, referred to as uF,f lux (conservation of the momentum ux) : uF,f lux = uI IF I + t,I u max(lm , t,I ) = uI t (I + t,I )

(II.2.8)

In reality, an extra approximation is made. It consists in imposing a zero normal velocity at the wall and in using equation (II.2.8) projected on the plane parallel to the wall : uF,f lux = u,I u max(lm , t,I ) t (I + t,I ) (II.2.9)

+ Moreover, if the value obtained for y + is lower than ylim a no-slip condition is applied. Finally, one can also make the wall velocity appear in the nal expression :

Flux boundary conditions of the velocity (k ) + if y + ylim uF,f lux = v p u max(lm , t,I ) otherwise ur uF,f lux = v p + t ,I (I + t,I )

(II.2.10)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 36/312

A rst pair of coecients Af lux and Bf lux can then be deduced (for each component of the velocity separately) and it is used only to compute the tangential stress dependent term (see bilsc2) : Coecients associated with the ux boundary conditions of the velocity (k ) + if y + ylim Af lux = v p u max(lm , t,I ) otherwise ur Af lux = v p + t ,I (I + t,I ) B f lux = 0 (II.2.11) We saw above how to impose a boundary condition to compute directly the stress term. Further analysis is necessary to calculate correctly the velocity gradients. We want to nd a boundary face value which permits to obtain, with the chosen expression for the gradient, the value the turbulent production as close as possible to its theoretical value (determined by using the logarithmic law), in order to evaluate the normal derivative the tangential velocity. Thus, we dene (at point I) : Ptho = I u uk e u nI

= I

uk (u )2 I F

(II.2.12)

Morevoer, the dominant term of the production computed in cell I is, in classical situations (y is the coordinate on the axis whose direction vector is n), Pcalc = t,I u y2

(II.2.13)I

The normal gradient of the tangential velocity (cell gradient) is calculated in the code using nite volume, and its expression on regular orthogonal meshes is (see the notations on gure II.2.2) : Pcalc = t,I u,G u,F 2d2

= t,I

u,I + u,J 2u,F 4d

2

(II.2.14)

We then assume that u,J can be obtained from u,I and from the normal gradient of u calculated in G from the logarithmic law : u,J = u,I + IJ . (y u )G + O(IJ 2 ) u,I + IJ . y and thus we obtain : Pcalc = t,I = t,Iu u,I + u,I + 2d 2d 2u,F 4d

u ln(y + ) + 5, 2 2

= u,I + 2dG

u (II.2.15) 2d

2u,I + 2 u 2u,F 2 4d

2

= t,I

u,I +

u 2

u,F

2

(II.2.16)

2d

We then use (II.2.12) and (II.2.16) to impose that the calculated production is equal to the theoretical production. The preceeding formulae are extended with no precaution to non-orthogonal meshes (the velocity at I is then simply computed at I ). The following expression for u,F is then obtained : u,F,grad = u,I u 2 1 I u k I F t,I 2 (II.2.17)

Additionally, we force the gradient to remain as sti as the one given by the normal derivative of the theoretical velocity prole (logarithmic) at I : u u y u = y ( ln(y + ) + 5, 2) = , thus : I F u,F,grad = u,I u max 1, 2 I u k I F 1 t,I 2 (II.2.18)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 37/312

Bord du domaine de calcul Domaine de calcul

J y

G

Id/2

M

Fd/2

d

d

d

11 00 11 00 11 00 11 00 n 11 00 11 00 de sortante1 normale norme 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00

Figure II.2.2: Cellule de bord - Maillage orthogonal. Finally, we clip the velocity at the wall with a minimum value calculated assuming that we are in the logarithmic layer : u,F,grad = max u 1 u + ln(ylim ) + 5, 2 , u,I max 1, 2 1 I u k I F t,I 2 (II.2.19)

+ The normal derivative at the wall is prescribed to zero. If the y + value at the wall is lower than ylim , a no-slip condition is prescribed. Finally, one can also make explicit the velocity of the wall in the nal expression :

Gradient boundary conditions of the velocity(k ) + if y + ylim uF,grad = v p uF,grad = v p + max u u 1 + ln(ylim ) + 5, 2 , ur max 1, 2 ,I 1 I u k I F t,I 2 otherwise (II.2.20) A second pair of coecients Agrad and Bgrad can then be deduced (for each velocity component separately). It is used when the velocity gradient is necessary (except for the terms depending on the tangential shear, those being treated in bilsc2 using Af lux and Bf lux ) : Coecients associated to the gradient boundary conditions of the velocity(k ) + if y + ylim Agrad = v p A grad = v p + max u B grad = 0 1 u + ln(ylim ) + 5, 2 , ur max 1, 2 ,I

I u k I F 1 t,I 2

otherwise (II.2.21)

Boundary conditions of the velocity in Rij The boundary conditions of the velocity with the Rij model are more simple, since there are only of one type. Keeping the same notations as above, we want the tangential velocity gradient (calculated

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 38/312

at I, and to be used to evaluate the turbulent production) to be consistent with the logarithmic law giving the ideal tangential velocity prole. The theoretical gradient is : Gtheo = u y =I

u I F

(II.2.22)

The normal gradient of the tangential velocity (cell gradient) is calculated in the code using nite volumes, and its expression in the case of regular orthogonal meshes is (see notations in gure II.2.2) : Gcalc = u,G u,F u,I + u,J 2u,F = 2d 4d (II.2.23)

We then assume that u,J can be obtained from u,I and from the normal gradient of u calculated in u G from the logarithmic law (see equation (II.2.15)) u,J = u,I + 2d and we thus obtain : 2d u,I + u,I + 2d Gcalc = u u u 2u,F 2u,F u,F 2u,I + 2 u,I + 2d 2 2 = = 4d 4d 2d

(II.2.24)

We then use the equations (II.2.22) and (II.2.24) to derive an expression for u,F (the preceeding formulae are extended with no precaution to the case non-orthogonal meshes, the velocity at I being simply computed at I ) : 3u (II.2.25) u,F = u,I 2 The normal derivative at the wall is prescribed to zero. If the value obtained for y + at the wall is + lower than ylim , a no-slip condition is prescribed. Finally, one can also make explicit the velocity of the wall in the nal expression : Boundary conditions of the velocity (Rij ) + if y + ylim uF = v p 3u + v p otherwise uF = ur ,I 2

(II.2.26)

Un couple de coecients A et B sen dduit (pour chaque composante de vitesse sparment) : e e e Coecients associs aux conditions aux limites sur la vitesse (Rij ) e + si y + ylim A = vp 3u + v p sinon A = ur ,I 2 B=0

(II.2.27)

A pair of coecients Agrad and Bgrad can be deduced from the above equation (for each velocity component separately). Boundary conditions of the velocity in laminar When no turbulence model is activated, we implicitly use a one velocity scale model (there is no turbulent variables to compute uk ), and the same conditions 4 as in Rij are used : the model degenerates automatically.

4 In

other words; the boundary conditions are given by (II.2.26) and (II.2.27).

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 39/312

Boundary conditions for k and (standard k model)

We impose k with a Dirichlet condition using the friction velocity uk (see equation (II.2.1)) : k= u2 k1 2 C

(II.2.28)

We want to impose the normal derivative of from of the following theoretical law (see the notations in gure II.2.2) : u3 /( y) k Gtheo, = (II.2.29) y We use point M to impose a boundary condition with a higher order of accuracy in space. Indeed, using the simple expression F = I + dy I + O(d2 ) leads to rst order accuracy. A second order accuracy can be reached using the following Taylor series expansion: 2 2 M = I d y I + d y I + O(d3 ) 2 82 (II.2.30) M = F + d y F + d 2 F + O(d3 ) 2 8 y By substracting these twxo expression, we obtain d F = I (y I + y F ) + O(d3 ) 2 Additionally, we have y I y F2 = y M + dy M + O(d2 ) 2 = y M dy M + O(d2 )

(II.2.31)

(II.2.32)

The sum of these last two expressions gives y I +y F = 2y M +O(d2 ) and, using equation (II.2.31), we nally obtain a second order approximation for F : F = I dy M + O(d3 ) (II.2.33)

The theoretical value (see equation II.2.29) is then used in order to evaluate y M and thus the value to prescribe at the boundary is obtained (d = I F ) : F = I + d u3 k (d/2)2 (II.2.34)

This expression is extended to non-orthogonal mesh without any precautions (which is bound to deteriorate the spatial accuracy ot the method). Additionally, the velocity uk is set to zero for y + are both zero. Finally we have : Boundary conditions for k and u2 k F = k 1 2 C u3 k F = I + I F (I F/2)2 + with uk = 0 if y + ylim+ ylim . Consequently, the value of k and the ux of

(II.2.35)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 40/312

and the associated pair of coecients Coecients associated to the boundary conditions of k et 2 A = uk and Bk = 0 1 k 2 C u3 k A = I F and B = 1 (I F/2)2 + + with uk = 0 if y ylim

(II.2.36)

Boundary conditions for Rij and (standard Rij model)

The boundary conditions for the Reynolds stresses in the coordinate system attached to the wall write (R refers to the local coordinate system) : n R = n Rnn = n Rbb = 0 et R n = u uk et R b = Rnb = 0 (II.2.37)

+ Additionally, if the value obtained for y + is lower than ylim , all Reynolds stresses are set to zero (we assume that the turbulent stresses are negligible compared to the viscous stresses).

Although it is done systematically in the code, expressing the above boundary conditions in the computation coordinate system is relatively complex (rotation of a tensor): the reader is referred to the documentation of clsyvt where more details are provided. In what follows, the boundary conditions will only be presented in the local coordinate system. Thus we want to impose the boundary values : Boundary conditions of Rij + if y + ylim R,F = R,F = 0 R,F = R,I with {, n, b} (without summation) otherwise n = u uk and R b = Rnb = 0 R

(II.2.38)

For the dissipation, the boundary condition applied is identical to the one applied with the k model : Boundary conditions of (Rij ) u3 k F = I + I F (I F/2)2 + with uk = 0 if y + ylim

(II.2.39)

These boundary conditions can be imposed explicitly (by default, ICLPTR=0) or (semi-)implicitly ( ICLPTR=1). The standard option (explicit) leads to the following values5 of the coecients A and B:5 It

can be noticed that the value of is not reconstructed at I . We thus wish to improve the stability since 1 ), and thus only weak recontruction errors at I could lead to important y deterioration of the results. However, it would be necessary to check if stability is altered with the gradient reconstruction of gradrc. has a very steep gradient at the wall (

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 41/312

Coecients associated to the explicit boundary conditions of Rij et + + ylim : If y AR = AR = 0 and BR = BR = 0 Otherwise : and BR = 0 with {, n, b} (without summation) AR = (R )I AR n = u uk and BR n = 0 AR b = AR = 0 and BR b = BRnb = 0 And for all cases : nb u3 k A = I + I F and B = 0 (I F/2)2 + with uk = 0 if y + ylim (II.2.40) The semi-implicit option leads to the following values for the coecients A and B. They dier from the preceeding ones, only as regards as the diagonal Reynolds stresses and dissipation. In the general case, impliciting of some components of the tensor in the local coordinate system leads to partially impliciting all the components in the global computation coordinate system : Coecients associated to the semi-implicit boundary conditions of sur les variables Rij et + If y + ylim : AR = AR = 0 and BR = BR = 0 Sinon : and BR = 1 with {, n, b} (without summation) AR = 0 AR n = u uk and BR n = 0 AR b = AR = 0 and BR b = BRnb = 0 And for all cases : nb u3 k and B = 1 A = I F (I F/2)2 + + with uk = 0 if y ylim (II.2.41)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 42/312

Boundary conditions of the VarScalaires Only the boundary conditions when a boundary value is imposed (at the wall or away from the wall with a possible external exchange coecient) are treated here. The reader is referred to the notations in gure II.2.1 and to the general presentation provided in condli (in what follows only the most essential part of the presentation is repeated). The conservation of the normal ux at the boundary for variable f writes : himp,ext (fimp,ext fb,ext ) (Dirichlet condition) real imposed hint (fb,int fI ) = hb (fb,ext fI ) = (Neumann condition) imp,ext int b

real

imposed

(II.2.42) The above two equation are rearranged in order to obtain the value of the numerical ux fb,int = fF to impose at the wall boundary face, according to the values of fimp,ext and himp,ext set by the user, and to the value of hb set by the similarity laws detailed hereafter. The coecients A and B can then be readily derived, and are presented here. Boundary conditions of the VarScalaires hint himp,ext hint + himp,ext (hr 1) fimp,ext + fb,int = fI with hr = hint + hr himp,ext hint + hr himp,ext hbA B

(II.2.43)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 43/312

Similarity principle : calculation of hb . The only remaining unknown in expression (II.2.43) is the value of hb , since hint has a numerical value ). The which is coherent with the face gradient computation options detailed in condli (hint = IF value of hb must relate the ux to the values fI and fb,ext by taking into account the boundary layer (the prole of f is not always linear) : b = hb (fb,ext fI ) (II.2.44)

The following considerations are presented using the general notations. In particular, the Prandtl C Schmidt number writes = . When the considered scalar f is the temperature, we have (see condli) C = Cp (specic heat capacity), = (molecular conductivity), = Cp = P r (Prandtl number),

t = P rt (turbulent Prandtl number), = + Cp t t T (ux in W m2 ). y

The reference Convection Heat Transfer, Vedat S. Arpaci and Poul S. Larsen, Prentice-Hall, Inc was used. The ux at the wall writes for the scalar f (the ux is positive if it enters the uid domain, as shown by the orientation of the y axis) : = +C t t f = C y t + C t f y (II.2.45)

Similarly for the temperature, with a =

t and at = , we have : Cp t = Cp (a + at ) T y (II.2.46)

In order to make f dimensionless, we introduce f dened using the ux at the boundary b : f = For the temperature, we thus have : T = b Cp uk (II.2.48) b C uk (II.2.47)

We then divide both sides of equation (II.2.45) by b . For the left-hand side, we simplify using the conservation of the ux (and thus the fact that = b ). For the right-hand side, we replace b by its value C uk f . With the notations : = we have : 1= 1 1 t + t t = t y+ = y uk f + y + f+ = f fb,ext f (II.2.49)

(II.2.50)

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 44/312

One can remark at this stage that with the notations used in the preceeding, hb can be expressed as + a function of fI : b C uk (II.2.51) hb = = + fb,ext fI fI+ In order to compute hb , we integrate equation (II.2.50) to obtain fI . The only diculty then consists 1 1 t in prescribing a variation law K = + . t

In the fully developed turbulent region (far enough from the wall, for y + hypothesis models the variations of t : t = l2 | U | = y u y

+ y2 ), a mixing length

(II.2.52)

Additionally, the molecular diusion of f (or the conduction when f represents the temperature) is 1 t 1 compared to . Finally we negligible compared to its turbulent diusion : therefore we neglect t 6 have : y+ K= (II.2.53) t+ On the contrary, in the near-wall region (for y + < y1 ) the turbulent contribution becomes negligible 1 t 1 compared to the molecular contribution and we thus neglect compared to . t

It would be possible to restrict ourselves to these two regions, but Arpaci and Larsen suggest the + + model can be improved by introducing an intermediate region (y1 y + < y2 ) in which the following hypothesis is made : t = a1 (y + )3 (II.2.54) where a1 is a constant whose value is obtained from experimental correlations : a1 = t 1000 in gure 2.2) :+ if y + < y1 + if y1 + if y2 + y + < y2

(II.2.55)

Thus the following model is used for K (see a sketch 1 1 a1 (y + )3 + K= t y+ t

(II.2.56)

y+

+ + The values of y1 and y2 are obtained by calculating the intersection points of the variations laws used for K.

The existence of an intermediate region depends upon the values of . Lets rst consider the case where cannot be neglected compared to 1. In practise we consider > 0, 1 (this is the common case when scalar f represents the air or the water temperature in normal temperature and pressure 1 a1 (y + )3 conditions). It is assumed that can be neglected compared to in the intermediate region. t We thus obtain : 1 1000 3 1000 + + (II.2.57) y1 = y2 = t6 We

make the approximation that the denitions of y + from u and uk are equivalent.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide14 12 10 8 K 6 4 2 0 y+1

Code Saturne documentation Page 45/312

1/Pr 0.42 y+/Prt a1 (y+)**3/Prt

y+2

0

10 y+

20

30

Figure II.2.3: (a + at )/ as a function of y + obtained for = 1 and t = 1. The dimensionless equation (II.2.50) is integrated under the same hypothesis and we obtain the law of f + : + + + if y + < y1 f = y + t + + f = a2 if y1 y + < y2 (II.2.58) 2 a1 (y + )2 + f = t ln(y + ) + a3 if y + y + 2 where a2 and a3 are integration constants, which have been chosen to obtain a continuous prole of f+ : 2 2 t 1000 a2 = 15 3 a3 = 15 3 1 + ln (II.2.59) 2 t Lets now study the case where is much smaller than 1. In practise it is assumed that 0, 1 (this is for instance the case for liquid metals whose thermal conductivity is very large, and who have Prandtl number of values of the order of 0.01). The intermediate region then disappears and the coordinate of the interface between the law used in the near-wall region and the one used away from the wall is given by : t + y0 = (II.2.60) The dimensionless equation (II.2.50) is then integrated under the same hypothesis, and the law of f + is obtained : + + if y + y0 f = y+ + t y (II.2.61) + + ln + y0 if y0 < y + f+ = + y0

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 46/312

To summarize, the computation of hb hb = b C uk = + fb,ext fI fI (II.2.62)

+ + is performed by calculating fI from y + = yI using the following laws.

If

0, 1, a two-layer model is used : + f = y+ t ln f+ =

if y + y + y0+ + + y0

+ y0

+ if y0 < y +

(II.2.63)

with+ y0 =

t

(II.2.64)

If > 0, 1, a three-layer model is used : + + f = y + t f = a2 2 a1 (y + )2 f + = t ln(y + ) + a3 with+ y1

+ if y + < y1 + + if y1 y + < y2

(II.2.65)

if

+ y2

y

+

=

1000

1 3

+ y2 =

1000 t 1000 t

(II.2.66)

and a2 = 15 32

a3 = 15 3

2

t 2

1 + ln

(II.2.67)

2.3

Implementation

This subroutines treats the variables IVAR on the faces IFAC for which ICODCL(IFAC,IVAR)=5. First the velocity of the wall (possibly zero) is projected onto the plane parallel to the wall. Its three components in the computation coordinate system are stored in the arrays RCODCL(IFAC,IUIPH,1),RCODCL(IFAC,IVIPH,1)RCODCL(IFAC,IWIPH,1). We then compute the local coordinate system R. For each face, it is stored in the vectors (TX, TY, TZ), n (-RNX, -RNY,-RNZ), and b (T2X, -T2Y,-T2Z). It should be noticed that the third vector is only needed (and thus only calculated) when the Rij model is used (for the second order tensor projection). Additionally, if the norm of the tangential velocity is lower than the arbitrary value EPZERO (1012 ), the indicator TXN0 is set to 0 (it is 0 otherwise) and the vector is - chosen arbritrarily, in the plane orthogonal to n in Rij (the components of n are used to construct ; if n is the zero vector, the code stops) ; - zero, otherwise. Once the local coordinate system has been calculated, the subroutine clca66 is called with 7 CLSYME =0 (if the Rij model is activated) in order to compute the matrix ALPHA. The latter will be used to compute the values to prescribe at the boundary, using the the values of the Reynolds stress tensor at the points I .7 CLSYME = 0 indicates that we consider wall boundary conditions and not symmetry boundary conditions. One is referred to CLSYVT for more details on clca66.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 47/312

The friction velocities are then computed and stored in UET (= u ) and UK (= uk ). The subroutine causta computes the friction velocity for the one velocity scale model (IDEUCH=0). Fot the two velocity scale model (IDEUCH=1), the (more simple) computation of UET and UK is performed directly in clptur. If one velocity scale model is activated, we impose UK=UET to keep the coherence of the coding in the following of the subroutine. However, if we are in the viscous sublayer, we force UK=0 to obtain a zero value for k and a zero ux for (the value UET is not used, because the condition of the velocity is a no-slip condition and the Reynolds stresses are zero). If we are in the viscous sublayer, we compute UET again (and YPLUS if we use the one velocity scale model) since the previous derivation has been made under the assumption that we were in the logarithmic region. The boundary conditions for the velocity are then completed. - In k , the coecients Af lux (coming from the analysis of the tangential velocity) for the three components of the velocity are stored in COEFA(IFAC,ICLUF), COEFA(IFAC,ICLVF) et COEFA(IFAC,ICLWF) , respectively. Similarly, the coecients Bf lux are stored in COEFB(IFAC,ICLUF), COEFB(IFAC,ICLVF) et COEFB(IFAC,ICLWF). The boundary conditions coming from the analysis of the velocity gradient Agrad and Bgrad are stored in COEFA(IFAC,ICLU), COEFA(IFAC,ICLV), COEFA(IFAC,ICLW) and COEFB(IFAC,ICLU), COEFB(IFAC,ICLV), COEFB(IFAC,ICLW). - When the tangential velocity at I is lower than EPZERO, the indicator TXN0 is set to zero (otherwise, TXN0 is 1). Likewise, when the value of y + is lower or equal to 10, 88, the indicator UNTURB is set to 0 (otherwise, it is 1). Both these indicators are used to set to zero the coecients A, and thus to prescribe no-slip boundary conditions. - the velocity of the wall is taken into account in the boundary conditions (coecients COEFA). The conditions of the turbulent variables are then lled in. Additional details are provided for the t Reynolds tensor in Rij . Using tensorial notation, we want to obtain RF = Eloglo RF Eloglo , where RF is the stress tensor to impose in the local coordinate system and Eloglo is the transformation matrix. The tensor in the local coordinate system is dened by the boundary conditions detailed B=1 above, RF = RF , with 8 : R ,I = Bu uk RF 0B

Bu uk Rnn,I 0

0 0 bb,I R

(II.2.68)

The Reynolds tensor is stored in a vector with 6 components (at points I of the boundary faces, these values are stored in RIJIPB(IFAC,II), with IFAC the index of the face and II the index of the stress, from 1 to 6 II refers to R11 , R22 , R33 , R12 , R13 and R23 , respectively. The array IFAC of dimension 66 (calculated by clca66) is used to perform the necessary change of coordinate system computations, B=0 from the values stored in RIJIPB(IFAC,II). Thus, and to obtain the values of RF8 The

parameter B permits to set to zero two terms if needed.

EDF R&D

Code Saturne 2.0.0-rc1 Theory and Programmers Guide

Code Saturne documentation Page 48/312

- for each Reynolds stress ISOU, in case of explicit boundary conditions (ICLPTR=0), we set COEFA(IFAC,ISOU) to the corresponding value of RB=1 obtained by rst computing RB=0 by F F II=1,6 ALPHA(ISOU,II)*RIJIPB(IFAC,II), and then by adding the quantity factorised by B in the previous sum, in order to obtain the complete value of RB=1 . Since the boundary conditions F are explicit, COEFB is set to 0. - in case of semi-implicit boundary conditions (ICLPTR=1), for each Reynolds stress ISOU, we store in the array COEFA(IFAC,ISOU) the corresponding value RB=1 minus the terms which depend F upon RIJIPB(IFAC,ISOU) (which will be implicited) This value is obtained by rst calculating II=1,6|II=ISOU ALPHA(ISOU,II)*RIJIPB(IFAC,II), and then by adding the quantity factor