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 "nuSgsWallFunctionFvPatchScalarField.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace incompressible
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 nuSgsWallFunctionFvPatchScalarField::
44 nuSgsWallFunctionFvPatchScalarField
47 const DimensionedField<scalar, volMesh>& iF
50 fixedValueFvPatchScalarField(p, iF),
58 nuSgsWallFunctionFvPatchScalarField::
59 nuSgsWallFunctionFvPatchScalarField
61 const nuSgsWallFunctionFvPatchScalarField& ptf,
63 const DimensionedField<scalar, volMesh>& iF,
64 const fvPatchFieldMapper& mapper
67 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
75 nuSgsWallFunctionFvPatchScalarField::
76 nuSgsWallFunctionFvPatchScalarField
79 const DimensionedField<scalar, volMesh>& iF,
80 const dictionary& dict
83 fixedValueFvPatchScalarField(p, iF, dict),
84 UName_(dict.lookupOrDefault<word>("U", "U")),
85 nuName_(dict.lookupOrDefault<word>("nu", "nu")),
86 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
87 E_(dict.lookupOrDefault<scalar>("E", 9.8))
91 nuSgsWallFunctionFvPatchScalarField::
92 nuSgsWallFunctionFvPatchScalarField
94 const nuSgsWallFunctionFvPatchScalarField& nwfpsf
97 fixedValueFvPatchScalarField(nwfpsf),
98 UName_(nwfpsf.UName_),
99 nuName_(nwfpsf.nuName_),
100 kappa_(nwfpsf.kappa_),
105 nuSgsWallFunctionFvPatchScalarField::
106 nuSgsWallFunctionFvPatchScalarField
108 const nuSgsWallFunctionFvPatchScalarField& nwfpsf,
109 const DimensionedField<scalar, volMesh>& iF
112 fixedValueFvPatchScalarField(nwfpsf, iF),
113 UName_(nwfpsf.UName_),
114 nuName_(nwfpsf.nuName_),
115 kappa_(nwfpsf.kappa_),
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 void nuSgsWallFunctionFvPatchScalarField::evaluate
124 const Pstream::commsTypes
127 const scalarField& ry = patch().deltaCoeffs();
129 const fvPatchVectorField& U =
130 patch().lookupPatchField<volVectorField, vector>(UName_);
132 scalarField magUp = mag(U.patchInternalField() - U);
134 const scalarField& nuw =
135 patch().lookupPatchField<volScalarField, scalar>(nuName_);
136 scalarField& nuSgsw = *this;
139 scalarField magFaceGradU = mag(U.snGrad());
141 forAll(nuSgsw, facei)
143 scalar magUpara = magUp[facei];
145 scalar utau = sqrt((nuSgsw[facei] + nuw[facei])*magFaceGradU[facei]);
154 scalar kUu = min(kappa_*magUpara/utau, 50);
155 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
158 - utau/(ry[facei]*nuw[facei])
160 + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
163 - 1.0/(ry[facei]*nuw[facei])
165 - 1/E_*kUu*fkUu/utau;
167 scalar utauNew = utau - f/df;
168 err = mag((utau - utauNew)/utau);
171 } while (utau > VSMALL && err > 0.01 && ++iter < 10);
174 max(sqr(max(utau, 0))/magFaceGradU[facei] - nuw[facei], 0.0);
184 void nuSgsWallFunctionFvPatchScalarField::write(Ostream& os) const
186 fvPatchField<scalar>::write(os);
187 writeEntryIfDifferent<word>(os, "U", "U", UName_);
188 writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
189 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
190 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
191 writeEntry("value", os);
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 nuSgsWallFunctionFvPatchScalarField
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 } // End namespace LESModels
206 } // End namespace incompressible
207 } // End namespace Foam
209 // ************************************************************************* //