1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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 \*---------------------------------------------------------------------------*/
26 #include "muSgsUSpaldingWallFunctionFvPatchScalarField.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace compressible
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 muSgsUSpaldingWallFunctionFvPatchScalarField::
44 muSgsUSpaldingWallFunctionFvPatchScalarField
47 const DimensionedField<scalar, volMesh>& iF
50 fixedValueFvPatchScalarField(p, iF),
59 muSgsUSpaldingWallFunctionFvPatchScalarField::
60 muSgsUSpaldingWallFunctionFvPatchScalarField
62 const muSgsUSpaldingWallFunctionFvPatchScalarField& ptf,
64 const DimensionedField<scalar, volMesh>& iF,
65 const fvPatchFieldMapper& mapper
68 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
70 rhoName_(ptf.rhoName_),
77 muSgsUSpaldingWallFunctionFvPatchScalarField::
78 muSgsUSpaldingWallFunctionFvPatchScalarField
81 const DimensionedField<scalar, volMesh>& iF,
82 const dictionary& dict
85 fixedValueFvPatchScalarField(p, iF, dict),
86 UName_(dict.lookupOrDefault<word>("U", "U")),
87 rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
88 muName_(dict.lookupOrDefault<word>("mu", "mu")),
89 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
90 E_(dict.lookupOrDefault<scalar>("E", 9.8))
94 muSgsUSpaldingWallFunctionFvPatchScalarField::
95 muSgsUSpaldingWallFunctionFvPatchScalarField
97 const muSgsUSpaldingWallFunctionFvPatchScalarField& mwfpsf
100 fixedValueFvPatchScalarField(mwfpsf),
101 UName_(mwfpsf.UName_),
102 rhoName_(mwfpsf.rhoName_),
103 muName_(mwfpsf.muName_),
104 kappa_(mwfpsf.kappa_),
109 muSgsUSpaldingWallFunctionFvPatchScalarField::
110 muSgsUSpaldingWallFunctionFvPatchScalarField
112 const muSgsUSpaldingWallFunctionFvPatchScalarField& mwfpsf,
113 const DimensionedField<scalar, volMesh>& iF
116 fixedValueFvPatchScalarField(mwfpsf, iF),
117 UName_(mwfpsf.UName_),
118 rhoName_(mwfpsf.rhoName_),
119 muName_(mwfpsf.muName_),
120 kappa_(mwfpsf.kappa_),
125 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
127 void muSgsUSpaldingWallFunctionFvPatchScalarField::evaluate
129 const Pstream::commsTypes
132 const scalarField& ry = patch().deltaCoeffs();
134 const fvPatchVectorField& U =
135 patch().lookupPatchField<volVectorField, vector>(UName_);
137 const scalarField magUp(mag(U.patchInternalField() - U));
139 const scalarField& muw =
140 patch().lookupPatchField<volScalarField, scalar>(muName_);
142 const scalarField& rhow =
143 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
145 scalarField& muSgsw = *this;
147 const scalarField magFaceGradU(mag(U.snGrad()));
149 forAll(muSgsw, facei)
151 scalar magUpara = magUp[facei];
154 sqrt((muSgsw[facei] + muw[facei])*magFaceGradU[facei]/rhow[facei]);
163 scalar kUu = kappa_*magUpara/utau;
164 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
167 - utau/(ry[facei]*muw[facei]/rhow[facei])
169 + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
172 - 1.0/(ry[facei]*muw[facei]/rhow[facei])
174 - 1/E_*kUu*fkUu/utau;
176 scalar utauNew = utau - f/df;
177 err = mag((utau - utauNew)/utau);
180 } while (utau > VSMALL && err > 0.01 && ++iter < 10);
185 rhow[facei]*sqr(utau)/magFaceGradU[facei] - muw[facei],
197 void muSgsUSpaldingWallFunctionFvPatchScalarField::write(Ostream& os) const
199 fvPatchField<scalar>::write(os);
200 writeEntryIfDifferent<word>(os, "U", "U", UName_);
201 writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
202 writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
203 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
204 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
205 writeEntry("value", os);
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 muSgsUSpaldingWallFunctionFvPatchScalarField
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 } // End namespace LESModels
220 } // End namespace compressible
221 } // End namespace Foam
223 // ************************************************************************* //