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),
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  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 // ************************************************************************* //
Foam::nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
nutWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: nutWallFunctionFvPatchScalarField.C:69
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
p
p
Definition: pEqn.H:62
Foam::nutWallFunctionFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: nutWallFunctionFvPatchScalarField.C:169
Foam::nutWallFunctionFvPatchScalarField::yPlusLam_
scalar yPlusLam_
Y+ at the edge of the laminar sublayer.
Definition: nutWallFunctionFvPatchScalarField.H:119
nutWallFunctionFvPatchScalarField.H
wallFvPatch.H
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Definition: dictionaryTemplates.C:33
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
fvPatchFieldMapper.H
Foam::constant::electromagnetic::kappa
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
Foam::nutWallFunctionFvPatchScalarField::kappa_
scalar kappa_
Von Karman constant.
Definition: nutWallFunctionFvPatchScalarField.H:113
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::nutWallFunctionFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: nutWallFunctionFvPatchScalarField.C:182
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::nutWallFunctionFvPatchScalarField::calcNut
virtual tmp< scalarField > calcNut() const =0
Calculate the turbulence viscosity.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::nutWallFunctionFvPatchScalarField::E_
scalar E_
E coefficient.
Definition: nutWallFunctionFvPatchScalarField.H:116
Foam::log
dimensionedScalar log(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:253
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::nutWallFunctionFvPatchScalarField::Cmu_
scalar Cmu_
Cmu coefficient.
Definition: nutWallFunctionFvPatchScalarField.H:110
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::nutWallFunctionFvPatchScalarField
This boundary condition provides a turbulent kinematic viscosity condition when using wall functions,...
Definition: nutWallFunctionFvPatchScalarField.H:101
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::nutWallFunctionFvPatchScalarField::yPlusLam
static scalar yPlusLam(const scalar kappa, const scalar E)
Calculate the Y+ at the edge of the laminar sublayer.
Definition: nutWallFunctionFvPatchScalarField.C:153
Foam::nutWallFunctionFvPatchScalarField::writeLocalEntries
virtual void writeLocalEntries(Ostream &) const
Write local wall function variables.
Definition: nutWallFunctionFvPatchScalarField.C:58
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::nutWallFunctionFvPatchScalarField::checkType
virtual void checkType()
Check the type of the patch.
Definition: nutWallFunctionFvPatchScalarField.C:44