1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 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
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 "muSgsWallFunctionFvPatchScalarField.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace compressible
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
47 const DimensionedField<scalar, volMesh>& iF
50 fixedValueFvPatchScalarField(p, iF),
59 muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
61 const muSgsWallFunctionFvPatchScalarField& ptf,
63 const DimensionedField<scalar, volMesh>& iF,
64 const fvPatchFieldMapper& mapper
67 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
69 rhoName_(ptf.rhoName_),
76 muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
79 const DimensionedField<scalar, volMesh>& iF,
80 const dictionary& dict
83 fixedValueFvPatchScalarField(p, iF, dict),
84 UName_(dict.lookupOrDefault<word>("U", "U")),
85 rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
86 muName_(dict.lookupOrDefault<word>("mu", "mu")),
87 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
88 E_(dict.lookupOrDefault<scalar>("E", 9.8))
92 muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
94 const muSgsWallFunctionFvPatchScalarField& mwfpsf
97 fixedValueFvPatchScalarField(mwfpsf),
98 UName_(mwfpsf.UName_),
99 rhoName_(mwfpsf.rhoName_),
100 muName_(mwfpsf.muName_),
101 kappa_(mwfpsf.kappa_),
106 muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
108 const muSgsWallFunctionFvPatchScalarField& mwfpsf,
109 const DimensionedField<scalar, volMesh>& iF
112 fixedValueFvPatchScalarField(mwfpsf, iF),
113 UName_(mwfpsf.UName_),
114 rhoName_(mwfpsf.rhoName_),
115 muName_(mwfpsf.muName_),
116 kappa_(mwfpsf.kappa_),
121 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
123 void muSgsWallFunctionFvPatchScalarField::evaluate
125 const Pstream::commsTypes
128 const scalarField& ry = patch().deltaCoeffs();
130 const fvPatchVectorField& U =
131 patch().lookupPatchField<volVectorField, vector>(UName_);
133 scalarField magUp = mag(U.patchInternalField() - U);
135 const scalarField& muw =
136 patch().lookupPatchField<volScalarField, scalar>(muName_);
138 const scalarField& rhow =
139 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
141 scalarField& muSgsw = *this;
143 scalarField magFaceGradU = mag(U.snGrad());
145 forAll(muSgsw, facei)
147 scalar magUpara = magUp[facei];
150 sqrt((muSgsw[facei] + muw[facei])*magFaceGradU[facei]/rhow[facei]);
159 scalar kUu = kappa_*magUpara/utau;
160 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
163 - utau/(ry[facei]*muw[facei]/rhow[facei])
165 + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
168 - 1.0/(ry[facei]*muw[facei]/rhow[facei])
170 - 1/E_*kUu*fkUu/utau;
172 scalar utauNew = utau - f/df;
173 err = mag((utau - utauNew)/utau);
176 } while (utau > VSMALL && err > 0.01 && ++iter < 10);
181 rhow[facei]*sqr(utau)/magFaceGradU[facei] - muw[facei],
193 void muSgsWallFunctionFvPatchScalarField::write(Ostream& os) const
195 fvPatchField<scalar>::write(os);
196 writeEntryIfDifferent<word>(os, "U", "U", UName_);
197 writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
198 writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
199 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
200 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
201 writeEntry("value", os);
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 muSgsWallFunctionFvPatchScalarField
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 } // End namespace LESModels
216 } // End namespace compressible
217 } // End namespace Foam
219 // ************************************************************************* //