nutkAtmRoughWallFunctionFvPatchScalarField.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 label patchi = patch().index();
42 
43  const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
44  (
46  (
49  )
50  );
51  const scalarField& y = turbModel.y()[patchi];
52  const tmp<volScalarField> tk = turbModel.k();
53  const volScalarField& k = tk();
54  const tmp<scalarField> tnuw = turbModel.nu(patchi);
55  const scalarField& nuw = tnuw();
56 
57  const scalar Cmu25 = pow025(Cmu_);
58 
59  tmp<scalarField> tnutw(new scalarField(*this));
60  scalarField& nutw = tnutw();
61 
62  forAll(nutw, faceI)
63  {
64  label faceCellI = patch().faceCells()[faceI];
65 
66  scalar uStar = Cmu25*sqrt(k[faceCellI]);
67  scalar yPlus = uStar*y[faceI]/nuw[faceI];
68 
69  scalar Edash = (y[faceI] + z0_[faceI])/z0_[faceI];
70 
71  nutw[faceI] =
72  nuw[faceI]*(yPlus*kappa_/log(max(Edash, 1+1e-4)) - 1);
73 
74  if (debug)
75  {
76  Info<< "yPlus = " << yPlus
77  << ", Edash = " << Edash
78  << ", nutw = " << nutw[faceI]
79  << endl;
80  }
81  }
82 
83  return tnutw;
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
88 
91 (
92  const fvPatch& p,
94 )
95 :
97  z0_(p.size(), 0.0)
98 {}
99 
100 
103 (
105  const fvPatch& p,
107  const fvPatchFieldMapper& mapper
108 )
109 :
110  nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
111  z0_(ptf.z0_, mapper)
112 {}
113 
114 
117 (
118  const fvPatch& p,
120  const dictionary& dict
121 )
122 :
124  z0_("z0", dict, p.size())
125 {}
126 
127 
130 (
132 )
133 :
135  z0_(rwfpsf.z0_)
136 {}
137 
138 
141 (
144 )
145 :
147  z0_(rwfpsf.z0_)
148 {}
149 
150 
151 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152 
154 (
155  const fvPatchFieldMapper& m
156 )
157 {
158  nutkWallFunctionFvPatchScalarField::autoMap(m);
159  z0_.autoMap(m);
160 }
161 
162 
164 (
165  const fvPatchScalarField& ptf,
166  const labelList& addr
167 )
168 {
169  nutkWallFunctionFvPatchScalarField::rmap(ptf, addr);
170 
172  refCast<const nutkAtmRoughWallFunctionFvPatchScalarField>(ptf);
173 
174  z0_.rmap(nrwfpsf.z0_, addr);
175 }
176 
177 
179 {
181  writeLocalEntries(os);
182  z0_.writeEntry("z0", os);
183  writeEntry("value", os);
184 }
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
190 (
193 );
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace Foam
198 
199 // ************************************************************************* //
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::nutkAtmRoughWallFunctionFvPatchScalarField::calcNut
virtual tmp< scalarField > calcNut() const
Calculate the turbulence viscosity.
Definition: nutkAtmRoughWallFunctionFvPatchScalarField.C:39
p
p
Definition: pEqn.H:62
nutkAtmRoughWallFunctionFvPatchScalarField.H
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
dimensionedInternalField
rDeltaT dimensionedInternalField()
Foam::nutkAtmRoughWallFunctionFvPatchScalarField::nutkAtmRoughWallFunctionFvPatchScalarField
nutkAtmRoughWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: nutkAtmRoughWallFunctionFvPatchScalarField.C:91
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::turbulenceModel::y
const nearWallDist & y() const
Return the near wall distances.
Definition: turbulenceModel.H:157
Foam::nutWallFunctionFvPatchScalarField::kappa_
scalar kappa_
Von Karman constant.
Definition: nutWallFunctionFvPatchScalarField.H:113
Foam::pow025
dimensionedScalar pow025(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:131
Foam::nutkAtmRoughWallFunctionFvPatchScalarField
This boundary condition provides a turbulent kinematic viscosity for atmospheric velocity profiles....
Definition: nutkAtmRoughWallFunctionFvPatchScalarField.H:112
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::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::nutkAtmRoughWallFunctionFvPatchScalarField::rmap
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: nutkAtmRoughWallFunctionFvPatchScalarField.C:164
Foam::nutkAtmRoughWallFunctionFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: nutkAtmRoughWallFunctionFvPatchScalarField.C:178
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::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::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::nutkAtmRoughWallFunctionFvPatchScalarField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: nutkAtmRoughWallFunctionFvPatchScalarField.C:154
Foam::Field::writeEntry
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
Definition: Field.C:700
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
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::nutkAtmRoughWallFunctionFvPatchScalarField::z0_
scalarField z0_
Surface roughness length.
Definition: nutkAtmRoughWallFunctionFvPatchScalarField.H:121
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
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