turbulentMixingLengthDissipationRateInletFvPatchScalarField.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  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 #include "fvPatchFieldMapper.H"
32 #include "surfaceFields.H"
33 #include "volFields.H"
34 #include "turbulenceModel.H"
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
45 (
46  const fvPatch& p,
48 )
49 :
50  inletOutletFvPatchScalarField(p, iF),
51  kName_("k"),
52  mixingLength_(0.0),
53  Cmu_(0.0)
54 {
55  this->refValue() = 0.0;
56  this->refGrad() = 0.0;
57  this->valueFraction() = 0.0;
58 }
59 
60 
63 (
65  const fvPatch& p,
67  const fvPatchFieldMapper& mapper
68 )
69 :
70  inletOutletFvPatchScalarField(ptf, p, iF, mapper),
71  kName_(ptf.kName_),
72  mixingLength_(ptf.mixingLength_),
73  Cmu_(ptf.Cmu_)
74 {}
75 
76 
79 (
80  const fvPatch& p,
82  const dictionary& dict
83 )
84 :
85  inletOutletFvPatchScalarField(p, iF),
86  kName_(dict.getOrDefault<word>("k", "k")),
87  mixingLength_
88  (
89  dict.getCheck<scalar>("mixingLength", scalarMinMax::ge(SMALL))
90  ),
91  Cmu_(dict.getCheckOrDefault<scalar>("Cmu", 0.09, scalarMinMax::ge(SMALL)))
92 {
93  this->phiName_ = dict.getOrDefault<word>("phi", "phi");
94 
96 
97  this->refValue() = 0.0;
98  this->refGrad() = 0.0;
99  this->valueFraction() = 0.0;
100 }
101 
102 
105 (
107 )
108 :
109  inletOutletFvPatchScalarField(ptf),
110  kName_(ptf.kName_),
111  mixingLength_(ptf.mixingLength_),
112  Cmu_(ptf.Cmu_)
113 {}
114 
115 
118 (
121 )
122 :
123  inletOutletFvPatchScalarField(ptf, iF),
124  kName_(ptf.kName_),
125  mixingLength_(ptf.mixingLength_),
126  Cmu_(ptf.Cmu_)
127 {}
128 
129 
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 
133 {
134  if (updated())
135  {
136  return;
137  }
138 
139  // Lookup Cmu corresponding to the turbulence model selected
140  const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
141  (
143  (
145  internalField().group()
146  )
147  );
148 
149  Cmu_ = turbModel.coeffDict().getOrDefault<scalar>("Cmu", Cmu_);
150 
151  const scalar Cmu75 = pow(Cmu_, 0.75);
152 
153  const fvPatchScalarField& kp =
154  patch().lookupPatchField<volScalarField, scalar>(kName_);
155 
156  const fvsPatchScalarField& phip =
157  patch().lookupPatchField<surfaceScalarField, scalar>(this->phiName_);
158 
159  this->refValue() = (Cmu75/mixingLength_)*pow(kp, 1.5);
160  this->valueFraction() = 1.0 - pos0(phip);
161 
162  inletOutletFvPatchScalarField::updateCoeffs();
163 }
164 
165 
167 (
168  Ostream& os
169 ) const
170 {
172  os.writeEntry("mixingLength", mixingLength_);
173  os.writeEntry("phi", this->phiName_);
174  os.writeEntry("k", kName_);
175  writeEntry("value", os);
176 }
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
182 (
184  turbulentMixingLengthDissipationRateInletFvPatchScalarField
185 );
186 
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 } // End namespace Foam
191 
192 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:47
Foam::fvPatchScalarField
fvPatchField< scalar > fvPatchScalarField
Definition: fvPatchFieldsFwd.H:33
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Definition: fvPatchField.C:377
Foam::fvPatchField::operator=
virtual void operator=(const UList< Type > &)
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:46
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::constant::atomic::group
constexpr const char *const group
Definition: atomicConstants.H:46
Foam::fvsPatchScalarField
fvsPatchField< scalar > fvsPatchScalarField
Definition: fvsPatchFieldsFwd.H:39
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:64
Foam::turbulenceModel::propertiesName
static const word propertiesName
Definition: turbulenceModel.H:96
Foam::turbulentMixingLengthDissipationRateInletFvPatchScalarField::write
virtual void write(Ostream &) const
Definition: turbulentMixingLengthDissipationRateInletFvPatchScalarField.C:160
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
Foam::pos0
dimensionedScalar pos0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:181
Foam::compressible::turbulenceModel
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
Definition: turbulentFluidThermoModel.H:59
Foam::turbulenceModel::coeffDict
virtual const dictionary & coeffDict() const =0
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:53
Foam::dictionary::getCheckOrDefault
T getCheckOrDefault(const word &keyword, const T &deflt, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:202
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:68
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::turbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: turbulenceModel.H:59
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Definition: atmBoundaryLayer.C:26
Foam::turbulentMixingLengthDissipationRateInletFvPatchScalarField
This boundary condition provides an inlet condition for turbulent kinetic energy dissipation rate,...
Definition: turbulentMixingLengthDissipationRateInletFvPatchScalarField.H:155
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:50
Foam::foamVersion::patch
const std::string patch
Foam::MinMax::ge
static MinMax< T > ge(const T &minVal)
Definition: MinMaxI.H:24
Foam::dictionary::getCheck
T getCheck(const word &keyword, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:113
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Definition: Ostream.H:232
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:41
Foam::IOobject::groupName
static word groupName(StringType base, const word &group)
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:141
turbulentMixingLengthDissipationRateInletFvPatchScalarField.H
Foam::MinMax
A min/max value pair with additional methods. In addition to conveniently storing values,...
Definition: HashSet.H:72
turbulenceModel.H
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50
Foam::turbulentMixingLengthDissipationRateInletFvPatchScalarField::turbulentMixingLengthDissipationRateInletFvPatchScalarField
turbulentMixingLengthDissipationRateInletFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Definition: turbulentMixingLengthDissipationRateInletFvPatchScalarField.C:38
Foam::turbulentMixingLengthDissipationRateInletFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Definition: turbulentMixingLengthDissipationRateInletFvPatchScalarField.C:125