changed isA<wallPolyPatch> & isA<wallFvPatch> almost everywhere
[openfoam-extend-OpenFOAM-1.6-ext.git] / src / turbulenceModels / compressible / RAS / derivedFvPatchFields / wallFunctions / omegaWallFunctions / omegaWallFunction / omegaWallFunctionFvPatchScalarField.C
blob51bef476424b490b51c2e3d8318852b51cf9d471
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 \*---------------------------------------------------------------------------*/
27 #include "omegaWallFunctionFvPatchScalarField.H"
28 #include "RASModel.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
37 namespace compressible
39 namespace RASModels
42 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
44 void omegaWallFunctionFvPatchScalarField::checkType()
46     if (!patch().isWall())
47     {
48         FatalErrorIn("omegaWallFunctionFvPatchScalarField::checkType()")
49             << "Invalid wall function specification" << nl
50             << "    Patch type for patch " << patch().name()
51             << " must be wall" << nl
52             << "    Current patch type is " << patch().type() << nl << endl
53             << abort(FatalError);
54     }
58 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
60 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
62     const fvPatch& p,
63     const DimensionedField<scalar, volMesh>& iF
66     fixedInternalValueFvPatchField<scalar>(p, iF),
67     UName_("U"),
68     rhoName_("rho"),
69     kName_("k"),
70     GName_("RASModel::G"),
71     muName_("mu"),
72     mutName_("mut"),
73     Cmu_(0.09),
74     kappa_(0.41),
75     E_(9.8),
76     beta1_(0.075)
78     checkType();
82 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
84     const omegaWallFunctionFvPatchScalarField& ptf,
85     const fvPatch& p,
86     const DimensionedField<scalar, volMesh>& iF,
87     const fvPatchFieldMapper& mapper
90     fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
91     UName_(ptf.UName_),
92     rhoName_(ptf.rhoName_),
93     kName_(ptf.kName_),
94     GName_(ptf.GName_),
95     muName_(ptf.muName_),
96     mutName_(ptf.mutName_),
97     Cmu_(ptf.Cmu_),
98     kappa_(ptf.kappa_),
99     E_(ptf.E_),
100     beta1_(ptf.beta1_)
102     checkType();
106 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
108     const fvPatch& p,
109     const DimensionedField<scalar, volMesh>& iF,
110     const dictionary& dict
113     fixedInternalValueFvPatchField<scalar>(p, iF, dict),
114     UName_(dict.lookupOrDefault<word>("U", "U")),
115     rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
116     kName_(dict.lookupOrDefault<word>("k", "k")),
117     GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
118     muName_(dict.lookupOrDefault<word>("mu", "mu")),
119     mutName_(dict.lookupOrDefault<word>("mut", "mut")),
120     Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
121     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
122     E_(dict.lookupOrDefault<scalar>("E", 9.8)),
123     beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075))
125     checkType();
129 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
131     const omegaWallFunctionFvPatchScalarField& owfpsf
134     fixedInternalValueFvPatchField<scalar>(owfpsf),
135     UName_(owfpsf.UName_),
136     rhoName_(owfpsf.rhoName_),
137     kName_(owfpsf.kName_),
138     GName_(owfpsf.GName_),
139     muName_(owfpsf.muName_),
140     mutName_(owfpsf.mutName_),
141     Cmu_(owfpsf.Cmu_),
142     kappa_(owfpsf.kappa_),
143     E_(owfpsf.E_),
144     beta1_(owfpsf.beta1_)
146     checkType();
150 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
152     const omegaWallFunctionFvPatchScalarField& owfpsf,
153     const DimensionedField<scalar, volMesh>& iF
156     fixedInternalValueFvPatchField<scalar>(owfpsf, iF),
157     UName_(owfpsf.UName_),
158     rhoName_(owfpsf.rhoName_),
159     kName_(owfpsf.kName_),
160     GName_(owfpsf.GName_),
161     muName_(owfpsf.muName_),
162     mutName_(owfpsf.mutName_),
163     Cmu_(owfpsf.Cmu_),
164     kappa_(owfpsf.kappa_),
165     E_(owfpsf.E_),
166     beta1_(owfpsf.beta1_)
168     checkType();
172 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
174 void omegaWallFunctionFvPatchScalarField::updateCoeffs()
176     if (updated())
177     {
178         return;
179     }
181     // If G field is not present, execute zero gradient evaluation
182     // HJ, 20/Mar/2011
183     if (!db().foundObject<volScalarField>(GName_))
184     {
185         zeroGradientFvPatchScalarField::evaluate();
187         return;
188     }
190     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
191     const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
192     const scalarField& y = rasModel.y()[patch().index()];
194     const scalar Cmu25 = pow(Cmu_, 0.25);
196     volScalarField& G = const_cast<volScalarField&>
197         (db().lookupObject<volScalarField>(GName_));
199     volScalarField& omega = const_cast<volScalarField&>
200         (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
202     const scalarField& k = db().lookupObject<volScalarField>(kName_);
204     const scalarField& rhow =
205         patch().lookupPatchField<volScalarField, scalar>(rhoName_);
207     const scalarField& muw =
208         patch().lookupPatchField<volScalarField, scalar>(muName_);
210     const scalarField& mutw =
211         patch().lookupPatchField<volScalarField, scalar>(mutName_);
213     const fvPatchVectorField& Uw =
214         patch().lookupPatchField<volVectorField, vector>(UName_);
216     const scalarField magGradUw = mag(Uw.snGrad());
218     // Set omega and G
219     forAll(mutw, faceI)
220     {
221         label faceCellI = patch().faceCells()[faceI];
223         scalar yPlus =
224             Cmu25*y[faceI]*sqrt(k[faceCellI])
225            /(muw[faceI]/rhow[faceI]);
227         scalar omegaVis = 6.0*(muw[faceI]/rhow[faceI])/(beta1_*sqr(y[faceI]));
229         scalar omegaLog = sqrt(k[faceCellI])/(Cmu25*kappa_*y[faceI]);
231         omega[faceCellI] = sqrt(sqr(omegaVis) + sqr(omegaLog));
233         if (yPlus > yPlusLam)
234         {
235             G[faceCellI] =
236                 (mutw[faceI] + muw[faceI])
237                *magGradUw[faceI]
238                *Cmu25*sqrt(k[faceCellI])
239                /(kappa_*y[faceI]);
240         }
241         else
242         {
243             G[faceCellI] = 0.0;
244         }
245     }
247     // TODO: perform averaging for cells sharing more than one boundary face
249     fixedInternalValueFvPatchField<scalar>::updateCoeffs();
253 void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const
255     fixedInternalValueFvPatchField<scalar>::write(os);
256     writeEntryIfDifferent<word>(os, "U", "U", UName_);
257     writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
258     writeEntryIfDifferent<word>(os, "k", "k", kName_);
259     writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
260     writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
261     writeEntryIfDifferent<word>(os, "mut", "mut", mutName_);
262     os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
263     os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
264     os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
265     os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
266     writeEntry("value", os);
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 makePatchTypeField
274     fvPatchScalarField,
275     omegaWallFunctionFvPatchScalarField
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 } // End namespace RASModels
281 } // End namespace compressible
282 } // End namespace Foam
284 // ************************************************************************* //