Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / turbulenceModels / incompressible / RAS / include / nonLinearWallFunctionsI.H
blob1c3a999a4b182615286ae9e1ac55469dd18389d1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  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 (curPatch.isWall())
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     //- Accumulate the wall face contributions to epsilon and G
58     //  Increment cellBoundaryFaceCount for each face for averaging
59     forAll(patches, patchi)
60     {
61         const fvPatch& curPatch = patches[patchi];
63         if (curPatch.isWall())
64         {
65             #include "checkPatchFieldTypes.H"
67             const scalarField& nuw = nu().boundaryField()[patchi];
68             const scalarField& nutw = nut_.boundaryField()[patchi];
70             scalarField magFaceGradU = mag(U_.boundaryField()[patchi].snGrad());
72             forAll(curPatch, facei)
73             {
74                 label faceCelli = curPatch.faceCells()[facei];
76                 //- using local Cmu !
77                 scalar Cmu25 = pow(Cmu_[faceCelli], 0.25);
78                 scalar Cmu75 = pow(Cmu_[faceCelli], 0.75);
80                 scalar yPlus =
81                     Cmu25*y_[patchi][facei]
82                     *sqrt(k_[faceCelli])
83                     /nuw[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()*y_[patchi][facei]);
95                 if (yPlus > yPlusLam)
96                 {
97                     G[faceCelli] +=
98                         (nutw[facei] + nuw[facei])
99                         *magFaceGradU[facei]
100                         *Cmu25*sqrt(k_[faceCelli])
101                         /(kappa_.value()*y_[patchi][facei])
102                       - (nonlinearStress_[faceCelli] && gradU_[faceCelli]);
103                 }
104             }
105         }
106     }
108     // Perform the averaging
110     forAll(patches, patchi)
111     {
112         const fvPatch& curPatch = patches[patchi];
114         if (curPatch.isWall())
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 // ************************************************************************* //