nutWallFunctionFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------* \
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "fvPatchFieldMapper.H"
28 #include "volFields.H"
29 #include "wallFvPatch.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 defineTypeNameAndDebug(nutWallFunctionFvPatchScalarField, 0);
40 
41 
42 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
43 
45 {
46  if (!isA<wallFvPatch>(patch()))
47  {
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  }
55 }
56 
57 
59 {
60  os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
61  os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
62  os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
63 }
64 
65 
66 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
67 
69 (
70  const fvPatch& p,
72 )
73 :
74  fixedValueFvPatchScalarField(p, iF),
75  Cmu_(0.09),
76  kappa_(0.41),
77  E_(9.8),
79 {
80  checkType();
81 }
82 
83 
85 (
87  const fvPatch& p,
89  const fvPatchFieldMapper& mapper
90 )
91 :
92  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
93  Cmu_(ptf.Cmu_),
94  kappa_(ptf.kappa_),
95  E_(ptf.E_),
96  yPlusLam_(ptf.yPlusLam_)
97 {
98  checkType();
99 }
100 
101 
103 (
104  const fvPatch& p,
106  const dictionary& dict
107 )
108 :
109  fixedValueFvPatchScalarField(p, iF, dict),
110  Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
111  kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
112  E_(dict.lookupOrDefault<scalar>("E", 9.8)),
114 {
115  checkType();
116 }
117 
118 
120 (
122 )
123 :
124  fixedValueFvPatchScalarField(wfpsf),
125  Cmu_(wfpsf.Cmu_),
126  kappa_(wfpsf.kappa_),
127  E_(wfpsf.E_),
128  yPlusLam_(wfpsf.yPlusLam_)
129 {
130  checkType();
131 }
132 
133 
135 (
138 )
139 :
140  fixedValueFvPatchScalarField(wfpsf, iF),
141  Cmu_(wfpsf.Cmu_),
142  kappa_(wfpsf.kappa_),
143  E_(wfpsf.E_),
144  yPlusLam_(wfpsf.yPlusLam_)
145 {
146  checkType();
147 }
148 
149 
150 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
151 
153 (
154  const scalar kappa,
155  const scalar E
156 )
157 {
158  scalar ypl = 11.0;
159 
160  for (int i=0; i<10; i++)
161  {
162  ypl = log(max(E*ypl, 1))/kappa;
163  }
164 
165  return ypl;
166 }
167 
168 
170 {
171  if (updated())
172  {
173  return;
174  }
175 
176  operator==(calcNut());
177 
178  fixedValueFvPatchScalarField::updateCoeffs();
179 }
180 
181 
183 {
185  writeLocalEntries(os);
186  writeEntry("value", os);
187 }
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace Foam
193 
194 // ************************************************************************* //
dimensionedScalar log(const dimensionedScalar &ds)
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
virtual tmp< scalarField > calcNut() const =0
Calculate the turbulence viscosity.
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
Macros for easy insertion into run-time selection tables.
virtual void writeLocalEntries(Ostream &) const
Write local wall function variables.
This boundary condition provides a turbulent kinematic viscosity condition when using wall functions...
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::fvPatchFieldMapper.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:262
defineTypeNameAndDebug(combustionModel, 0)
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
virtual void checkType()
Check the type of the patch.
static scalar yPlusLam(const scalar kappa, const scalar E)
Calculate the Y+ at the edge of the laminar sublayer.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
nutWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
scalar yPlusLam_
Y+ at the edge of the laminar sublayer.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Namespace for OpenFOAM.
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:363