chapter 4 numerical implementations, i, the solve4les and...

30
39 Chapter 4 Numerical implementations, the Solve4kI, the Solve4LES and the CFX codes In this chapter a description of the numerical code developed to perform Large Eddy Simulation for ventilation enclosures is given. Due to the high demands on memory and computational time when doing LES , it has been necessary to developed a special purpose code that could take advantage of the architecture of modern high performance workstations and supercomputers. As already stated, LES implies using a relatively fine mesh in three dimensions in order to resolve the more important time-dependent flow features. From a numerical point of view this implies, that we have to average over a certain time interval, i.e. large time steps would be desirable to reduce the number of time steps. Since the easy gain in computational speed is over, more effort was put into the development and the implementation of an efficient numerical algorithm. Therefore, both an explicit and an implicit fractional step method has been tested together with an advance solver, either based on a multigrid technique or a Krylov subspace method with a suitable preconditioning method. Finally, a short description of the implementation of the Large Eddy Simulation model and three different subgrid scale models into the commercial CFD code CFX version 4.2 is presented. 4.1 Introduction The numerical discretization of the Navier-Stokes equations and the procedures needed to solve the resulting discretized system of equations is presented in this chapter. The description provided by the author will give a brief review of and highlight the computational methods employed, that are considered to be of interest to this project. Further information about the numerical implementation and a user guide to the programme developed are provided in Bennetsen (2001). The original idea was to use the commercial software, CFX, and implement the LES method into this code by using the user Fortran interface to the code. But due to the inefficiency of the code, although

Upload: trinhhuong

Post on 02-May-2018

220 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

39

Chapter 4

Numerical implementations,the Solve4kIIII, the Solve4LES and the CFX codes

In this chapter a description of the numerical code developed to perform Large EddySimulation for ventilation enclosures is given. Due to the high demands on memory andcomputational time when doing LES , it has been necessary to developed a special purposecode that could take advantage of the architecture of modern high performance workstationsand supercomputers. As already stated, LES implies using a relatively fine mesh in threedimensions in order to resolve the more important time-dependent flow features. From anumerical point of view this implies, that we have to average over a certain time interval,i.e. large time steps would be desirable to reduce the number of time steps. Since the easygain in computational speed is over, more effort was put into the development and theimplementation of an efficient numerical algorithm. Therefore, both an explicit and animplicit fractional step method has been tested together with an advance solver, either basedon a multigrid technique or a Krylov subspace method with a suitable preconditioningmethod. Finally, a short description of the implementation of the Large Eddy Simulationmodel and three different subgrid scale models into the commercial CFD code CFX version4.2 is presented.

4.1 IntroductionThe numerical discretization of the Navier-Stokes equations and the procedures needed to solve theresulting discretized system of equations is presented in this chapter. The description provided by theauthor will give a brief review of and highlight the computational methods employed, that are consideredto be of interest to this project. Further information about the numerical implementation and a user guideto the programme developed are provided in Bennetsen (2001).

The original idea was to use the commercial software, CFX, and implement the LES method intothis code by using the user Fortran interface to the code. But due to the inefficiency of the code, although

Page 2: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

40

Solver

Solve4k… Solve4LES

Laminar and Turbulent flows: k- model…=

Turbulent flows: Large Eddy Simulation: Subgrid Scale Model: Smagorinsky. Dynamic model. Dynamic One-eq. model.

Figure 4.1: Basic structure of the Solver code.

it is very general and supplied with many different turbulence models to perform Reynolds AveragedSimulation it was not sufficient for LES in terms of computational efficiency.

Therefore, the author decided to start a new code, which should be able to handle the currentgeometry used in this project and which should be efficiently implemented to take advantage of thearchitecture of modern high performance workstations (and supercomputers). The current implementationis able to compute two or threendimensional steady/unsteady, turbulent/laminar internal flows (Figure4.1).

Usually, geometric flexibility is one of the key issues in the development of a CFD code, thus allowingit to be used as a practical aid to study complex geometries. Although a considerable level of flexibilitycan be attained with a single-block structured grid (providing non-orthogonality is permitted), there willbe many applications notably involving multiple connected computational domains which cannot bemeshed with a single-block structured grid. Alternative routes for complex geometries and flexibility arebased on unstructured or/and block-structured grids. Both methods have weaknesses and strengths.

However, structured grids are well-posed towards an accurate near-wall resolution, and they allowthe use of a well-established structured grid solver like the Alternating Direction Implicit (ADI), theStrongly Implicit Procedure (SIP), the Preconditioned Conjugate Gradient method and the Multigridmethods. These methods are rather simple to implement on structured grids compared to unstructured ormulti-block grid solvers.

Since one of the primary issues has been to reduce the total computational time when studyingunsteady flows, the framework started here only features a single-block implementation with a non-orthogonal grid, and thereby the influence of the implemented methods for handling unsteady flows withthe LES model and different subgrid scale models are studied. The extension to multi-block grids hasbeen postponed and will not be studied in this project. However, the current implementation does supportthe

Page 3: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

41

use of body-fitted coordinates by using geometric transformations of the physical geometry into acomputational geometry to allow more complexity of the problems.

First of all, a good initial guess is needed to avoid spending too much time on calculating an initialflow field which at the end would probably be approximated in some form by the Large Eddy Simulationmodels. Therefore, an initial guess based on a RANS solution (a laminar or a two-equation turbulencemodel) will be needed at first. The LES computation could then be restarted from here.

In the following sections a description of the different programmes for calculating laminar andturbulent flows using either the k-I two-equation turbulence model or the different subgrid scale modelsfor large eddy simulation is given.

4.2 The numerical methods of Solve4kIIII for laminar and turbulent flows.In the following section a review of the theory of the flow solver, Solve4kI, is presented. Specifically,a description of the various issues involved with the pressure-based algorithm and features like thediscretization schemes employed in the present code is given. Usually, the discretization schemes can beclassified into two different categories, where the first one has primarily been developed forincompressible flows and is differentiated by the geometric shape of the interpolation function used toestimate the fluxes on a control volume interface. The category includes schemes like the first-orderupwind, the central difference, the second-order upwind and the QUICK (Quadratic Upwind Interpolationfor Convective Kinematics) (Vanka, 1987, Shyy et al., 1992, Thakur and Shyy, 1993, Leonard, 1979).

A second category is the controlled variation schemes (CVS), which have mainly been developedfor resolving sharp gradients, such as shock waves in compressible flows, and which are therefore not ofinterest here.

