nutAtmosphericBoundaryLayerWallFunctionFvPatchScalarField.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-2026 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 "momentumTransportModel.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
37 
38 tmp<scalarField>
40 {
41  const label patchi = patch().index();
42 
43  const momentumTransportModel& turbModel =
44  db().lookupType<momentumTransportModel>(internalField().group());
45 
46  const scalarField& y = turbModel.yb()[patchi];
47  const tmp<volScalarField> tk = turbModel.k();
48  const volScalarField& k = tk();
49  const tmp<scalarField> tnuw = turbModel.nu(patchi);
50  const scalarField& nuw = tnuw();
51 
52  const atmosphericBoundaryLayer& abl =
53  atmosphericBoundaryLayer::New(patch().db());
54 
55  const scalar Cmu25 = pow025(abl.Cmu());
56  const scalar kappa = abl.kappa();
57 
58  const scalarField z0(abl.z0(patch().Cf()));
59 
60  tmp<scalarField> tnutw(new scalarField(*this));
61  scalarField& nutw = tnutw.ref();
62 
63  forAll(nutw, facei)
64  {
65  label celli = patch().faceCells()[facei];
66 
67  scalar uStar = Cmu25*sqrt(k[celli]);
68  scalar yPlus = uStar*y[facei]/nuw[facei];
69 
70  scalar Edash = (y[facei] + z0[facei])/z0[facei];
71 
72  nutw[facei] =
73  nuw[facei]*(yPlus*kappa/log(max(Edash, 1+1e-4)) - 1);
74 
75  if (debug)
76  {
77  Info<< "yPlus = " << yPlus
78  << ", Edash = " << Edash
79  << ", nutw = " << nutw[facei]
80  << endl;
81  }
82  }
83 
84  return tnutw;
85 }
86 
87 
88 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
89 
92 (
93  const fvPatch& p,
95  const dictionary& dict
96 )
97 :
99 {}
100 
101 
104 (
106  const fvPatch& p,
108  const fieldMapper& mapper
109 )
110 :
111  nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
112 {}
113 
114 
117 (
120 )
121 :
123 {}
124 
125 
126 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
127 
129 (
130  Ostream& os
131 ) const
132 {
134  writeLocalEntries(os);
135  writeEntry(os, "value", *this);
136 }
137 
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
142 (
145 );
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Foam
151 
152 // ************************************************************************* //
scalar y
label k
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
This class provides functions to evaluate the velocity and turbulence distributions appropriate for a...
tmp< scalarField > z0(const vectorField &C) const
Return surface roughness height.
scalar kappa() const
Von Karman constant.
static const atmosphericBoundaryLayer & New(const objectRegistry &db)
Return a reference to the atmosphericBoundaryLayer.
scalar Cmu() const
Turbulent viscosity coefficient.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:90
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:235
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
Abstract base class for momentum transport models (RAS, LES and laminar).
const volScalarField::Boundary & yb() const
Return the near wall distance.
virtual tmp< volScalarField > k() const =0
Return the turbulence kinetic energy.
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
This boundary condition provides a turbulent kinematic viscosity for atmospheric velocity profiles....
nutAtmosphericBoundaryLayerWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void writeLocalEntries(Ostream &) const
Write local wall function variables.
static const nutWallFunctionFvPatchScalarField & nutw(const momentumTransportModel &turbModel, const label patchi)
Return the nut patchField for the given wall patch.
Turbulent viscosity wall-function boundary condition for high Reynolds number flows based on near-wal...
virtual tmp< scalarField > yPlus() const
Calculate and return the yPlus at the boundary.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
label patchi
Namespace for OpenFOAM.
const doubleScalar e
Definition: doubleScalar.H:106
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
void pow025(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
makePatchTypeField(fvPatchScalarField, atmosphericBoundaryLayerTurbulentEpsilonFvPatchScalarField)
messageStream Info
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar log(const dimensionedScalar &ds)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dictionary dict
volScalarField & p