changed isA<wallPolyPatch> & isA<wallFvPatch> almost everywhere
[openfoam-extend-OpenFOAM-1.6-ext.git] / src / turbulenceModels / compressible / RAS / derivedFvPatchFields / wallFunctions / epsilonWallFunctions / epsilonWallFunction / epsilonWallFunctionFvPatchScalarField.C
blob89f79aa55d773917a55d1ccf5b0d6216d82590ba
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 "epsilonWallFunctionFvPatchScalarField.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 epsilonWallFunctionFvPatchScalarField::checkType()
46     if (!patch().isWall())
47     {
48         FatalErrorIn("epsilonWallFunctionFvPatchScalarField::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 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
62     const fvPatch& p,
63     const DimensionedField<scalar, volMesh>& iF
66     fixedInternalValueFvPatchField<scalar>(p, iF),
67     UName_("U"),
68     kName_("k"),
69     GName_("RASModel::G"),
70     rhoName_("rho"),
71     muName_("mu"),
72     mutName_("mut"),
73     Cmu_(0.09),
74     kappa_(0.41),
75     E_(9.8)
77     checkType();
81 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
83     const epsilonWallFunctionFvPatchScalarField& ptf,
84     const fvPatch& p,
85     const DimensionedField<scalar, volMesh>& iF,
86     const fvPatchFieldMapper& mapper
89     fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
90     UName_(ptf.UName_),
91     kName_(ptf.kName_),
92     GName_(ptf.GName_),
93     rhoName_(ptf.rhoName_),
94     muName_(ptf.muName_),
95     mutName_(ptf.mutName_),
96     Cmu_(ptf.Cmu_),
97     kappa_(ptf.kappa_),
98     E_(ptf.E_)
100     checkType();
104 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
106     const fvPatch& p,
107     const DimensionedField<scalar, volMesh>& iF,
108     const dictionary& dict
111     fixedInternalValueFvPatchField<scalar>(p, iF, dict),
112     UName_(dict.lookupOrDefault<word>("U", "U")),
113     kName_(dict.lookupOrDefault<word>("k", "k")),
114     GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
115     rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
116     muName_(dict.lookupOrDefault<word>("mu", "mu")),
117     mutName_(dict.lookupOrDefault<word>("mut", "mut")),
118     Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
119     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
120     E_(dict.lookupOrDefault<scalar>("E", 9.8))
122     checkType();
126 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
128     const epsilonWallFunctionFvPatchScalarField& ewfpsf
131     fixedInternalValueFvPatchField<scalar>(ewfpsf),
132     UName_(ewfpsf.UName_),
133     kName_(ewfpsf.kName_),
134     GName_(ewfpsf.GName_),
135     rhoName_(ewfpsf.rhoName_),
136     muName_(ewfpsf.muName_),
137     mutName_(ewfpsf.mutName_),
138     Cmu_(ewfpsf.Cmu_),
139     kappa_(ewfpsf.kappa_),
140     E_(ewfpsf.E_)
142     checkType();
146 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
148     const epsilonWallFunctionFvPatchScalarField& ewfpsf,
149     const DimensionedField<scalar, volMesh>& iF
152     fixedInternalValueFvPatchField<scalar>(ewfpsf, iF),
153     UName_(ewfpsf.UName_),
154     kName_(ewfpsf.kName_),
155     GName_(ewfpsf.GName_),
156     rhoName_(ewfpsf.rhoName_),
157     muName_(ewfpsf.muName_),
158     mutName_(ewfpsf.mutName_),
159     Cmu_(ewfpsf.Cmu_),
160     kappa_(ewfpsf.kappa_),
161     E_(ewfpsf.E_)
163     checkType();
167 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
169 void epsilonWallFunctionFvPatchScalarField::updateCoeffs()
171     if (updated())
172     {
173         return;
174     }
176     // If G field is not present, execute zero gradient evaluation
177     // HJ, 20/Mar/2011
178     if (!db().foundObject<volScalarField>(GName_))
179     {
180         zeroGradientFvPatchScalarField::updateCoeffs();
182         return;
183     }
185     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
187     const scalar Cmu25 = pow(Cmu_, 0.25);
188     const scalar Cmu75 = pow(Cmu_, 0.75);
189     const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
191     const scalarField& y = rasModel.y()[patch().index()];
193     volScalarField& G = const_cast<volScalarField&>
194         (db().lookupObject<volScalarField>(GName_));
196     volScalarField& epsilon = const_cast<volScalarField&>
197         (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
199     const volScalarField& k = db().lookupObject<volScalarField>(kName_);
201     const scalarField& rhow =
202         patch().lookupPatchField<volScalarField, scalar>(rhoName_);
204     const scalarField& muw =
205         patch().lookupPatchField<volScalarField, scalar>(muName_);
207     const scalarField& mutw =
208         patch().lookupPatchField<volScalarField, scalar>(mutName_);
210     const fvPatchVectorField& Uw =
211         patch().lookupPatchField<volVectorField, vector>(UName_);
213     const scalarField magGradUw = mag(Uw.snGrad());
215     // Set epsilon and G
216     forAll(mutw, faceI)
217     {
218         label faceCellI = patch().faceCells()[faceI];
220         scalar yPlus =
221             Cmu25*y[faceI]*sqrt(k[faceCellI])
222            /(muw[faceI]/rhow[faceI]);
224         epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa_*y[faceI]);
226         if (yPlus > yPlusLam)
227         {
228             G[faceCellI] =
229                 (mutw[faceI] + muw[faceI])
230                *magGradUw[faceI]
231                *Cmu25*sqrt(k[faceCellI])
232                /(kappa_*y[faceI]);
233         }
234         else
235         {
236             G[faceCellI] = 0.0;
237         }
238     }
240     // TODO: perform averaging for cells sharing more than one boundary face
242     fixedInternalValueFvPatchField<scalar>::updateCoeffs();
246 void epsilonWallFunctionFvPatchScalarField::evaluate
248     const Pstream::commsTypes commsType
251     fixedInternalValueFvPatchField<scalar>::evaluate(commsType);
255 void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const
257     fixedInternalValueFvPatchField<scalar>::write(os);
258     writeEntryIfDifferent<word>(os, "U", "U", UName_);
259     writeEntryIfDifferent<word>(os, "k", "k", kName_);
260     writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
261     writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
262     writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
263     writeEntryIfDifferent<word>(os, "mut", "mut", mutName_);
264     os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
265     os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
266     os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
267     writeEntry("value", os);
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 makePatchTypeField
275     fvPatchScalarField,
276     epsilonWallFunctionFvPatchScalarField
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 } // End namespace RASModels
282 } // End namespace compressible
283 } // End namespace Foam
285 // ************************************************************************* //