initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / turbulenceModels / RAS / compressible / wallFunctions / wallFunctionsI.H
blob19aa023b1ce64be362b19b425b0e889fecdda9d0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Global
26     wallFunctions
28 Description
29     Calculate wall dissipation from wall-functions.
31 \*---------------------------------------------------------------------------*/
34     labelList cellBoundaryFaceCount(epsilon_.size(), 0);
36     scalar Cmu25 = pow(Cmu_.value(), 0.25);
37     scalar Cmu75 = pow(Cmu_.value(), 0.75);
39     const fvPatchList& patches = mesh_.boundary();
41     //- Initialise the near-wall G field to zero
42     forAll(patches, patchi)
43     {
44         const fvPatch& curPatch = patches[patchi];
46         if (isType<wallFvPatch>(curPatch))
47         {
48             forAll(curPatch, facei)
49             {
50                 label faceCelli = curPatch.faceCells()[facei];
52                 epsilon_[faceCelli] = 0.0;
53                 G[faceCelli] = 0.0;
54             }
55         }
56     }
58     //- Accumulate the wall face contributions to epsilon and G
59     //  Increment cellBoundaryFaceCount for each face for averaging
60     forAll(patches, patchi)
61     {
62         const fvPatch& curPatch = patches[patchi];
64         if (isType<wallFvPatch>(curPatch))
65         {
66 #           include "checkPatchFieldTypes.H"
68             const scalarField& rhow = rho_.boundaryField()[patchi];
70             const scalarField& muw = mu().boundaryField()[patchi];
71             const scalarField& mutw = mut_.boundaryField()[patchi];
73             scalarField magFaceGradU =
74                 mag(U_.boundaryField()[patchi].snGrad());
76             forAll(curPatch, facei)
77             {
78                 label faceCelli = curPatch.faceCells()[facei];
80                 scalar yPlus =
81                     Cmu25*RASModel::y_[patchi][facei]
82                    *sqrt(k_[faceCelli])
83                    /(muw[facei]/rhow[facei]);
85                 // For corner cells (with two boundary or more faces),
86                 // epsilon and G in the near-wall cell are calculated
87                 // as an average
89                 cellBoundaryFaceCount[faceCelli]++;
91                 epsilon_[faceCelli] +=
92                     Cmu75*pow(k_[faceCelli], 1.5)
93                    /(kappa_.value()*RASModel::y_[patchi][facei]);
95                 if (yPlus > yPlusLam_)
96                 {
97                     G[faceCelli] +=
98                         (mutw[facei] + muw[facei])
99                        *magFaceGradU[facei]
100                        *Cmu25*sqrt(k_[faceCelli])
101                        /(kappa_.value()*RASModel::y_[patchi][facei]);
102                 }
103             }
104         }
105     }
108     // Perform the averaging
110     forAll(patches, patchi)
111     {
112         const fvPatch& curPatch = patches[patchi];
114         if (isType<wallFvPatch>(curPatch))
115         {
116             forAll(curPatch, facei)
117             {
118                 label faceCelli = curPatch.faceCells()[facei];
120                 epsilon_[faceCelli] /= cellBoundaryFaceCount[faceCelli];
121                 G[faceCelli] /= cellBoundaryFaceCount[faceCelli];
122             }
123         }
124     }
128 // ************************************************************************* //