nutWallFunctionFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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  defineTypeNameAndDebug(nutWallFunctionFvPatchScalarField, 0);
37 }
38 
39 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
40 
42 {
43  if (!isA<wallFvPatch>(patch()))
44  {
46  << "Invalid wall function specification" << nl
47  << " Patch type for patch " << patch().name()
48  << " must be wall" << nl
49  << " Current patch type is " << patch().type() << nl << endl
50  << abort(FatalError);
51  }
52 }
53 
54 
56 (
57  Ostream& os
58 ) const
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),
78  yPlusLam_(yPlusLam(kappa_, E_))
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)),
113  yPlusLam_(yPlusLam(kappa_, E_))
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  return yPlusLam_;
172 }
173 
174 
176 {
177  if (updated())
178  {
179  return;
180  }
181 
182  operator==(calcNut());
183 
184  fixedValueFvPatchScalarField::updateCoeffs();
185 }
186 
187 
189 {
191  writeLocalEntries(os);
192  writeEntry("value", os);
193 }
194 
195 
196 // ************************************************************************* //
dimensionedScalar log(const dimensionedScalar &ds)
scalar yPlusLam() const
Return the Y+ at the edge of the laminar sublayer.
virtual void writeLocalEntries(Ostream &) const
Write local wall function variables.
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:256
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:362
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
Macros for easy insertion into run-time selection tables.
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:265
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.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
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.
Namespace for OpenFOAM.