kLowReWallFunctionFvPatchScalarField.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) 2012-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 
28 #include "momentumTransportModel.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 (
40  const fvPatch& p,
42  const dictionary& dict
43 )
44 :
45  fixedValueFvPatchScalarField(p, iF, dict),
46  Ceps2_(dict.lookupOrDefault<scalar>("Ceps2", dimless, 1.9))
47 {}
48 
49 
51 (
53  const fvPatch& p,
55  const fieldMapper& mapper
56 )
57 :
58  fixedValueFvPatchScalarField(ptf, p, iF, mapper),
59  Ceps2_(ptf.Ceps2_)
60 {}
61 
62 
64 (
67 )
68 :
69  fixedValueFvPatchScalarField(kwfpsf, iF),
70  Ceps2_(kwfpsf.Ceps2_)
71 {}
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
77 {
78  if (updated())
79  {
80  return;
81  }
82 
83  const label patchi = patch().index();
84 
85  const momentumTransportModel& turbModel =
86  db().lookupType<momentumTransportModel>(internalField().group());
87 
90 
91  const scalarField& y = turbModel.yb()[patchi];
92 
93  const tmp<volScalarField> tk = turbModel.k();
94  const volScalarField& k = tk();
95 
96  const tmp<scalarField> tnuw = turbModel.nu(patchi);
97  const scalarField& nuw = tnuw();
98 
99  const scalar Cmu25 = pow025(nutw.Cmu());
100 
101  scalarField& kw = *this;
102 
103  // Set k wall values
104  forAll(kw, facei)
105  {
106  label celli = patch().faceCells()[facei];
107 
108  scalar uTau = Cmu25*sqrt(k[celli]);
109 
110  scalar yPlus = uTau*y[facei]/nuw[facei];
111 
112  if (yPlus > nutw.yPlusLam())
113  {
114  scalar Ck = -0.416;
115  scalar Bk = 8.366;
116  kw[facei] = Ck/nutw.kappa()*log(yPlus) + Bk;
117  }
118  else
119  {
120  scalar C = 11.0;
121  scalar Cf = (1.0/sqr(yPlus + C) + 2.0*yPlus/pow3(C) - 1.0/sqr(C));
122  kw[facei] = 2400.0/sqr(Ceps2_)*Cf;
123  }
124 
125  kw[facei] *= sqr(uTau);
126  }
127 
128  // Limit kw to avoid failure of the turbulence model due to division by kw
129  kw = max(kw, small);
130 
131  fixedValueFvPatchScalarField::updateCoeffs();
132 
133  // TODO: perform averaging for cells sharing more than one boundary face
134 }
135 
136 
138 {
139  writeEntry(os, "Ceps2", Ceps2_);
141 }
142 
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
147 (
150 );
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Foam
155 
156 // ************************************************************************* //
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.
Graphite solid properties.
Definition: C.H:51
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
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
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
This boundary condition provides a turbulence kinetic energy wall function condition for low- and hig...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
kLowReWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
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 condition when using wall functions,...
static const nutWallFunctionFvPatchScalarField & nutw(const momentumTransportModel &turbModel, const label patchi)
Return the nut patchField for the given wall patch.
A class for managing temporary objects.
Definition: tmp.H:55
const scalar yPlus
const scalar uTau
label patchi
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
const dimensionSet & dimless
Definition: dimensions.C:138
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
void pow025(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
makePatchTypeField(fvPatchScalarField, atmosphericBoundaryLayerTurbulentEpsilonFvPatchScalarField)
dimensionedScalar log(const dimensionedScalar &ds)
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void pow3(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
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