nutkRoughWallFunctionFvPatchScalarField.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 "turbulenceModel.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
38 
40 (
41  const scalar KsPlus,
42  const scalar Cs
43 ) const
44 {
45  // Return fn based on non-dimensional roughness height
46 
47  if (KsPlus < 90.0)
48  {
49  return pow
50  (
51  (KsPlus - 2.25)/87.75 + Cs*KsPlus,
52  sin(0.4258*(log(KsPlus) - 0.811))
53  );
54  }
55  else
56  {
57  return (1.0 + Cs*KsPlus);
58  }
59 }
60 
61 
63 {
64  const label patchi = patch().index();
65 
66  const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
67  (
69  (
72  )
73  );
74  const scalarField& y = turbModel.y()[patchi];
75  const tmp<volScalarField> tk = turbModel.k();
76  const volScalarField& k = tk();
77  const tmp<scalarField> tnuw = turbModel.nu(patchi);
78  const scalarField& nuw = tnuw();
79 
80  const scalar Cmu25 = pow025(Cmu_);
81 
82  tmp<scalarField> tnutw(new scalarField(*this));
83  scalarField& nutw = tnutw();
84 
85  forAll(nutw, faceI)
86  {
87  label faceCellI = patch().faceCells()[faceI];
88 
89  scalar uStar = Cmu25*sqrt(k[faceCellI]);
90  scalar yPlus = uStar*y[faceI]/nuw[faceI];
91  scalar KsPlus = uStar*Ks_[faceI]/nuw[faceI];
92 
93  scalar Edash = E_;
94  if (KsPlus > 2.25)
95  {
96  Edash /= fnRough(KsPlus, Cs_[faceI]);
97  }
98 
99  scalar limitingNutw = max(nutw[faceI], nuw[faceI]);
100 
101  // To avoid oscillations limit the change in the wall viscosity
102  // which is particularly important if it temporarily becomes zero
103  nutw[faceI] =
104  max
105  (
106  min
107  (
108  nuw[faceI]
109  *(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1),
110  2*limitingNutw
111  ), 0.5*limitingNutw
112  );
113 
114  if (debug)
115  {
116  Info<< "yPlus = " << yPlus
117  << ", KsPlus = " << KsPlus
118  << ", Edash = " << Edash
119  << ", nutw = " << nutw[faceI]
120  << endl;
121  }
122  }
123 
124  return tnutw;
125 }
126 
127 
128 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
129 
131 (
132  const fvPatch& p,
134 )
135 :
137  Ks_(p.size(), 0.0),
138  Cs_(p.size(), 0.0)
139 {}
140 
141 
143 (
145  const fvPatch& p,
147  const fvPatchFieldMapper& mapper
148 )
149 :
150  nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
151  Ks_(ptf.Ks_, mapper),
152  Cs_(ptf.Cs_, mapper)
153 {}
154 
155 
157 (
158  const fvPatch& p,
160  const dictionary& dict
161 )
162 :
164  Ks_("Ks", dict, p.size()),
165  Cs_("Cs", dict, p.size())
166 {}
167 
168 
170 (
172 )
173 :
175  Ks_(rwfpsf.Ks_),
176  Cs_(rwfpsf.Cs_)
177 {}
178 
179 
181 (
184 )
185 :
187  Ks_(rwfpsf.Ks_),
188  Cs_(rwfpsf.Cs_)
189 {}
190 
191 
192 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
193 
195 (
196  const fvPatchFieldMapper& m
197 )
198 {
199  nutkWallFunctionFvPatchScalarField::autoMap(m);
200  Ks_.autoMap(m);
201  Cs_.autoMap(m);
202 }
203 
204 
206 (
207  const fvPatchScalarField& ptf,
208  const labelList& addr
209 )
210 {
211  nutkWallFunctionFvPatchScalarField::rmap(ptf, addr);
212 
214  refCast<const nutkRoughWallFunctionFvPatchScalarField>(ptf);
215 
216  Ks_.rmap(nrwfpsf.Ks_, addr);
217  Cs_.rmap(nrwfpsf.Cs_, addr);
218 }
219 
220 
222 {
224  writeLocalEntries(os);
225  Cs_.writeEntry("Cs", os);
226  Ks_.writeEntry("Ks", os);
227  writeEntry("value", os);
228 }
229 
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
234 (
237 );
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 } // End namespace Foam
242 
243 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:48
Foam::turbulenceModel::nu
virtual tmp< volScalarField > nu() const =0
Return the laminar viscosity.
Foam::IOobject::groupName
static word groupName(Name name, const word &group)
Foam::nutkRoughWallFunctionFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: nutkRoughWallFunctionFvPatchScalarField.C:221
p
p
Definition: pEqn.H:62
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:255
dimensionedInternalField
rDeltaT dimensionedInternalField()
Foam::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:97
Foam::constant::atomic::group
const char *const group
Group name for atomic constants.
Definition: atomicConstants.C:40
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
fvPatchFieldMapper.H
Foam::nutkRoughWallFunctionFvPatchScalarField::calcNut
virtual tmp< scalarField > calcNut() const
Calculate the turbulence viscosity.
Definition: nutkRoughWallFunctionFvPatchScalarField.C:62
Foam::turbulenceModel::y
const nearWallDist & y() const
Return the near wall distances.
Definition: turbulenceModel.H:157
Foam::nutkRoughWallFunctionFvPatchScalarField::rmap
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: nutkRoughWallFunctionFvPatchScalarField.C:206
Foam::nutWallFunctionFvPatchScalarField::kappa_
scalar kappa_
Von Karman constant.
Definition: nutWallFunctionFvPatchScalarField.H:113
Foam::pow025
dimensionedScalar pow025(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:131
nutkRoughWallFunctionFvPatchScalarField.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::Info
messageStream Info
Foam::nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField
nutkRoughWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: nutkRoughWallFunctionFvPatchScalarField.C:131
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::nutkRoughWallFunctionFvPatchScalarField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: nutkRoughWallFunctionFvPatchScalarField.C:195
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:73
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::turbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: turbulenceModel.H:60
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::nutkRoughWallFunctionFvPatchScalarField::Ks_
scalarField Ks_
Roughness height.
Definition: nutkRoughWallFunctionFvPatchScalarField.H:103
Foam::nutWallFunctionFvPatchScalarField::Cmu_
scalar Cmu_
Cmu coefficient.
Definition: nutWallFunctionFvPatchScalarField.H:110
Foam::turbulenceModel::k
virtual tmp< volScalarField > k() const =0
Return the turbulence kinetic energy.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::makePatchTypeField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
Foam::Field::writeEntry
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
Definition: Field.C:700
Foam::nutkRoughWallFunctionFvPatchScalarField::fnRough
virtual scalar fnRough(const scalar KsPlus, const scalar Cs) const
Compute the roughness function.
Definition: nutkRoughWallFunctionFvPatchScalarField.C:40
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::nutkRoughWallFunctionFvPatchScalarField
This boundary condition provides a turbulent kinematic viscosity condition when using wall functions ...
Definition: nutkRoughWallFunctionFvPatchScalarField.H:94
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
Foam::yPlus
This function object evaluates and outputs turbulence y+ for turbulence models. The field is stored o...
Definition: yPlus.H:110
patchi
label patchi
Definition: getPatchFieldScalar.H:1
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::nutkRoughWallFunctionFvPatchScalarField::Cs_
scalarField Cs_
Roughness constant.
Definition: nutkRoughWallFunctionFvPatchScalarField.H:106
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::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
turbulenceModel.H
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
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::nutkWallFunctionFvPatchScalarField
This boundary condition provides a turbulent kinematic viscosity condition when using wall functions,...
Definition: nutkWallFunctionFvPatchScalarField.H:66