initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / turbulenceModels / incompressible / RAS / include / nonLinearWallFunctionsI.H
blobe88e0f8ee317b0bcff4337a0ad7ccf83d8da4ef1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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     nonLinearwallFunctions
28 Description
29     Calculate wall generation and dissipation from wall-functions
30     for non-linear models.
32 \*---------------------------------------------------------------------------*/
35     labelList cellBoundaryFaceCount(epsilon_.size(), 0);
37     scalar yPlusLam = this->yPlusLam(kappa_.value(), E_.value());
39     const fvPatchList& patches = mesh_.boundary();
41     //- Initialise the near-wall G and epsilon fields 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& nuw = nu().boundaryField()[patchi];
69             const scalarField& nutw = nut_.boundaryField()[patchi];
71             scalarField magFaceGradU = mag(U_.boundaryField()[patchi].snGrad());
73             forAll(curPatch, facei)
74             {
75                 label faceCelli = curPatch.faceCells()[facei];
77                 //- using local Cmu !
78                 scalar Cmu25 = pow(Cmu_[faceCelli], 0.25);
79                 scalar Cmu75 = pow(Cmu_[faceCelli], 0.75);
81                 scalar yPlus =
82                     Cmu25*y_[patchi][facei]
83                     *sqrt(k_[faceCelli])
84                     /nuw[facei];
86                 // For corner cells (with two boundary or more faces),
87                 // epsilon and G in the near-wall cell are calculated
88                 // as an average
90                 cellBoundaryFaceCount[faceCelli]++;
92                 epsilon_[faceCelli] +=
93                      Cmu75*pow(k_[faceCelli], 1.5)
94                     /(kappa_.value()*y_[patchi][facei]);
96                 if (yPlus > yPlusLam)
97                 {
98                     G[faceCelli] +=
99                         (nutw[facei] + nuw[facei])
100                         *magFaceGradU[facei]
101                         *Cmu25*sqrt(k_[faceCelli])
102                         /(kappa_.value()*y_[patchi][facei])
103                       - (nonlinearStress_[faceCelli] && gradU_[faceCelli]);
104                 }
105             }
106         }
107     }
109     // Perform the averaging
111     forAll(patches, patchi)
112     {
113         const fvPatch& curPatch = patches[patchi];
115         if (isType<wallFvPatch>(curPatch))
116         {
117             forAll(curPatch, facei)
118             {
119                 label faceCelli = curPatch.faceCells()[facei];
121                 epsilon_[faceCelli] /= cellBoundaryFaceCount[faceCelli];
122                 G[faceCelli] /= cellBoundaryFaceCount[faceCelli];
123             }
124         }
125     }
129 // ************************************************************************* //