changed isA<wallPolyPatch> & isA<wallFvPatch> almost everywhere
[openfoam-extend-OpenFOAM-1.6-ext.git] / src / turbulenceModels / incompressible / RAS / derivedFvPatchFields / wallFunctions / omegaWallFunctions / omegaWallFunction / omegaWallFunctionFvPatchScalarField.C
blob0c6f547da7fbe48871089fa053eecb92618160e7
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 incompressible
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     kName_("k"),
69     GName_("RASModel::G"),
70     nuName_("nu"),
71     nutName_("nut"),
72     Cmu_(0.09),
73     kappa_(0.41),
74     E_(9.8),
75     beta1_(0.075)
77     checkType();
81 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
83     const omegaWallFunctionFvPatchScalarField& 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     nuName_(ptf.nuName_),
94     nutName_(ptf.nutName_),
95     Cmu_(ptf.Cmu_),
96     kappa_(ptf.kappa_),
97     E_(ptf.E_),
98     beta1_(ptf.beta1_)
100     checkType();
104 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
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     nuName_(dict.lookupOrDefault<word>("nu", "nu")),
116     nutName_(dict.lookupOrDefault<word>("nut", "nut")),
117     Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
118     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
119     E_(dict.lookupOrDefault<scalar>("E", 9.8)),
120     beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075))
122     checkType();
126 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
128     const omegaWallFunctionFvPatchScalarField& owfpsf
131     fixedInternalValueFvPatchField<scalar>(owfpsf),
132     UName_(owfpsf.UName_),
133     kName_(owfpsf.kName_),
134     GName_(owfpsf.GName_),
135     nuName_(owfpsf.nuName_),
136     nutName_(owfpsf.nutName_),
137     Cmu_(owfpsf.Cmu_),
138     kappa_(owfpsf.kappa_),
139     E_(owfpsf.E_),
140     beta1_(owfpsf.beta1_)
142     checkType();
146 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
148     const omegaWallFunctionFvPatchScalarField& owfpsf,
149     const DimensionedField<scalar, volMesh>& iF
152     fixedInternalValueFvPatchField<scalar>(owfpsf, iF),
153     UName_(owfpsf.UName_),
154     kName_(owfpsf.kName_),
155     GName_(owfpsf.GName_),
156     nuName_(owfpsf.nuName_),
157     nutName_(owfpsf.nutName_),
158     Cmu_(owfpsf.Cmu_),
159     kappa_(owfpsf.kappa_),
160     E_(owfpsf.E_),
161     beta1_(owfpsf.beta1_)
163     checkType();
167 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
169 void omegaWallFunctionFvPatchScalarField::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::evaluate();
182         return;
183     }
185     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
186     const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
187     const scalarField& y = rasModel.y()[patch().index()];
189     const scalar Cmu25 = pow(Cmu_, 0.25);
191     volScalarField& G = const_cast<volScalarField&>
192         (db().lookupObject<volScalarField>(GName_));
194     volScalarField& omega = const_cast<volScalarField&>
195         (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
197     const scalarField& k = db().lookupObject<volScalarField>(kName_);
199     const scalarField& nuw =
200         patch().lookupPatchField<volScalarField, scalar>(nuName_);
202     const scalarField& nutw =
203         patch().lookupPatchField<volScalarField, scalar>(nutName_);
205     const fvPatchVectorField& Uw =
206         patch().lookupPatchField<volVectorField, vector>(UName_);
208     vectorField n = patch().nf();
210     const scalarField magGradUw = mag(Uw.snGrad());
212     // Set omega and G
213     forAll(nutw, faceI)
214     {
215         label faceCellI = patch().faceCells()[faceI];
217         scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
219         scalar omegaVis = 6.0*nuw[faceI]/(beta1_*sqr(y[faceI]));
221         scalar omegaLog = sqrt(k[faceCellI])/(Cmu25*kappa_*y[faceI]);
223         omega[faceCellI] = sqrt(sqr(omegaVis) + sqr(omegaLog));
225         if (yPlus > yPlusLam)
226         {
227             G[faceCellI] =
228                 (nutw[faceI] + nuw[faceI])
229                *magGradUw[faceI]
230                *Cmu25*sqrt(k[faceCellI])
231                /(kappa_*y[faceI]);
232         }
233         else
234         {
235             G[faceCellI] = 0.0;
236         }
237     }
239     // TODO: perform averaging for cells sharing more than one boundary face
241     fixedInternalValueFvPatchField<scalar>::updateCoeffs();
245 void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const
247     fixedInternalValueFvPatchField<scalar>::write(os);
248     writeEntryIfDifferent<word>(os, "U", "U", UName_);
249     writeEntryIfDifferent<word>(os, "k", "k", kName_);
250     writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
251     writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
252     writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
253     os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
254     os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
255     os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
256     os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
257     writeEntry("value", os);
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 makePatchTypeField
265     fvPatchScalarField,
266     omegaWallFunctionFvPatchScalarField
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 } // End namespace RASModels
272 } // End namespace incompressible
273 } // End namespace Foam
275 // ************************************************************************* //