The current implementation is based on the solution of the partial differential equations governingthe flow. The Navier-Stokes equations for incompressible flow are written in a curvilinear coordinatesystem. Here the physical geometry is mapped into a more simple rectangular geometry, which is thecomputational space (Fig 4.2). This is done by use of curvilinear coordinate transformation. Thefinitenvolume method is applied to transform the partial differential equations to algebraic relationswhich link the values of the dependent variables at the nodes of the computational grid. A collocated gridarrangement has been used, which means that it uses Cartesian velocity components, and that all variablesare stored in the centre of each control volume (see Ferziger & Peric, (1996) and Versteeg &Malalasekera (1995)) for further reference. The methods were first introduced by Rhie and Chow (1983).In order to solve the given set of equations in a segregate way, a Tri-Diagonal Matrix Algorithm (TDMA),(see Anderson, (1984)) or a Strongly Implicit Procedure (SIP),(Stone, 1968) or a Modfied StronglyImplicit Procedure (Schneider and Zedan, 1981) were implemented.

In order to achieve closure for the Reynolds-Averaged Navier-Stokes equations for the turbulentflow, the well-known two-equation k-I model (Jones and Launder, 1972) were implemented. To account

Page 4: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

42

Physical Geometry Computational Geometry

x

yK

M

K

M

K= K= (x,y)M= M= (x,y)

x = x( , )K My = y( , )K M

Figure 4.2: Two-dimensional example of the mapping of physicalspace into the computational space.

(4.1)

(4.2)

for the viscous effects near solid walls, a wall function defining the velocity profile in the vicinity of theno-slip boundary were used. Furthermore, a modification to the standard two-equation k-I model, whichinvolves separating the flow into two parts were used. In the mean flow region away from the solid wallsthe flow were solved with the standard k-I model, and in the near-wall region a different model whichaccurately resolves the boundary layer were used. The present implementation uses the one-equationmodel described Chen and Patel (1988), which is based on a modified model after Wolfshtein (1967).

4.2.1 The Finite Volume methodNow, consider the incompressible Navier-Stokes equations where there is a general variable k. Then theconservative form of all fluid flows, which also includes equations for scalar quantities, such astemperature and pollutant concentration, etc. can be written as the following expression:

where Dk is the diffusion coefficient equal to the viscosity in the momentum equations. This equationis also known as the transport equation for the property k .The dependent variable k can be 1 (one) forthe continuity equation and equal to e.g. u, v, w, k, I and T. The key step of the finite volume method isthe integration of previous equations over a three dimensional finite control volume CV yielding:

Page 5: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

43

(4.3)

(4.4)

P

N

S

W Eew

n

s

Boundary nodes

Cell Centered nodesfor a control volume

Control Volume

Face of a control volume

Figure 4.2: Control volume with discretizationstencil in two dimensions.

(4.5)

(4.6)

(4.7)

If the Gauss divergence theorem are applied, the equations will be as follows

If Q i is defined as the sum of total flux, the convective and diffusive fluxes will be

The scalar convection-diffusion Eqn. (4.3) is discretized, and the integration thereof will be as follows

where the subscripts e, w, n, s, h, l refer to the face of the control volume, east, west, north, south,high, and low (Fig 4.3). By use of a discretization schemes, the non-linear equation can be transformedinto a set of algebraic linear equations for all the grid points. For any grid point denoted p in thecomputational domain, the discretized equations can be rearranged into

where nb denotes the neighbouring grid point of p and where

Page 6: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

44

(4.8)

(4.9)

(4.10)

(4.11)

and

It should, however, be noted that the source term has been linearlized by using and where has been used in order to enhance the diagonal dominance for

the resulting coefficient matrix (Patankar (1980) and Versteeg and Malalasekera (1995)). In the sourceterm b the pressure gradient has been included for the momentum equations.

