H. G. Weller and G. Tabor

7
Turbulence modeling consists of finding convenient and physically correct representations for R and B. A. RAS modeling In all there are 11 RAS models implemented in FOAM, including standard, 24 nonlinear, and low-Reynolds- number 25 variants of the k 2e model, q 2z , and nonlinear Shih models. The appropriate terms and equations can be incorporated directly into the code as additions to the NSE. However, since FOAM is intended as a research tool for investigating fluid flows as well as modeling, it is important to be able to select the turbulence model at run time with- out recompiling the code. Once again, OOP techniques are of value here. Since all of the models generate a term of the form “–R to add to the momentum equation, they can be implemented as a set of classes with a common interface. This implies that polymorphism via a virtual class hierar- chy is appropriate. A virtual base class turbulenceModel is declared, and classes that implement the various RAS mod- els are derived from it. The model selection is stored in a parsed dictionary file, and a pointer mechanism is used to instantiate the correct RAS model as an instance of the virtual base class turbulenceModel at run time, with the values of the coefficients being taken from this file as well. The additional terms can be included into the averaged NSE as follows: fvMatrixVector Ueqn ( fvm::ddt(U) 1 fvm::div(phi, U) 2 fvm::laplacian(turbulence.nuEff( ), U) 1 turbulence.momentumSource( ) ); solve (Ueqn 55 2 fvc::grad(p)); where turbulence is the RAS-model object. The contribu- tion of the turbulence model to the flow is via the member function nuEff(), which returns n 1n t , where n is the lami- nar viscosity. As an example, the standard k 2e model 24 requires the solution of the following equations for turbu- lent kinetic energy k and dissipation rate e: P k 52 n t u U ¯ u 2 , ] k ] t 1~ U ¯ k ! 2n t s k k 5 P k 2e , ~8! ] e ] t 1~ U ¯ e ! 2n t s e e 5C 1 e e k P k 2C 2 e e 2 k , where P k is the production rate of k and s k , s k , C 1 e , and C 2 e are model coefficients. Below is an example of how this can be implemented in FOAM. // Turbulent kinetic energy production volScalarField Pk 5 2 * nut * magSqr(fvc::grad(U)); // Turbulent kinetic energy equation solve ( fvm::ddt(k) 1 fvm::div(phi, k) 2 fvm::laplacian(nu/sigmaK, k) 55 Pk 2 fvm::Sp(epsilon/k, k) ); // Dissipation equation solve ( fvm::ddt(epsilon) 1 fvm::div(phi, epsilon) 2 fvm::laplacian(nu/sigmalEps, epsilon) 55 C1 * Pk * epsilon/k 2 fvm::Sp(C2 * epsilon/k, Epsilon) ); Reynolds stress models can be implemented in a similar manner. Here, for example, is the implementation of the Launder–Reece–Rodi ~LRR! model equation 26 for the Reynolds stress tensor R: volTensorField P 52 (R & fvc::grad(U)) 2 (fvc::grad(U) & R); solve ( fvm::ddt(R) 1 fvm::div(phi, R) 2 fvm::laplacian(Cs * (k/epsilon) * R, R) 55 P 2 fvm::Sp(Cr1 * epsilon/k, R) 2 (2.0/3.0) * (1.0 2 Cr1) * I * epsilon 2 Cr2 * (P 2 (1.0/3.0) * I * tr(P)) ); B. LES modeling The range of possible LES models is, if anything, even larger than the range of RAS models, and a comparison is made between a large number of different models in Ref. 17. Once again, the models can be incorporated directly into the momentum equation, or a virtual class hierarchy may be constructed in order to make the models’ run time selectable. Unlike the flat hierarchy used for the RAS mod- els, in this case a three-level system is used ~Fig. 1!. The various LES models can be grouped into sets that share common characteristics, and it is natural to construct the class hierarchy to match, using derivation to represent the Figure 1. Virtual class hierarchy for LES SGS models. The solid lines represent the inheritance hierarchy. COMPUTERS IN PHYSICS, VOL. 12, NO. 6, NOV/DEC 1998 625

