nutkFilmWallFunctionFvPatchScalarField.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
33 #include "surfaceFilmRegionModel.H"
34 #include "mappedWallPolyPatch.H"
35 #include "mapDistribute.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 namespace compressible
42 {
43 namespace RASModels
44 {
45 
46 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
47 
49 (
50  const scalarField& magGradU
51 ) const
52 {
53  tmp<scalarField> tuTau(new scalarField(patch().size(), Zero));
54  scalarField& uTau = tuTau.ref();
55 
56  const auto* filmModelPtr = db().time().findObject
58  (filmRegionName_);
59 
60  if (!filmModelPtr)
61  {
62  // Do nothing on construction - film model doesn't exist yet
63  return tuTau;
64  }
65 
66  const label patchi = patch().index();
67 
68  // Retrieve phase change mass from surface film model
69  const auto& filmModel = *filmModelPtr;
70 
71  const label filmPatchi = filmModel.regionPatchID(patchi);
72 
73  tmp<volScalarField> mDotFilm(filmModel.primaryMassTrans());
74  scalarField mDotFilmp = mDotFilm().boundaryField()[filmPatchi];
75  filmModel.toPrimary(filmPatchi, mDotFilmp);
76 
77 
78  // Retrieve RAS turbulence model
79  const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
80  (
82  (
84  internalField().group()
85  )
86  );
87 
88  const scalarField& y = turbModel.y()[patchi];
89  const tmp<volScalarField> tk = turbModel.k();
90  const volScalarField& k = tk();
91  const tmp<scalarField> tnuw = turbModel.nu(patchi);
92  const scalarField& nuw = tnuw();
93 
94  const scalar Cmu25 = pow(Cmu_, 0.25);
95 
96  forAll(uTau, facei)
97  {
98  label faceCelli = patch().faceCells()[facei];
99 
100  scalar ut = Cmu25*sqrt(k[faceCelli]);
101 
102  scalar yPlus = y[facei]*ut/nuw[facei];
103 
104  scalar mStar = mDotFilmp[facei]/(y[facei]*ut);
105 
106  scalar factor = 0.0;
107  if (yPlus > yPlusCrit_)
108  {
109  scalar expTerm = exp(min(50.0, B_*mStar));
110  scalar powTerm = pow(yPlus, mStar/kappa_);
111  factor = mStar/(expTerm*powTerm - 1.0 + ROOTVSMALL);
112  }
113  else
114  {
115  scalar expTerm = exp(min(50.0, mStar));
116  factor = mStar/(expTerm*yPlus - 1.0 + ROOTVSMALL);
117  }
118 
119  uTau[facei] = sqrt(max(0, magGradU[facei]*ut*factor));
120  }
121 
122  return tuTau;
123 }
124 
125 
127 {
128  const label patchi = patch().index();
129 
130  const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
131  (
133  (
135  internalField().group()
136  )
137  );
138 
139  const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi];
140  const scalarField magGradU(mag(Uw.snGrad()));
141  const tmp<scalarField> tnuw = turbModel.nu(patchi);
142  const scalarField& nuw = tnuw();
143 
144  return max
145  (
146  scalar(0),
147  sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - nuw
148  );
149 }
150 
151 
152 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
153 
155 (
156  const fvPatch& p,
158 )
159 :
161  filmRegionName_("surfaceFilmProperties"),
162  B_(5.5),
163  yPlusCrit_(11.05)
164 {}
165 
166 
168 (
170  const fvPatch& p,
172  const fvPatchFieldMapper& mapper
173 )
174 :
175  nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
176  filmRegionName_(ptf.filmRegionName_),
177  B_(5.5),
178  yPlusCrit_(11.05)
179 {}
180 
181 
183 (
184  const fvPatch& p,
186  const dictionary& dict
187 )
188 :
190  filmRegionName_
191  (
192  dict.lookupOrDefault<word>("filmRegion", "surfaceFilmProperties")
193  ),
194  B_(dict.lookupOrDefault("B", 5.5)),
195  yPlusCrit_(dict.lookupOrDefault("yPlusCrit", 11.05))
196 {}
197 
198 
200 (
202 )
203 :
205  filmRegionName_(wfpsf.filmRegionName_),
206  B_(wfpsf.B_),
207  yPlusCrit_(wfpsf.yPlusCrit_)
208 {}
209 
210 
212 (
215 )
216 :
218  filmRegionName_(wfpsf.filmRegionName_),
219  B_(wfpsf.B_),
220  yPlusCrit_(wfpsf.yPlusCrit_)
221 {}
222 
223 
224 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
225 
227 {
228  const label patchi = patch().index();
229 
230  const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
231  (
233  (
235  internalField().group()
236  )
237  );
238 
239  const scalarField& y = turbModel.y()[patchi];
240  const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi];
241  const tmp<scalarField> tnuw = turbModel.nu(patchi);
242  const scalarField& nuw = tnuw();
243 
244  return y*calcUTau(mag(Uw.snGrad()))/nuw;
245 }
246 
247 
249 {
252  (
253  "filmRegion",
254  "surfaceFilmProperties",
256  );
257  writeLocalEntries(os);
258  os.writeEntry("B", B_);
259  os.writeEntry("yPlusCrit", yPlusCrit_);
260  writeEntry("value", os);
261 }
262 
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 } // End namespace RASModels
271 } // End namespace compressible
272 } // End namespace Foam
273 
274 // ************************************************************************* //
Foam::fvPatchField< vector >
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:364
Foam::fvPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: fvPatchField.C:217
Foam::Ostream::writeEntryIfDifferent
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Definition: Ostream.H:231
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
p
volScalarField & p
Definition: createFieldRefs.H:8
mappedWallPolyPatch.H
Foam::compressible::RASModels::nutkFilmWallFunctionFvPatchScalarField::write
virtual void write(Ostream &os) const
Write.
Definition: nutkFilmWallFunctionFvPatchScalarField.C:248
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::compressible::RASModels::nutkFilmWallFunctionFvPatchScalarField::yPlusCrit_
scalar yPlusCrit_
y+ value for laminar -> turbulent transition (default = 11.05)
Definition: nutkFilmWallFunctionFvPatchScalarField.H:87
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::compressible::RASModels::nutkFilmWallFunctionFvPatchScalarField::yPlus
virtual tmp< scalarField > yPlus() const
Calculate and return the yPlus at the boundary.
Definition: nutkFilmWallFunctionFvPatchScalarField.C:226
Foam::compressible::RASModels::nutkFilmWallFunctionFvPatchScalarField::calcNut
virtual tmp< scalarField > calcNut() const
Calculate the turbulence viscosity.
Definition: nutkFilmWallFunctionFvPatchScalarField.C:126
Foam::compressible::RASModels::nutkFilmWallFunctionFvPatchScalarField::B_
scalar B_
B Coefficient (default = 5.5)
Definition: nutkFilmWallFunctionFvPatchScalarField.H:84
Foam::compressible::RASModels::makePatchTypeField
makePatchTypeField(fvPatchScalarField, alphatFilmWallFunctionFvPatchScalarField)
Foam::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:100
Foam::constant::atomic::group
const char *const group
Group name for atomic constants.
Definition: atomicConstants.C:41
Foam::compressible::RASModels::nutkFilmWallFunctionFvPatchScalarField::nutkFilmWallFunctionFvPatchScalarField
nutkFilmWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: nutkFilmWallFunctionFvPatchScalarField.C:155
fvPatchFieldMapper.H
Foam::exp
dimensionedScalar exp(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:261
surfaceFilmRegionModel.H
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
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:62
Foam::Field< scalar >
Foam::regionModels::surfaceFilmModels::surfaceFilmRegionModel
Base class for surface film models.
Definition: surfaceFilmRegionModel.H:55
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
uTau
scalar uTau
Definition: evaluateNearWall.H:14
compressible
bool compressible
Definition: pEqn.H:3
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::compressible::RASModels::nutkFilmWallFunctionFvPatchScalarField::calcUTau
virtual tmp< scalarField > calcUTau(const scalarField &magGradU) const
Calculate the friction velocity.
Definition: nutkFilmWallFunctionFvPatchScalarField.C:49
Foam::compressible::RASModels::nutkFilmWallFunctionFvPatchScalarField::filmRegionName_
word filmRegionName_
Name of film region.
Definition: nutkFilmWallFunctionFvPatchScalarField.H:81
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
nutkFilmWallFunctionFvPatchScalarField.H
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
mapDistribute.H
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::ThermalDiffusivity
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
Definition: phaseCompressibleTurbulenceModelFwd.H:47
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
Foam::IOobject::groupName
static word groupName(StringType name, const word &group)
Create dot-delimited name.group.
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::compressible::RASModels::nutkFilmWallFunctionFvPatchScalarField
This boundary condition provides a turbulent viscosity condition when using wall functions,...
Definition: nutkFilmWallFunctionFvPatchScalarField.H:72
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
yPlus
scalar yPlus
Definition: evaluateNearWall.H:16
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GeometricField< scalar, fvPatchField, volMesh >
turbulentFluidThermoModel.H
Foam::nutWallFunctionFvPatchScalarField::writeLocalEntries
virtual void writeLocalEntries(Ostream &) const
Write local wall function variables.
Definition: nutWallFunctionFvPatchScalarField.C:76
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::nutkWallFunctionFvPatchScalarField
This boundary condition provides a wall constraint on the turbulent kinematic viscosity,...
Definition: nutkWallFunctionFvPatchScalarField.H:98