4.2.2 The transformation relationship from physical geometry to computational geometryWhen dealing with a curvilinear coordinate system the Cartesian flow equations should be transformedinto the actual computational coordinate system. The mapping of the physical domain (x,y,z) to thecomputational domain ([, M, K ), where [ = [(x,y,z) , M = M(x,y,z) and K = K(x,y,z), is achieved via transformation metrics which are related to the physical coordinates as follows (Anderson et al., (1984)):

where

and where the expression has been calculated by using the rule of chain:

The metric terms that are used in the transformation and the inverse transformation can be expressedin matrix notation as follows:

Page 7: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

1 Peclet number: Pe=aUL/D, where L is a characteristic length and D is the diffusivity,expressing the ratio of convection to diffusion.

45

(4.12)

(4.13)

Transformation Inverse Transformation

Finally, the Jacobian J of the transformation is given as

Since only the Cartesian grid is used in this project, the illustration of the transformations of equationshas been omitted. Further reference, see Anderson et al., (1984).

4.2.3 The discretization schemesBefore the algebraic equations can be assembled, the evaluations of the terms representing the convectionand diffusion will have to be attended to. The diffusion terms in the Navier-Stokes equations are generallyapproximated by the standard second-order central difference schemes, which for the second derivativesare quite well-behaved. Because of this, only the central difference schemes have been implemented forthe diffusional term.

On the other hand, the second-order central difference operator for the first derivative convectionterms, though quite accurate for low cell Peclet1 numbers, give rise to wiggles when the local cell Pecletnumber is greater than some critical value (Shyy (1985), Gresho & Lee (1981)).

To overcome this problem, the upwind scheme has been widely used, but it introduces somenumerical dissipation inherent to this scheme whichs is often a necessity to obtain a stable flow solution.To take advantage of the concept of upwinding, while achieving higher accuracy, higher-order upwindschemes, such as the QUICK (Leonard 1979, 1988) schemes, have been proposed. Within the code, thereare three possible ways of discretizating to the convection term, i.e. the Hybrid, the Central differencingand the QUICK schemes.

The Hybrid Upwind / Central Differencing SchemesThis discretization scheme is first order accurate (marginally second order) and approximates theconvective terms by using either the central differencing or upwind scheme based on the value of the local

Page 8: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

46

(4.14)

EPW w e

U < 0e

U > 0e

EŒ= Œ= e

Œ= Œ= Pe

face

ControlVolume node

Figure 4.3: First-order UpwindScheme; Constant Extrapolation(Assuming uniform grid ).

EPW w e

U < 0e

U > 0e

face

ControlVolume node

EŒ= Œ= Œ== ( + )e ½ P

EŒ= Œ= Œ== ( + )e ½ P

ŒE

ŒE

Figure 4.4: Second-order CentralDifference Scheme; Linear Interpolation (Assuming uniform grid).

(4.15)

(grid) Reynolds number. When it is below the critical value of two, the central differencing is appliedor else the upwinding scheme is applied.

From Figure 4.3, the east face of a control volume is calculated as:

where is the interpolation factor which is equal to 0.5 when the face e lies midway between P andE. The Hybrid schemes are often used in conjunction with the kinetic energy and dissipation equations,where the accuracy of the schemes do not affect the computation very much. The difference between theupwind and the central difference schemes is illustrated in the following two Figures 4.4 and 4.5.

The QUICK SchemeThe QUICK schemes (Leonard, 1979) use a quadratic interpolation between two upstream neighboursand one neighbour downstream in order to estimate the k value at any control volume interface.Depending on the sign of the face velocities at any interface, k can be estimated by the quadraticinterpolation; for example at the east face:

Page 9: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

2 Boundedness: The solution is said to be bounded if the solution value in a computational point is bounded bythe solution values in the surrounding points, or rather those of the surrounding points, which influence the point. Diagonaldominance is a pre-requisite for boundedness. For advective-diffusive problems, a centered difference discretization may, forcell Reynolds numbers or cell Peclet numbers exceeding 2, lead to locally non-limited solutions, typically of oscillatorycharacter (= unbound).

47

EPW w e

U < 0e

U > 0e

face

ControlVolume node

ŒE

WW EEŒ

E

EEŒ

EŒ= Œ= Œ= Œ== + - 3/8 3/4 1/8e P EE

EŒ= Œ= Œ= Œ== + - 3/4 3/8 1/8e P W

Figure 4.5: The QUICK scheme; QuadraticInterpolation.(Assuming uniform grid).

One should note that this scheme is unbound2 which means that it can give rise to problems. TheQUICK scheme is a form of upwinding, combining the accuracy of the central scheme and the stabilityof the upwind scheme.

4.2.4 The Pressure-Velocity Solver for the Naiver-Stokes equationsTo solve the pressure-velocity coupling between the equations, the process of solution is based on theiterative SIMPLEC algorithm by Van Doormal and Raithby (1984), which follows the same step as theSIMPLE algorithm by Patankar (1980), the difference being that the momentum equations aremanipulated. This is done in such a way that the velocity correction equations in the SIMPLEC algorithmhave omitted less important terms. The implementation of the SIMPLEC method following the derivationin Nilsson and Davidson, (1998) will not be repeated here.

4.2.5 Turbulence Modelling and Wall Boundary ConditionTo solve the turbulent flow a two-equation model is applied, which will solve one differential equationfor the velocity scale and another equation for the length scale. The major advantage of the two-equationsmodel is that the length is solved rather than prescribed. The turbulence model applied within Solve4kIIIIfollows the description in Renard and Gresser (1995), which also lists the given wall boundaryconditions.The turbulent flow is then separated into two parts. One is near the wall region where the flow is solvedby using a model which can resolve the boundary layer accurately. This other one is the main flow regionwhere the k-I equations are used. The one-equation model by Wolfshtein, and later modified by Chenand Patel is used in the present case.

In the commercial CFD code CFX many different two-equation models exist (see Appendix B), buta k-I with a two-layer model was not included. Therefore, it was included in the Solve4kIIII code. Theorigin of the two layer model is the standard k-I turbulence model:

Page 10: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

48

(4.16)

(4.17)

(4.18)

(4.19)

(4.20)

(4.21)

where

and . At the walls a one-equation model can be applied. For example the one-equation

model compiled by Wolfshtein (1969) and later modified by Chen and Patel (1988). During thesimulation the standard k-equations can be solved and the diffusional term in the k-equations can bemodelled using the eddy viscosity concept. The turbulent length scales will then described as follows

where Rn is the Reynolds number, and n is the wall normal distance. This means that the dissipation termin the k-equation and the turbulent viscosity can be obtained from

The constants in the equations above are defined as:

The one-equation model is used only close to the walls on a chosen grid line where the wall normaldistance is approximable y+ ³ 50 and the standard k-I model is used in the outer part of the flow. Renardand Gresser (1995) have also been studying the model and they discuss further how it can beimplemented.

As mentioned before the solve4kIIII was primarly used to provide an initial velocity field for theLarge Eddy Simulation that was a restart from the k-I solution. Basically, in order to reduce the totalamount of time to perform a given Large Eddy Simulation. There are many issues governing the choiceof a discretization method, equations solver and the solution accuracy and efficiency, ease ofprogramming,

Page 11: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

49

(4.22)

(4.23)

computer memory, storage requirements, etc. that have to dealt with. A suitable choice of numericalalgorithm is especially important in dealing with a timendependent solution because the number of timesteps could be very large.

The present version of the solve4kI code was sufficient to provide initial conditions for the later useof LES. No special optimization was used for the present version.

In the following section, the next module of the Solver code, the Solve4LES, which deals with somedifferent approaches to reduce the level of computational requirements will be dealt with.

4.3 The numerical basic of Solve4LESHistorically, the early LES users have all used finite difference/volume methods, e.g., Deardorff (1970)and Schumann (1975). However, in the early 1980s, the spectral method was the main numerical tool usedboth in LES and DNS studies. The spectral method is well- known for its high accuracy, especially forproblems with periodic boundary conditions and a continuous solution. Nevertheless, it is generally moreexpensive to use the method and more difficult to generalize complex geometries. Furthermore, Rai andMoin (1989) have shown that their higher order finitendifference schemes could have an accuracycomparable to that of the spectral method for DNS applications. Recently, more and more DNS/LESstudies have employed the finite difference/volume method (Akselvoll & Moin, 1993; Choi & Moin,1994; Zang et al., 1993; Sreedhar & Ragab, 1994, Breuer, 1998, Chollet et al., 1997, Liu & Liu, 1997,Piomelli, 1999, Piomelli, 1996. Rodi et al., 1996. Voke et al., 1996 and Tafti, 1996).

Consequently, with the future goal of applying LES to more complex geometries, the finite volumemethod was adopted here to carry out the numerical solution of the NaviernStokes equations. The basicstructure of this new code reassembles that of the previously described Solve4kIIII.When LES is used in this context of the volume average approach (known as the box or top-hat filtering),the time-dependent, three-dimensional Navier-Stokes equations are solved.

The incompressible Navier-Stokes and the continuity equations will be integrated in time by using afractional step-like method. There are a number of ways to solve the equations above numerical, anexplicit and an implicit one.

Page 12: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

3) CFL-number is defined as , where Fx, Fy and Fz arethe grid spacing in the Cartesian coordinates.

50

The Implicit versus Explicit MethodsNumerical solution schemes are often referred to as being explicit or implicit. When a direct computationof the dependent variables can be made in terms of known quantities, the computation is said to beexplicit. In contrast, when the dependent variables are defined by coupled sets of equations, and wheneither a matrix or an iterative technique is needed to obtain the solution, the numerical method is said tobe implicit.

In computational fluid dynamics, the governing equations are non-linear, and the number ofunknown variables is typically very large. Under these conditions, implicitly formulated equations arealmost always solved by use of iterative techniques. Iterations are used to advance the solution througha sequence of steps from an initial state to a final, converged state. In either case, the iteration steps willresemble a time-like process. Of course, the iteration steps usually do not correspond to a realistictime-dependent behaviour. In fact, it is this aspect of an implicit method that are it attractive forsteady-state computations, because the number of iterations required for a solution is often much smallerthan the number of time steps needed for an accurate transient solution that asymptotically approachessteady conditions.

On the other hand, it will also be this “distorted transient” feature that leads to the question "Whatare the consequences of using an implicit versus an explicit solution method for a time-dependentproblem?" There will be two answer to this question. One which has to do with numerical stability and one withnumerical accuracy.

The principal reason for using implicit solution methods, which are more complex to program andrequire more computational effort in each solution step, is to allow for large time-step sizes. In an implicitformulation, a solution for the unknowns at level n+1 may be obtained for any size time step. Of course,the solution for very large timesteps may not be realistic.

When the time step is sufficiently small only one iteration will be necessary for convergence. This is true for both the explicit and the implicit method. The limits for the stability of the explicit method isdetermined by the CFL3- number < 1. An explicit method would be unstable, but implicit methods simplyunder-relax more to maintain the stability of the iterative solution. It is this increased damping, with theincrease in time-step size, that could produce inaccuracies in transient behaviour.

For many Large Eddy Simulations it has been common practice to treat all diffusive terms implicitlyand all convective terms explicitly. The motivation for treating the diffusive terms implicitly is the severetime-step restriction that originates from these terms near the solid walls, where the computational gridis refined. The convective terms do not introduce the same limitations, because the velocity componentsclose to the solid wall are generally small.

In the following both an explicit and implicit method for time-advancement has been implemented.

Page 13: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

51

(4.24)

(4.25)

(4.28)

(4.29)

4.3.1 General description and methodsThe basic structure of the Solve4LES code reassembles that of the Solve4kI code which is based on a3nD finitenvolume method for solving the incompressible NaviernStokes equations employing a cell-centred arrangement of variables. Both convective and viscous fluxes are approximated by centraldifferences of second order accuracy. The momentum equations are solved with the traditionalGaussnSeidel or versions of the Strongly Implicit Procedures method, whereas a Krylov subspace(Conjugate Gradient) or multigrid method are used for the acceleration of convergence when solving thepressure equations for both the explicit and implicit method.

4.3.2 The Explicit MethodThe filtered Navier-Stokes equations (Eqns. (4.22) and (4.23)) above are numerical integrated in time bya two-stage fractional step procedure with Adam-Bashfort explicit differencing for both convective anddiffusion terms:

which gives:

where is an intermediate velocity field, and is given by

and where the time derivate has been discretized as:

within a single time step. Here the same methods as in Davidson and Nielsen (1996) have been appliedin order to circumvent the problem that the pressure term appears implicitly in Eqn. (3.15).

Page 14: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

52

(4.30)

(4.31)

(4.32)

(4.33)

(4.34)

Predictor step:

Corrector step:

Eqn. (4.30) gives us an intermediate velocity field, that, however, does not satisfy the continuity equation.This is corrected by taking the divergence of Eqn.(4.31)

By following the continuity it can be required that should satisfy:

A combination Eqns. (4.32) and (4.33) will give

Eqn. (4.34) is a Poisson equation for the pressure which must be solved at each time step. In Davidsonand Nielsen (1996) the solution procedure is summarized as follows:

Solutions for each time step:1. Solve velocities (Eqn. (4.30)) without the pressure term to obtain the intermediate velocity field 2. Compute the face velocities by using linear interpolation.3. Compute the mass flux imbalance

4. Solve the Poisson equation to obtain the pressure (this is the most time consuming part)5. Correct the node velocities and face velocities6. Update velocities and pressure7. Compute the turbulent viscosity by a subgrid scale model8. Restart from next time step and repeat all step again.

Next, the implicit method of time-advancement.

Page 15: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

53

(4.35)

(4.36)

(4.37)

(4.38)

4.3.3 The Implicit MethodActually the code employs an implicit, twonstep timenadvancement method. Integration of the filteredNaviernStokes Eqns. (4.23) over a time interval from t to t+Ft and over the control volume will give

This may be discretized in time to the following expression:

which can be reduced to:

where

The Crank-Nicolson method can be obtained from the above equations by letting ? be equal to 0.5,although, most of the cases simulated ? were set up to 0.6 for stability reasons. So, the time accuracywould be close to second order, since ? = 1 gives a fully implicit scheme which is only first orderaccurate.

Page 16: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

54

(4.39)

(4.40)

(4.41)

(4.42)

(4.43)

(4.44)

When the control volume formulation is used the above discretized equation will be:

where i = 1, 2 or 3 and

The source term S includes the pressure terms and one part of the subgrid stresses given by

. Eqn. (4.33) can be solved to give the new velocity field , which will not satisfy the

continuity. An intermediate velocity field can be computed by subtracting the implicit part of thepressure gradient term .

The divergence of Eqn.(4.41) is taken, while requiring that continuity equations for the face velocitiesshould be satisfied at time step n + 1, i.e.

to obtain the correction:

The face velocities will be obtained by a linear interpolation over the control volume cell.

The numerical algorithm is given by: 1. Solve the discretized NaviernStokes2. Create an intermediate velocity field 3. Solve the Poisson4. Compute the face velocities, which satisfy continuity, as:

5. Repeat steps 1 to 4, until convergence is achieved.6. Compute the turbulent viscosity, Y T , by a subgrid scale model7. Next time step.

Page 17: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

55

One should note that no extra dissipation has to be added to overcome the add-even decoupling due tonon-staggered grid assignment. An implicit dissipation is present. The intermediate field is computed atall nodes subtracting the pressure velocity. After solving the Poisson equation, the face velocity field iscalculated followed by adding a pressure gradient at the faces. In this way Rhie-Chow interpolation willnot be necessary, since this procedure is similar.

4.3.4 The Solver for the linear system of equationsThe effectiveness of this method is greatly connected to the performance of the matrix solver applied instep 3. Davidson & Nielsen (1996) and Emvin (1997) mention that using an explicit formulation of thesame method to perform large eddy simulation, required a large amount of cpu-time compared to theimplicit method, when a conjugate gradient solver with incomplete Cholesky preconditioning was usedto solve the Poisson equation in the explicit method. The preconditioning conjugated gradient solverrequires many iterations to lower the residual 3 - 4 order of magnitude. The residual for both the explicitand implicit methods was set to 10 -3, defined by the L 2 - norm.

For the explicit method to solve the pressure Poisson equation, the conjugate gradient Krylovsubspace solver was implemented, together with the ILU (Incomplete LU) and ILUT (Incomplete LUwith threshold drop tolerance) (Saad, 1996) . Furthermore, the MRILU preconditioner (Botta and Wubs,1999) were tested, and finally a multigrid solver (Llorente and Melson, 1998) was implemented and used.For the implicit method, only the muligrid solver (Llorente and Melson, 1998) was implemented. Themultigrid solver consists of a Full Approximation multigrid scheme with alternating- plane smoothers(Gauss-Seidel ). In order to solve the velocity component in the momentum equations, the Gauss-Seidelmethod, the Strongly Implicit Procedure method (SIP) (Stone, 1968) and finally the Modified StronglyImplicit Procedure (MSIP) (Schneider and Zedan, 1981) method were implemented.

The Krylov method, such as the conjugate gradient, mainly consists of vector updates, vector-vectorand vector matrix operations, Refinement of the grid will increase the vector length, and therefore, betterperformance can be achieved on vector supercomputers. A disadvantage of the multigrid methods is thatthe occurrence of vectors of short length are inevitable, since the use of a coarse grid will be necessary.This can diminish the multigrid efficiency on a vector supercomputer, and even on workstations. For moreinformation about Krylov methods, see Barrett, (1994) and the reference given there. In order to obtainoptimal performance for the Conjugate Gradient solver, the matrix was stored in a banded format (Saad,(1996)), since the matrix arising from the discretization of the Pressure Poisson equations will only havediagonals. To allow fill-in during the factorization phase of the three different the preconditioning matrixwere stored in a compressed row format (Saad (1996)). Unfortunately, this is not the most efficient wayto do it, but the format is very general and allows additional fill-in of elements in the matrix.

Page 18: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

56

(4.45)

(4.46)

(4.47)

4.3.5 The boundary conditionsThe boundary condition for the velocities are no-slip and Neuman for the pressure. But to account for theviscous effect near the wall, the Werner and Wengle’s (1991) approach were used. The boundaryconditions at the walls were specified by assuming that at the grid points closest to the wall, and theinstantaneous velocity components tangential to the wall are in phase with the instantaneous wall shearstress components and that the instantaneous velocity profile is assumed to follow the law of the wall,stating that

And it is continued by a power-law description of the form (> 11.81), with A = 8.3 and B = 1/7. Thevelocity components tangential to a wall at the grid point next to the wall can be related to thecorresponding wall shear stress components by integrating the velocity distribution over the height of thefirst grid cell (Werner, 1991).

The resulting equations can be resolved analytically for the wall shear stress components, i.e.and therefore the advantages of this method are that no average values are required, numerical problemsin reattachment regions are avoided, and no iteration method is necessary to determine the wall shearstress, because it can be obtained analytically.

In many simulations there is a need to have fluid flow from one or more boundaries of thecomputational region. At such "outflow" boundaries the following question will arise what constitutesa good boundary condition? In compressible flows, when the flow speed at the outflow boundary issupersonic, it makes little difference how the boundary conditions are specified, since flow disturbancescannot propagate upstream. In low speed and incompressible flows, however, disturbances introducedat an outflow boundary can have an affect on the entire computational region.

The simplest and most commonly used outflow condition is that of a "continuatives" boundary.Continuatives boundary conditions consist of zero normal derivatives at the boundary for all quantities.The zero-derivative condition is intended to represent a smooth continuation of the flow through theboundary. It must be stressed that the continuatives boundary condition has no physical basis, it is rathera mathematical statement that may or may not provide the desired flow behaviour. In particular, if flow

Page 19: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

57

(4.48)

(4.49)

(4.50)

is observed to enter the computational region across such a boundary, then the computations may bewrong because nothing has been specified about flow conditions existing outside the boundary. Tofurther improve the outlet boundary, instead of just using the zero-derivative, a convective outletboundary was implemented. Here, the inflow velocity Uin is used as the convective velocity for theoutflow boundary condition (Pauley et al., 1990; Dai et al., 1992; Sohankar, 1998; Sohankar et al.,1998):

This type of outflow boundary is suitable for moving vortical structures out of the computational domain.

4.4 The LES implementation in the CFX softwareFinally, a short description of the implementation of the Large Eddy Simulation model and the usedsubgrid scale models into the commercial computational fluid dynamic code, CFX will be given. Theimplementation is achieved by using a user fortran interface, which allows the user to add additionalmodels, like new wall functions, difference turbulence, etc. The basic implementation involves addinga subgrid scale viscosity to the laminar viscosity. CFX was set up to solve the given problem as a time-dependent and laminar problem. The routine USRVIS which allows the user to modify the laminarviscosity using the Fortran 77 programming languages by means of which the user can specify their ownmodification to the viscosity.

In the following subsections some of the functions and subroutines within the CFX code have beenused, which has made the implementations relative simple. The given implementation is the same asshown in Jacobsen (1997). It is only included for completeness of the different implementations used inthis project and to illustrate some issues that should be adressed when using a commercial code whichdoes not include a LES implementation. Three different subgrid scale models, the Smagorinsky Model,the Mixed Scale Model and finally the Dynamic model, are implemented, tested briefly and comparedwithin CFX.

4.4.1 The implementation of the Smagorinsky SGS model in CFXAs previously stated, the Smagorinsky model is based on an equilibrium hypothesis and can be writtenas:

if we neglect the influence of the solid wall. Since the turbulence length scale decreases close to the wall,the van Drist functions are used.

Page 20: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

58

(4.51)

(4.52)

(4.53)

where is the strain rate factor. is the van Drist damping function. Since CFXuses a body fitted structure of the grid, the calculation of the filter width is done by determining the cuberoot of the cell volume:

However, this implies that the distortion of the cell is not too great. In the case of an anisotropic grid, thefilter width is not a measure of the cell, but rather an appropriate filter size of the eddies which can beresolved in the present grid.

Secondly, the strain rate factor has to be calculated as the modulus of the strain rate , which canbe calculated from the velocity gradient:

The strain rate factor |S| can be found as

for a Cartesian coordinate system. The calculation of the velocity gradient can be performed by using thesubroutine GRADV , which is included in the CFX user fortran interface.

C-----------compute velocity gradientsCALL GRADV('USRVIS',IPHASE,U(1,IPHASE),V(1,IPHASE),

+ W(1,IPHASE),WORK(JUGRAD),WORK(JVGRAD),WORK(JWGRAD), + XP,YP,ZP,VOL,AREA, + IBLK,IPVERT,IPNODN,IPFACN,IPNODF,IPNODB,IPFACB, + WORK,IWORK,CWORK)

The gradients are stored in a WORK array, where space has been allocated by using the subroutineSETWRK.

C-----------reserve real workspace for velocity gradientsCALL SETWRK('USRVIS','WORK ','UGRAD ',3*NCELL,JUGRAD)CALL SETWRK('USRVIS','WORK ','VGRAD ',3*NCELL,JVGRAD)CALL SETWRK('USRVIS','WORK ','WGRAD ',3*NCELL,JWGRAD)

The three integers JUGRAD, JVGRAD and JWGRAD return pointers to where the gradients are storedin the WORK array.

Page 21: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

59

(4.54)

(4.55)

(4.56)

In order to address each single node in the grid, CFX uses INODE which is calculated in thesubroutine

CALL IPALL('*','*','BLOCK','CENTRES',IPT,NPT,CWORK,IWORK)

Here, the array IPT contains the INODE numbers of the nodes for all blocks in a multi-block structured grid.On the next page a code segment of the Smagorinsky implementation is given.

Applying the van Drist wall damping function involves multiplying the strain rate factor by thedamping factor which accounts for the fact that the resolved strain rate does not vanish on the walls, whilethe subgrid scale stress and also the viscosity do. Therefore, the subgrid viscosity must vanish at thewalls. By following the implementation of Jacobson (1997), the expression for the van Drist wall dampingis

is set to 25, and the wall distance in terms of wall units can be found as:

where is the wall friction velocity, i is the laminar kinematic viscosity, y is the normal distance from the node to the nearest wall.It should be noted that the expression for is only valid for channel flow and is therefore not particularlysuited for the calculation where both flow separation and recirculation occurs, because the wall shearstress will vanish at the point mentioned. However, this implementation is used anyway. The wall shearstress is calculated in the following way:

where the mean velocity gradient is taken perpendicularly to the wall.

Page 22: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

60

C-----------reserve real workspace for velocity gradients CALL SETWRK('USRVIS','WORK ','UGRAD ',3*NCELL,JUGRAD)

CALL SETWRK('USRVIS','WORK ','VGRAD ',3*NCELL,JVGRAD)CALL SETWRK('USRVIS','WORK ','WGRAD ',3*NCELL,JWGRAD)

C-----------CALL IPALL('*','*','BLOCK','CENTRES',IPT,NPT,CWORK,IWORK)

C-----------compute velocity gradientsCALL GRADV('USRVIS',IPHASE,U(1,IPHASE),V(1,IPHASE),

& W(1,IPHASE),WORK(JUGRAD),WORK(JVGRAD),WORK(JWGRAD), & XP,YP,ZP,VOL,AREA, & IBLK,IPVERT,IPNODN,IPFACN,IPNODF,IPNODB,IPFACB, & WORK,IWORK,CWORK)CC-----------defining constants: The Smagorinsky constant Cs and laminar viscosity

Cs = 0.18mu_lam = 15.10E-6

C-----------loop over all interior cellsDO 100 I=1,NPT

C-----------use array ipt to get addressINODE=IPT(I)DUDX = WORK(JUGRAD+INODE-1)DUDY = WORK(JUGRAD+NCELL+INODE-1)DUDZ = WORK(JUGRAD+2*NCELL+INODE-1)

C-----------DVDX = WORK(JVGRAD+INODE-1)DVDY = WORK(JVGRAD+NCELL+INODE-1)DVDZ = WORK(JVGRAD+2*NCELL+INODE-1)

C-----------DWDX = WORK(JWGRAD+INODE-1)DWDY = WORK(JWGRAD+NCELL+INODE-1)DWDZ = WORK(JWGRAD+2*NCELL+INODE-1)

C-----------calculation of the Smagorinsky term SMAG2 = 2.0*(DUDX**2 + DVDY**2 + DWDZ**2) +

& (DUDY + DVDX)**2 + (DUDZ + DWDX)**2 + (DVDZ + DWDY)**2SMAG = SQRT(SMAG2)

C-----------calculation of length scaleDELTA = VOL(INODE)**(1/3)L = Cs * DELTA

C-----------calculation of sgs viscosityVIS_SGS = L**2 * SMAG

C-----------calculation of new viscosity by adding subgrid viscosity to laminar viscosityVISN(INODE,IPHASE) = MU_LAM + VIS_SGS*RHO

C-----------100 CONTINUE

Codes segment 1: The basic Smagorinsky code for CFX

Page 23: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

61

(4.57)

The normal distance from the nearest wall to the node is calculated in the set up by CFX and canbe addressed in a work array by CFX, and by using the pointer found by the subroutine:

CALL GETADD(‘USRVIS’, ‘GEOM ’, ‘DISWALL’,ILEVEL, IUDIST)

The integer IUDIST contains the addressee. The gradient du/dy can therefore be calculated by useof a linear interpolation of the development of the boundary layer

Finally, the subgrid scale viscosity can be found by use of Eqn. (4.42) and be added to the laminarviscosity which is stored in the VISN variable (see code segments 1 and 2).

Page 24: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

62

C-----------reserve real workspace for velocity gradients CALL SETWRK('USRVIS','WORK ','UGRAD ',3*NCELL,JUGRAD)

CALL SETWRK('USRVIS','WORK ','VGRAD ',3*NCELL,JVGRAD)CALL SETWRK('USRVIS','WORK ','WGRAD ',3*NCELL,JWGRAD)

C-----------CALL IPALL('*','*','BLOCK','CENTRES',IPT,NPT,CWORK,IWORK)

C-----------compute velocity gradientsCALL GRADV('USRVIS',IPHASE,U(1,IPHASE),V(1,IPHASE),

& W(1,IPHASE),WORK(JUGRAD),WORK(JVGRAD),WORK(JWGRAD), & XP,YP,ZP,VOL,AREA, & IBLK,IPVERT,IPNODN,IPFACN,IPNODF,IPNODB,IPFACB, & WORK,IWORK,CWORK)CC-----------defining constants: The Smagorinsky constant Cs and laminar viscosity mu_lam

Cs = 0.18mu_lam = 15.10E-6Aplus = 25IPHASE = 1

C-----------loop over all interior cellsDO 100 I = 1,NPT

C-----------use array ipt to get addressINODE=IPT(I)DUDX = WORK(JUGRAD+INODE-1)DUDY = WORK(JUGRAD+NCELL+INODE-1)DUDZ = WORK(JUGRAD+2*NCELL+INODE-1)

C-----------DVDX = WORK(JVGRAD+INODE-1)DVDY = WORK(JVGRAD+NCELL+INODE-1)DVDZ = WORK(JVGRAD+2*NCELL+INODE-1)

C-----------DWDX = WORK(JWGRAD+INODE-1)DWDY = WORK(JWGRAD+NCELL+INODE-1)DWDZ = WORK(JWGRAD+2*NCELL+INODE-1)

C-----------calculation of the Smagorinsky term SMAG2 = 2.0*(DUDX**2 + DVDY**2 + DWDZ**2) +

& (DUDY + DVDX)**2 + (DUDZ + DWDX)**2 + (DVDZ + DWDY)**2SMAG = SQRT(SMAG2)

C-----------calculation of the wall functionsYdist = WORK(IUDIST+INODE-1)TAUWALL = mu_lam*SQRT( U(INODE,IPHASE)**2 +

& V(INODE,IPHASE)**2 + & W(INODE,IPHASE)**2 ) / YDIST

yplus = YDIST/(mu_lam / Den(INODE,IPHASE)) * & SQRT((TAUWALL/DEN(INODE,IPHASE))

Fd = 1 - EXP((-yplus/Aplus))C-----------calculation of length scale

DELTA = VOL(INODE)**(1/3)L = Fd * Cs * DELTA

C-----------calculation of sgs viscosityVIS_SGS = L**2 * SMAG

C-----------calculation of new viscosity by adding subgrid viscosity to laminar viscosityVISN(INODE,IPHASE) = MU_LAM + VIS_SGS*DEN(INODE,IPHASE)

C-----------100 CONTINUE

Code segment 2: The basic Smagorinsky with van Drist wall function code for CFX

Page 25: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

63

(4.58)

ui-1 ui ui+1

F

F

_

—Figure 4.6: Difference between the single anddouble filtering operation on a uniform grid.

1/64

1/64

1/64

1/64

1/161/32

1/32

1/32

1/32

1/81/64

1/64

1/64

1/64

1/161/32

1/32

1/32

1/321/16 1/16

1/16

1/16

1/32 1/32

1/321/32

Figure 4.7: Weighing factors of the double filteringoperation.

4.4.2 The implementation of the Mixed Scale SGS model in CFXThe mixed scale model by Sagaut (1995), described in the previous chapter, uses a double filteringoperation together with some extra parameters. The basic implementation is quite similar to theSmagorinsky model. Calculation of the subgrid scale viscosity can be done by evaluating the followingexpression:

where the parameters are as follows: S is the strain rate factor, and Cm is a model constant which can befound as . Here, c q = 0.20 and cs = 0.17 have been chosen for the simulation. F is thefilter width. ? is a constant and has been set to 0.5. Finally, q cut is the kinetic energy of the fluctuatingresolved scale motion.

As mentioned, the mixed scale model involves a double filtration of the velocity field in order toevaluate the kinetic subgrid scale energy qcut . The secondary filter operation is applied to the cut-offlength scale equal to a filter width of 2 F (Figure 4.6),

which therefore involves the neighbouring 27 cells and is depicted in Figure 4.7:

Due to the fact, that CFX addresses the individual cells by using a one-dimensional storage location, theaddressing of a single cell is not straightforward although the code uses a structured grid. As explained

Page 26: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

64

1/2

1/4

1/4

1/4 1/2 1/4 1/21/4

1/4

i

j

k

Figure 4.8: Weighting procedure and the factors for the double filtering operation.

for the Smagorinsky model one has to use the IPALL subroutine. However, only interior cells can beaddressees this way,as they will reach the boundary cells next to the wall, the INODE(INODE, NWALL),where NWALL will define which wall should be addressed (see Table below).

# NWALL Face of C.V. Direction of normal

1 high I Increasing I

2 high J Increasing J

3 high K Increasing K

4 low I Decreasing I

5 low J Decreasing J

6 low K Decreasing K

Table 4.1: The definition of the pointer NWALL for a Control Volume.

When the double filtering operation is applied, one has to average over the neighbouring 27 cells, and this can be divided into three traversing operations, one in the I-direction, one in the J-direction and onein the K-direction of the grid (Figure 4.8):

It should, however, be stressed that the used weighting procedure is only valid for structured gridsthat are not too much distorted (e.g. the orthogonality condition of the grid should be close to 1).

The kinetic energy of the resolved scales q cut is then calculated as follows:

QQ = 0.5 * ((U(INODE,1) - UFILTER(INODE))**2 + (V(INODE,1) - VFILTER(INODE))**2 + (W(INODE,1) - WFILTER(INODE))**2 )

The rest reassembles the implementation of the Smagorinsky model. The section of the user Fortrancode will be been depicted on the following pages.

Page 27: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

65

C-----------setting constants CK = 0.05 ALPHA = 0.75 ONETHIRD = 1.0/3.0

C-----------set phase number IPHASE = 1MU LAM = DIFLAM(1,IPHASE)

C-----------reserve real workspace for velocity gradientsCALL SETWRK(’USRVIS’,’WORK ’,’UGRAD ’,3+NCELL,JUGRAD)CALL SETVRK(’USRVIS’,’WORK ’,’VGRAD ’,3+NCELL,JVGRAD)CALL SETWRK(’USRVIS’,’WORK ’,’WGRAD ’,3+NCELL,JWGRAD)

C-----------compute velocity gradients CALL GRADV(’USRVIS’,IPHASE,U(1,IPHASE),V(1,IPHASE),

W(1,IPHASE),WORK(JUGRAD),WORK(JVGRAD),WORK(JWGRAD),XP,YP,ZP,VOL,AREA, IBLK,IPVERT,IPNODN,IPFACN,IPNODF,IPNODB,IPFACB,WORK,IWORK,CWORK)

C-----------CALL IPALL(’*’,’*’,’BLOCK’,’CENTRES’,IPT,NPT,CWORK,IWORK)

C-----------call of scalar numbers CALL GETSCA('USRDCC SMAG FACTORP,ISC7,CWORK) CALL GETSCA('USRDCC SGS ENERGY,ISC8,CWORK) CALL GETSCA('USRDCC SGS VISCOSITY',ISC9,CWORK) CALL GETSCA('USRDCC DELTA',ISC10,CWORK)

C-----------calculate the filtered velocities Do 100 I=1,NPT

INQDE=IPT(I)INODEW=IPNODN(INODE,1) INODEE=IPNODN(INODE,4) UFILTER(INODE) =0.25*U(INODEW,1)+0.5*U(INODE,1)+0.25*U(INODEE,1)VFILTER(INODE) =0.25*V(INODEW,1)+0.5*V(INQDE,1)+0.25*V(INODEE,1)WFILTER(INODE) =0 25*W(INODEW,1)+0.5*W(INODE,1)+0.25*W(INODEE,1)

100 Continue C-----------

Do 200 I=1,NPT INODE=IPT(I)INODET=IPNODN(INODE,2)INODEB=IPNODN(INODE,5) UFILTER(INODE)=

& 0.25*UFILTER(INODET)+0.5*UFILTER(INODE)+0.25+UFILTER(INODEB)VFILTER(INODE)=

& 0.25*VFILTER(INODET)+0.5*VFILTER(INODE)+0.25*VFILTER(INODEB) WFILTER(INODE)=

& 0.25*WFILTER(INODET)+0.5*WFILTER(INODE)+0.25*WFILTER(INODEB) 200 ContinueC-----------

Do 300 I=1,NPT INODE=IPT(I)INODET=IPNODN(INODE,3)INODEB=IPNODN(INODE,6)UFILTER(INODE)=

& 0.25*UFILTER(INODET)+0.5*UFILTER(INODE)+0.25*UFILTER(INODEB)VFILTER(INODE)=

& 0.25*VFILTER(INODET)+0.5*VFILTER(INODE)+0.25*VFILTER(INODEB)WFILTER(INODE)=

& 0.25*WFILTER(INODET)+0.5*WFILTER(INODE)+0.25*WFILTER(INODEB)300 Continue

Page 28: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

66

C-----------loop over all interior cellsDO I=1,NPT INODE=IPT(I)

C-----------compute kinetic energy QQ = 0.5 * ((U(INODE,1)-UFILTER(INODE))**2 +

& (V(INODE,1)-VFILTER(INODE))**2 + & (W(INODE,1)-WFILTER(INODE))**2 )

C-----------compute velocity gradients DUDX = WORK(JUGRAD+INODE-1)DUDY = WORK(JUGRAD+NCELL+INODE-1) DUDZ = WORK(JUGRAD+2*NCELL+INODE-1)

C-----------DVDX = WORK(JVGRAD+INODE-1) DVDY = MORK(JVGRAD+NCELL+INODE-1) DVDZ = WORK(JVGRAD+2*NCELL+INODE-1)

C-----------DWDX = WORK(JWGRAD+INODE-1)DWDY = WORK(JWGRAD+NCELL+INODE-i)DWDZ = WORK(JWGRAD+2*NCELL+INODE-1)

C-----------calculation of the Smagorinsky termSMAG2 = 2.0 * (DUDX**2 + DUDY**2 + DWDZ**2) +

(DUDY + DVDX)**2 + (DUDZ + DWDX)**2 +(DVDZ + DWDY)**2

C-----------SMAG=SQRT(SMAG2)

C-----------calculation of length scaleDELTA = VOL(INODE)**ONETHIRD

C-----------calculation of sgs viscosity VIS_SGS = Cm+ABS(SMAG)**ALPHA*QQ**((1-ALPHA)/2.0)*DELTA**(1+ALPHA) IF (VIS_SGS.LT.0.0) VIS SGS=O.

C-----------calculation of new viscosity VISN(INODE,IPHASE) = MU_LAM + VIS_SGS*DEN(INODE,IPHASE)

C-----------SCAL(INODE,IPHASE,ISC7)=SMAG SCAL(INODE,IPHASE,ISC8)=QQSCAL(INODE,IPHASE,ISC9)=VIS_ SGS*DEN(INODE,IPHASE) SCAL(INODE,IPHASE,ISC10)=DELTA

ENDDO

Code segment 2: The mixed scale code for CFX (Continued from last page)

Page 29: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

67

4.4.3 The implementation of the Dynamic SGS model in CFXThe deficiency in the Smagorinsky SGS model has led researchers to look for better alternatives. Oneof them, the dynamic subgrid scale model proposed by Germano et al. (1991), has provided renewedinterest in LES research, due to the dynamic nature of the model and the fact that it is easy use. In otherwords, the dynamic model will attempt to remedy some of the shortcomings of the Smagorinsky modelby allowing local calculation of the model coefficient by use of two levels of spectral information alreadypresent in the numerical calculation. Since the formulated model coefficient becomes a function of spaceand time and may become negative, it can therefore account for the backscatter of the turbulent energy.Additionally, the coefficient will automatically decrease towards a solid wall and achieve a zero valuewhen the flow is laminar, thus eliminating the need for an ad hoc treatment of the model constant to adaptto the flow situations (e.g., the transitional flow).

Just as the mixed scale model, a second filter, the denoted test filter, can be calculated on a gridwhich is twice as coarse as the original grid. The same double filtering can be applied by use of the 27nodes for the cell averaging procedure. The implementation of the dynamic procedure is similar to usingthe Smagorinsky model on two different grids, where the grid filter ratio is . Then the resolveturbulence stresses ©ij from the subgrid scale stresses can be calculated on the two different grid levelsassuming that the “constant” C is the same on both grid levels. By using the Lilly et al. (1992) as a least-square approach the equations can be reduced to one, on the assumption that C is only a function of twospace dimension and time.

The equations and the implementation reassemble what was previously described for the dynamicsubgrid scale model and the averaging in one homogenous direction (spanwise) for the Solve4LES code.It will therefore not be repeated here.

More information about the implementation and method in the Solve4LES code, is given inBennetsen(2001).

In the following chapter, the described programmes are used validated for simple block-buildingflow problems and later for more ventilation specific cases.

Page 30: Chapter 4 Numerical implementations, I, the Solve4LES and ...homes.civil.aau.dk/pvn/cfd-benchmarks/two_d_literature/phd_thesis/... · Numerical implementations, the Solve4kI, the

CHAPTER 4 NUMERICAL IMPLEMENTATION; SOLVE4KH, SOLVE4LES AND CFX

68