description

A tensorial approach to computational continuum mechanicsusing object-oriented techniques

Transcript of H. G. Weller and G. Tabor

  • Turbulence modeling consists of finding convenient and

    physically correct representations for R and B.A. RAS modeling

    In all there are 11 RAS models implemented in FOAM,including standard,24 nonlinear, and low-Reynolds-number25 variants of the k2e model, q2z , and nonlinearShih models. The appropriate terms and equations can beincorporated directly into the code as additions to the NSE.However, since FOAM is intended as a research tool forinvestigating fluid flows as well as modeling, it is importantto be able to select the turbulence model at run time with-out recompiling the code. Once again, OOP techniques areof value here. Since all of the models generate a term of theform R to add to the momentum equation, they can beimplemented as a set of classes with a common interface.This implies that polymorphism via a virtual class hierar-chy is appropriate. A virtual base class turbulenceModel isdeclared, and classes that implement the various RAS mod-els are derived from it. The model selection is stored in aparsed dictionary file, and a pointer mechanism is used toinstantiate the correct RAS model as an instance of thevirtual base class turbulenceModel at run time, with thevalues of the coefficients being taken from this file as well.The additional terms can be included into the averagedNSE as follows:

    fvMatrixVector Ueqn(

    fvm::ddt(U)1 fvm::div(phi, U)2 fvm::laplacian(turbulence.nuEff( ), U)1 turbulence.momentumSource( )

    );solve (Ueqn 55 2 fvc::grad(p));

    where turbulence is the RAS-model object. The contribu-tion of the turbulence model to the flow is via the memberfunction nuEff(), which returns n1n t , where n is the lami-nar viscosity. As an example, the standard k2e model24requires the solution of the following equations for turbu-lent kinetic energy k and dissipation rate e:

    Pk52n tuU u2,

    ]k]t

    1~U k !2 n tsk

    k5Pk2e , ~8!

    ]e

    ]t1~U e!2 n t

    see5C1e

    e

    k Pk2C2ee2

    k ,

    where Pk is the production rate of k and sk , sk , C1e , andC2e are model coefficients. Below is an example of howthis can be implemented in FOAM.

    // Turbulent kinetic energy productionvolScalarField Pk 5 2*nut*magSqr(fvc::grad(U));// Turbulent kinetic energy equationsolve(

    fvm::ddt(k)1 fvm::div(phi, k)2 fvm::laplacian(nu/sigmaK, k)

    55Pk2 fvm::Sp(epsilon/k, k));// Dissipation equationsolve(

    fvm::ddt(epsilon)1 fvm::div(phi, epsilon)2 fvm::laplacian(nu/sigmalEps, epsilon)

    55C1*Pk*epsilon/k

    2 fvm::Sp(C2*epsilon/k, Epsilon));

    Reynolds stress models can be implemented in a similarmanner. Here, for example, is the implementation of theLaunderReeceRodi ~LRR! model equation26 for theReynolds stress tensor R:volTensorField P 52 (R & fvc::grad(U)) 2 (fvc::grad(U) & R);solve(

    fvm::ddt(R)1 fvm::div(phi, R)2 fvm::laplacian(Cs*(k/epsilon)*R, R)

    55P

    2 fvm::Sp(Cr1*epsilon/k, R)2 (2.0/3.0)*(1.0 2 Cr1)*I*epsilon2 Cr2*(P 2 (1.0/3.0)*I*tr(P))

    );

    B. LES modeling

    The range of possible LES models is, if anything, evenlarger than the range of RAS models, and a comparison ismade between a large number of different models in Ref.17. Once again, the models can be incorporated directlyinto the momentum equation, or a virtual class hierarchymay be constructed in order to make the models run timeselectable. Unlike the flat hierarchy used for the RAS mod-els, in this case a three-level system is used ~Fig. 1!. Thevarious LES models can be grouped into sets that sharecommon characteristics, and it is natural to construct theclass hierarchy to match, using derivation to represent the

    Figure 1. Virtual class hierarchy for LES SGS models. The solid linesrepresent the inheritance hierarchy.COMPUTERS IN PHYSICS, VOL. 12, NO. 6, NOV/DEC 1998 625

  • relationships between the different models ~although this

    does make the coding somewhat more involved!.

    A wide selection of models use the Bousinesq hypoth-esis, in which the effect of the unresolved turbulence on thelarge-scale flow is modeled as an increase in the viscosity.This is equivalent to modeling B as

    B5 23kI22n tD D , ~9!

    with D D5D 2 13trD I , and the models differ in the waythat the turbulent viscosity n t is evaluated. Examples of thismodeling approach include the Smagorinsky27 and one-equation eddy-viscosity models.28,29 A second set of mod-els provides a full solution of the balance equations for B:for example, the model of Deardorff30 has the form

    ]B]t

    1~B^U !2 n tsB

    B5P2C1e

    k B223 ~12C1!Ie

    2C2@P2 13 I tr~P!# . ~10!

    Most conventional CFD codes require the six individualequations in Eq. ~10! to be written out separately; however,in FOAM these can be expressed as the single tensorialequation

    solve(

    fvm::ddt(B)1 fvm::div(phi, B)2 fvm::laplacian(nut/sigmaB, B)

    55P

    2 fvm::Sp(C1*epsilon/k, B)2 (2.0/3.0)*(1.0 2 C1)*I*epsilon2 C2*(P 2 (1.0/3.0)*I*tr(P))

    );A third set of LES models is the scale-similarity models,31which introduce further interaction between different turbu-lent scales by introducing a second level of filtering and canbe written

    B5U% ^ U% 2U ^ U . ~11!

    These models do not include the effects of dissipation cor-rectly and are usually combined with an eddy-viscositytype model to give a mixed model.32

    The FOAM LES models class hierarchy is based onthe model relationships described; see Fig. 1. At the base isa virtual base class isoLESmodel. Derived from this areintermediate classes isoGenEddyVisc, isoGenSGSStress,and isoGenScaleSimilarity, which implement Eqs. ~9!, ~10!,and ~11!, respectively. Finally details of the models areimplemented in the highest-level classes. For example, theclasses derived from isoGenEddyVisc calculate the valueof nk used in Eq. ~9!, while those derived fromisoGenSGSStress implement the modeling of Eq. ~10!.isoMixedSmagorinsky is a mixture of a scale-similarity andan eddy-viscosity model, and so multiple inheritance isused to represent this relationship.626 COMPUTERS IN PHYSICS, VOL. 12, NO. 6, NOV/DEC 1998III. EXAMPLES: FLOW AROUND A SQUARE PRISM

    The flow around bluff bodies usually produces strong vor-tices in the wake, which in turn generate intense fluctuatingforces on the body. The prediction of these forces is impor-tant in many applications. Such flows may involve complexphenomena such as unsteady separation and reattachment,vortex shedding and bimodal behavior, laminar subregionsand transition to turbulence, high turbulence, and coherentstructures, as well as curved shear layers. Recently suchflows have received increasing attention, motivated in partby the engineering demand for accurate predictions but alsoby the desire to increase understanding of the underlyingphysical processes governing these flows. A square prism,mounted in a rectilinear channel, is chosen as a simple,representative bluff body, the separation points of whichare fixed and known, unlike the case of a cylinder, wherethe separation points oscillate at the shedding frequency.The flow around and behind the prism is not only tempo-rally but also spatially complex, with direct interaction be-tween the separated shear layers and regions of irrotationalflow entrained into the wake, requiring high local resolu-tion.

    The flow configuration is presented in Fig. 2 and has across section of 10h314h , and a length of 20h where theprism has cross section h3h . The Re number based on hand the inlet velocity v` is 21,400. Experimental profiles ofthe first- and second-order statistical moments of the veloc-ity are available from Lyn et al.33 (Re521,400) and fromDurao et al.,34 (Re514,800) at x1 /h51 and 2 and on thecenter line ~the positions shown in Fig. 2!. Since all quan-tities are nondimensionalized with h and v` , experimentalprofiles of U and v rms from these experiments should beable to be compared directly. At the inlet, U 5vx ,` and pex50, where ex is the unit normal vector in the xx di-rection; at the outlet, p5p` and U ex50. For RAS, addi-tional boundary conditions have to be prescribed for k ande. The RAS calculations are two-dimensional, whereas the

    Figure 2. Geometry and inlet conditions for flow past a square-basedprism. The coordinate system is indicated, and the distances are in units ofthe square height h54 cm. The dotted lines indicate the lines along whichthe velocity profiles are measured.

  • LES are three-dimensional, and thus a semiartificial free-slip condition, U ex50 and (U ek)ek50, k5y , z, is ap-plied on the planes xI e350 and 4h . For the top and bottomboundaries, x/h567h , slip conditions are applied whileno-slip conditions are used for the boundary condition onthe prism. The computational domain is discretized using a250,000-cell grid.

    Results are shown in Fig. 3 from LES using theSmagorinsky27 and one-equation eddy-viscosity29 models,from RS using the LaunderGibson Reynolds stressmodel,35 and the standard and RNG36 k2e models. Thefunction of the comparison is to illustrate the flexibility ofFOAM for model implementation rather than to analyze themerits of the various models; a detailed analysis of themodels will be described elsewhere. Hence, only a repre-sentative set of results is presented, these being the time-averaged velocities U ~streamwise, that is, along the x axis!and V ~in the y direction!. There is a significant and unex-plained discrepancy between the Lyn and Durao data forthe U component on the center line, with the Lyn data

    Figure 3. Comparison between velocity components for the experiment(symbols) and for calculations (profiles) using standard k2e , RNG k2e , Reynolds stress [using a model of Launder and Gibson (Ref. 35)],and LES using the Smagorinsky and one-equation eddy-viscosity models.The top diagram shows the U (streamwise) component of the velocityalong the center of the domain. The next two figures show the U (left) andV (transverse, right) velocity components on a transverse plane at x/h51, that is, one obstacle height downstream from the obstacle. The bot-tom two figures show the same profiles at x/h52.failing to show the expected return to the inlet velocity atlarge distances from the obstacle. The simple k2e modelperforms poorly in this case, a result that has also beennoted elsewhere. The other models all perform well, withthe one-equation eddy-viscosity model and the LRR mod-els predicting the near obstacle flow well. The accuracy ofall models in capturing the recirculation behind the obstaclecan also be enhanced by increasing the degree of refine-ment in this area. Further downstream all three models ap-proach the data of Durao et al. The other results shown arethe U and V components in the y direction at x/h51,2.Only the top half of the data is shown. The inadequacy ofthe k2e model is clear. All the other models provide goodpredictions for the U component, with the main differencebetween the LES and RS models being the lack of smooth-ness in the curves, which is probably due to inadequatetemporal averaging. The V component shows much largerdiscrepancies between the models, with the LES modelsoutperforming the RS model at x/h51. Further down-stream no model performs well. Overall, the LRR modelproduces results that are very similar to those of the LESmodels; however, this is not the case for more complexgeometries.

    Figure 4 shows a perspective view of the flow aroundand behind the prism at one instant in time selected ran-domly from a LES with the one-equation eddy-viscositymodel. The top part of Fig. 4 shows an isosurface ofsubgrid-scale turbulent kinetic energy k, and the bottom anisosurface of grid-scale enstrophy @ 12(3U )2# . The grid-scale enstrophy traces the presence of the primary spanwisevortices, which are generated by KelvinHelmholtz insta-bilities in the shear layers originating from the separationpoints at the upstream corners of the prism and shed from

    Figure 4. Visualization of SGS kinetic energy (top) and enstrophy 12~3U !2, (bottom) behind a square prism. The calculation was performedusing the one-equation eddy viscosity LES model.COMPUTERS IN PHYSICS, VOL. 12, NO. 6, NOV/DEC 1998 627

  • alternate sides of the prism. It also traces the secondary solved if the same solution technique can be utilized in both

    (culation of the stress field in a 2-D square plate with acircular hole in it. The plate is being stretched in one direc-tion by uniform traction of 104 Pa. This is a relativelysmall load, and so the problem can be considered isother-mal, linear, elastic, and steady-state. Since the plate is two-dimensional, the assumption of plane stress is made. Thehole is central to the plate, and so only one quarter of thedomain need be simulated, symmetry boundaries being ap-plied on the left and bottom. The mesh for this calculationcontained 15,000 cells. The top boundary, together with thehole, are given zero-traction boundary conditions, while theright boundary has fixed traction of 104 Pa. The results areshown in Fig. 6 in the form of contours of sxx , sxy , andsyy . Apart from a small region in the plates center, theagreement is close. The error is in the region where several628 COMPUTERS IN PHYSICS, VOL. 12, NO. 6, NOV/DEC 1998ary. The results are shown in Fig. 7 as a function of anglearound the hole ~Q50 being the x direction, that of theimposed strain!. The accuracy achieved is very good, withthe maximum error being less than 2%.

    B. Magnetohydrodynamics calculation

    The flow of an incompressible conducting fluid with con-stant properties in a magnetic field is governed by theNavierStokes equations

    U50~13!]U

    ]t1~U^U!2nU52 1

    rp1

    1r

    J3B,

    together with Maxwells equations,fvm::d2dt2(U)55

    fvm::laplacian(2*mu 1 lambda, U)1 fvc::div(

    mu*gradU.T( ) 2 (mu 1 lambda)*gradU 1 lambda*I*tr(gradU))

    );%

    %

    Note the split into implicit fvm and explicit fvc parts. Thisparticular rearrangement guarantees diagonal dominance ofthe matrix and good convergence behavior. Iteration overthe equation is required every time step for transient calcu-lation in order to converge over the explicit contribution.For steady-state calculation, the inner iteration is unneces-sary.

    Figure 5 shows the computational domain for the cal-

    blocks of cells making up the mesh meet; this produces asuboptimal arrangement of cells. The error is probably aresult of the nonorthogonality of the mesh in this region.The stress concentration around the hole is clearly visible.This comparison shows that the solution is qualitativelycorrect; to demonstrate its quantitative accuracy, the ana-lytical solution on the edge of the hole can be comparedwith the values from the FOAM calculation on this bound-streamwise vortices that envelop the primary vortices. ktraces the subgrid-scale turbulence that arises from thebreakdown of these vortices and correlates well with thevortex distribution.

    IV. OTHER EXAMPLES

    A. Stress analysis

    The traditional approach to solid-body stress analysis is us-ing the FEM. However, the governing equations for fluidflow and for solid-body stress analysis are of a similarform, indicating that the FVM is also applicable as wasdemonstrated by Demirdzic and Muzaferija.37,38 This is notjust a tour de force: problems involving solidification of afluid ~welding or casting, for example! are most easily

    for(runTime11; !runTime.end( ); runTime11)$

    for(int iCorr 5 0; iCorr,nCorr; iCorr11)$

    volTensorField gradU 5 fvc::grad(U);solvephases. To demonstrate the ease with which FOAM can beused to develop a structures code, such a code will be pre-sented, together with the simple example of the stress pat-tern generated by a circular hole in a rectangular plate. Theplate material is assumed to be linear, elastic, and isother-mal, and the assumption of infinitesimal deformation ismade. Under these circumstances the displacement D canbe solved for as a dependent quantity without introducingthe complexity of how this affects the mesh.

    The time-dependent equation for the displacement Dis

    ]2D]t2

    5@m~D1DT!1lI tr~D!# , ~12!the FOAM representation of which is

  • 3H5J1]D]t

    , 3E52]B]t

    ,

    ~14!B50, J50,and Ohms law J5s(E1U3B). To conform to acceptedpractice in electrodynamics, B is the magnetic field (B5mH) and D the electric displacement vector. Assumingthat ]D/]t is negligible, then

    J3B5~3H!3B52B2

    2m 11m

    BB, ~15!

    and so the momentum equation takes the form]U]t

    1~U^U!2nU52 1r

    S p1 B22m D1

    1rm

    ~B^B!. ~16!Also,

    3H5J5s~E1U3B!, ~17!and taking the curl results in

    Figure 5. Geometry of the domain for stress calculation. The variousboundary types are indicated. In theory the domain should be infinite, inpractice a domain 16 m on each side seemed to be adequate.

    Figure 6. Comparison of calculated (top) and analytical (bottom) stresscomponents for a square plate with a circular hole. From left to right:sxx , sxy , and syy .]B]t

    1~U^B2B^U!2 1sm

    B50. ~18!

    These two transport equations for the system are in a formthat can be solved using FOAM. The pressure equation isconstructed from the total pressure ~static pressure p plusthe magnetic pressure B2/2m!. A fictitious magnetic-fluxpressure pH is introduced into the magnetic-field equationto facilitate the obeyance of the divergence-free constrainton B in the same manner as the pressure equation is used inPISO. The resulting field pH has no physical meaning, andat convergence represents the discretization error.

    A simple magnetohydrodynamics ~MHD! test case isthe flow of an electrically conducting incompressible fluidbetween parallel insulating plates with an applied trans-verse magnetic field. Figure 8 shows such an arrangement,known as the Hartmann problem. The analytical solutionfor the velocity and magnetic field profiles are

    Figure 7. Variation of stress with angle around the hole. Curves arecalculated from the analytical solution, while the symbols represent pro-files extracted from the boundary field of the FOAM computation. Q590 is the x direction (the direction of applied strain).

    Figure 8. Geometry and symbol definition for the Hartmann problem.COMPUTERS IN PHYSICS, VOL. 12, NO. 6, NOV/DEC 1998 629

  • wall! will reduce this error. coding that they are involved in; for example, a new

    l prf disV. CONCLUSIONS

    As a discipline, CCM involves a wide range of issues: thephysics of continua, the mathematical issues of manipulat-ing the governing equations into a form capable of solution~for example, the derivation of the LES and RAS equationsfor the mean flow!, the mathematical and physical issues ofmodeling terms in these equations, and the numerical andalgorithmic issues of constructing efficient matrix inversionroutines and accurate differencing schemes for the variousderivatives. In a traditional, procedural approach to coding,the modeled equations have to be discretized and then writ-ten out in terms of components before coding can reallybegin. Since a typical general-purpose CFD code will be;100,000 lines of code, the implementation of this is verychallenging.

    The aim of this work was to produce a C11 classlibrary ~FOAM! with which it is easy to develop CCMcodes to investigate modeling and simulation of fluid flows.

    SGS model can be implemented without the need toaccess ~or even know about! the details of how thecomponents of a tensor are being stored. Since a tensoris not simply a group of components but is a math-ematical object in its own right, this is also aestheti-cally pleasing.

    ~2! Operator overloading allows the syntax of the CCMmetalanguage to closely resemble that of conventionalmathematics. This enhances legibility at high levels inthe code. Although this approach increases the numberof copying operations somewhat and involves moretemporary storage than would be the case for a moretraditional code, this has not been found to be a criticalcost, and is more than compensated for by the ease ofuse of the resulting code.

    ~3! Function overriding and the use of virtual class hierar-chies enable new low-level algorithms to be included ina manner that can be entirely transparent at higher lev-els. For example, constructing and implementing newUv0

    5cosh~y0 /d!2cosh~y /d!

    cosh~y0 /d!21,

    B

    v0mAsnr52S ~y /y0!sinh~y0 /d!2sinh~y /d!

    cosh~y0 /d!21D ,

    ~19!

    d51

    B0Arn

    s,

    where M5y0 /d is the Hartmann number. Figure 9 showsthe analytical profiles of U and B compared with a calcu-lation on a 4000-cell mesh. For M51 the computed resultsare exact, which is not too surprising, since the profile isquadratic and FOAM uses second-order numerics by de-fault. As the Hartmann number increases, the profiles be-come steeper, with greater curvature towards the edge ofthe duct. The error increases somewhat, although increasedmesh resolution ~for example, a refined mesh towards the

    Figure 9. Comparison between computed profiles (symbols) and analytica51, 5, and 20. Shown on the left is the normalized velocity as a function ofield component parallel to the flow.630 COMPUTERS IN PHYSICS, VOL. 12, NO. 6, NOV/DEC 1998In essence, FOAM is a high-level language, a CCM meta-language, that closely parallels the mathematical descrip-tion of continuum mechanics. As well as simplifying theimplementation of new models, this makes checking themodeling more straightforward. This aspect is enhanced bythe inclusion of features such as automatic dimensionchecking of operations. In addition to this, use of OOPmethodology has enabled the dissociation of different lev-els of the code, thus minimizing unwanted interaction, andpermitting research into the numerics ~differencingschemes and matrix-inversion techniques! to be largely di-vorced from that of modeling.

    A number of key properties of OOP that have enabledthe development of FOAM are the following.~1! The use of data encapsulation and data hiding enables

    lower-level details of the code, such as the implemen-tation of the basic tensorial classes, to be hidden fromview at the higher levels. This enables a user to dealonly with aspects of the code relevant to the level of

    ofiles (solid lines) for MHD flow in a channel at Hartmann numbers Mtance across the duct, and on the right is the nondimensionalized magnetic

  • differencing schemes are complicated tasks; onceimplemented, the differencing scheme should be avail-able to all high-level codes. By implementing a com-mon interface for all differencing schemes throughfunction calls div, grad, curl, ddt, etc., this can be ac-complished.

    ~4! Polymorphism can also be used to give a commonstructure to higher-level elements of the code. Hence, acommon framework for all LES SGS models can beconstructed in the form of a virtual base class, andspecific SGS models can be derived from this. Thisprovides a mechanism whereby parts of the code can

    tional Fluid Dynamics: The Finite Volume Method ~Longman Scien-tific and Technical, 1995!.

    4. B. W. R. Forde, R. O. Foschi, and S. F. Stiemer, Comput. Struct. 34,355 ~1990!.

    5. B. Stroustrup, Proceedings of the 1st European Software Festival,1991.

    6. B. Stroustrup, The C11 Programming Language, 3rd ed. ~AddisonWesley, Reading, MA, 1997!.

    7. B. Stroustrup, OOPS Messenger, 1995, an addendum to the OOPSLA95 Proceedings.

    8. J. R. Cary, S. G. Shasharina, J. C. Cummings, J. V. W. Reynders, andP. J. Hinker, Comput. Phys. Commun. ~submitted!; available at http://jove.colorado.edu/ cary/CompCPP

    F90SciOOP.html.9. Y. Dubois-Pe`lerin and Th. Zimmermann, Comput. Methods Appl.be switched at run time; it also assists in partitioningthe code into independent sections. By appropriate useof derivation, the implementation of the SGS modelscan be made to reflect their internal structure as well.

    ~5! The distinction between interface and implementationand the rigorous hiding of the implementation make itpossible to replace whole sections of the low-level codeif this should become necessary, without problemshigher up. ~In particular, the implementation of paral-lelization via domain decomposition can be madetransparent to the top level through our implementationof interprocessor boundaries. Because of this, allFOAM codes parallelize immediately.!

    ~6! Code reuse, which is a major feature of OOP, is highlyachievable in FOAM, since all CFD codes share anumber of common features: differencing schemes,solvers, tensor algebra, etc.In summary, the application of OOP techniques to

    CCM has resulted in a powerful and flexible code for in-vestigating numerics, modeling, and flow physics. Interac-tion between these levels has been kept to a minimum, andthis makes the code easy to extend and maintain. TheFOAM project demonstrates that it is possible to implementa mathematically oriented CCM metalanguage and hasdemonstrated its benefits.

    ACKNOWLEDGMENTS

    The LES work used as an example in this article was sup-ported by the EPSRC under Grants No. 43902 and K20910and by European Gas Turbines.

    REFERENCES

    1. C. A. J. Fletcher, Computational Techniques for Fluid Dynamics,Springer Series in Computational Physics Vols. I and II, 2nd ed.~Springer, Berlin, 1991!.

    2. J. H. Ferziger and M. Peric, Computational Methods for Fluid Dy-namics ~Springer, Berlin, 1996!.

    3. H. K. Versteeg and W. Malalasekera, An Introduction to Computa-Mech. Eng. 108, 165 ~1993!.10. J-L. Liu, I.-J. Lin, M.-Z. Shih, R.-C. Chen, and M.-C. Hseih, Appl.

    Numer. Math. 21, 439 ~1996!.11. Th. Zimmermann, Y. Dubois-Pe`lerin, and P. Bomme, Comput. Meth-

    ods Appl. Mech. Eng. 98, 291 ~1992!.12. L. Machiels and M. O. Deville, ACM Trans. Math. Softw. 23, 32

    ~1997!.13. Th. Zimmermann and D. Eyheramendy, Comput. Methods Appl.

    Mech. Eng. 132, 259 ~1996!.14. D. Eyheramendy and Th. Zimmermann, Comput. Methods Appl.

    Mech. Eng. 132, 277 ~1996!.15. H. Jasak, Ph.D. thesis, Imperial College, 1996.16. O. Ubbink, Ph.D. thesis, Imperial College, 1997.17. C. Fureby, G. Tabor, H. Weller, and A. D. Gosman, Phys. Fluids 9,

    1416 ~1997!.18. S. Meyer, Effective C11 ~AddisonWesley, Reading, MA, 1992!.19. M. R. Hestens and E. L. Steifel, J. Res. 29, 409 ~1952!.20. D. A. H. Jacobs, Technical report, Central Electricity Research Labo-

    ratories, 1980.21. H. A. van der Vorst, SIAM J. Comput. 13, 631 ~1992!.22. R. I. Issa, J. Comput. Phys. 62, 40 ~1986!.23. R. I. Issa, A. D. Gosman, and A. P. Watkins, J. Comput. Phys. 62, 66

    ~1986!.24. B. E. Launder and D. B. Spalding, Comput. Methods Appl. Mech.

    Eng. 3, 269 ~1974!.25. V. C. Patel, W. Rodi, and G. Scheuerer, AIAA J. 23, 1308 ~1985!.26. B. E. Launder, G. J. Reece, and W. Rodi, Progress in the develop-

    ment of a Reynolds-stress Turbulence Closure, J. Fluid Mech. 68,537 ~1975!.

    27. J. Smagorinsky, Mon. Weather Rev. 91, 99 ~1963!.28. U. Schumann, J. Comput. Phys. 18, 376 ~1975!.29. A. Yoshizawa, Phys. Fluids A 29, 2152 ~1986!.30. J. W. Deardorff, Trans. ASME, Ser. I: J. Fluids Eng. 156, 55 ~1973!.31. J. Bardina, J. H. Ferziger, and W. C. Reynolds, Technical Report No.

    TF-19, Stanford University, 1983.32. G. Erlebacher, M. Y. Hussaini, C. G. Speziale, and T. A. Zang, J.

    Fluid Mech. 238, 155 ~1992!.33. D. Lyn, S. Einav, W. Rodi, and J. Park, Technical report, Karlsruhe

    University, 1994.34. D. F. G. Durao, M. V. Heitor, and J. C. F. Pereira, Exp. Fluids 6, 298

    ~1988!.35. M. M. Gibson and B. E. Launder, J. Fluid Mech. 86, 491 ~1978!.36. V. Yakhot, S. A. Orszag, S. Thangam, T. B. Gatski, and C. G. Spe-

    ziale, Phys. Fluids A 4, 1510 ~1992!.37. I. Demirdzic and S. Muzaferija, Int. J. Numer. Methods Eng. 37, 3751

    ~1994!.38. I. Demirdzic and S. Muzaferija, Comput. Methods Appl. Mech. Eng.

    125, 235 ~1995!.COMPUTERS IN PHYSICS, VOL. 12, NO. 6, NOV/DEC 1998 631