BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / RAS / include / nonLinearWallFunctionsI.H
blob9489ad078fa3dbd01744b911704b383c6484c1b6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Global
25     nonLinearwallFunctions
27 Description
28     Calculate wall generation and dissipation from wall-functions
29     for non-linear models.
31 \*---------------------------------------------------------------------------*/
34     labelList cellBoundaryFaceCount(epsilon_.size(), 0);
36     scalar yPlusLam = this->yPlusLam(kappa_.value(), E_.value());
38     const fvPatchList& patches = mesh_.boundary();
40     //- Initialise the near-wall G and epsilon fields to zero
41     forAll(patches, patchi)
42     {
43         const fvPatch& curPatch = patches[patchi];
45         if (isA<wallFvPatch>(curPatch))
46         {
47             forAll(curPatch, facei)
48             {
49                 label faceCelli = curPatch.faceCells()[facei];
51                 epsilon_[faceCelli] = 0.0;
52                 G[faceCelli] = 0.0;
53             }
54         }
55     }
57     const volScalarField nuLam(this->nu());
59     //- Accumulate the wall face contributions to epsilon and G
60     //  Increment cellBoundaryFaceCount for each face for averaging
61     forAll(patches, patchi)
62     {
63         const fvPatch& curPatch = patches[patchi];
65         if (isA<wallFvPatch>(curPatch))
66         {
67             #include "checkPatchFieldTypes.H"
69             const scalarField& nuw = nuLam.boundaryField()[patchi];
70             const scalarField& nutw = nut_.boundaryField()[patchi];
72             const scalarField magFaceGradU
73             (
74                 mag(U_.boundaryField()[patchi].snGrad())
75             );
77             forAll(curPatch, facei)
78             {
79                 label faceCelli = curPatch.faceCells()[facei];
81                 //- using local Cmu !
82                 scalar Cmu25 = pow025(Cmu_[faceCelli]);
83                 scalar Cmu75 = pow(Cmu_[faceCelli], 0.75);
85                 scalar yPlus =
86                     Cmu25*y_[patchi][facei]
87                     *sqrt(k_[faceCelli])
88                     /nuw[facei];
90                 // For corner cells (with two boundary or more faces),
91                 // epsilon and G in the near-wall cell are calculated
92                 // as an average
94                 cellBoundaryFaceCount[faceCelli]++;
96                 epsilon_[faceCelli] +=
97                      Cmu75*pow(k_[faceCelli], 1.5)
98                     /(kappa_.value()*y_[patchi][facei]);
100                 if (yPlus > yPlusLam)
101                 {
102                     G[faceCelli] +=
103                         (nutw[facei] + nuw[facei])
104                         *magFaceGradU[facei]
105                         *Cmu25*sqrt(k_[faceCelli])
106                         /(kappa_.value()*y_[patchi][facei])
107                       - (nonlinearStress_[faceCelli] && gradU_[faceCelli]);
108                 }
109             }
110         }
111     }
113     // Perform the averaging
115     forAll(patches, patchi)
116     {
117         const fvPatch& curPatch = patches[patchi];
119         if (isA<wallFvPatch>(curPatch))
120         {
121             forAll(curPatch, facei)
122             {
123                 label faceCelli = curPatch.faceCells()[facei];
125                 epsilon_[faceCelli] /= cellBoundaryFaceCount[faceCelli];
126                 G[faceCelli] /= cellBoundaryFaceCount[faceCelli];
127             }
128         }
129     }
133 // ************************************************************************* //