turbulentMixingLengthFrequencyInletFvPatchScalarField.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  mixingLength_(0.0),
52  kName_("undefined-k")
53 {
54  this->refValue() = 0.0;
55  this->refGrad() = 0.0;
56  this->valueFraction() = 0.0;
57 }
58 
61 (
63  const fvPatch& p,
65  const fvPatchFieldMapper& mapper
66 )
67 :
68  inletOutletFvPatchScalarField(ptf, p, iF, mapper),
69  mixingLength_(ptf.mixingLength_),
70  kName_(ptf.kName_)
71 {}
72 
75 (
76  const fvPatch& p,
78  const dictionary& dict
79 )
80 :
81  inletOutletFvPatchScalarField(p, iF),
82  mixingLength_(dict.get<scalar>("mixingLength")),
83  kName_(dict.getOrDefault<word>("k", "k"))
84 {
85  this->phiName_ = dict.getOrDefault<word>("phi", "phi");
86 
88 
89  this->refValue() = 0.0;
90  this->refGrad() = 0.0;
91  this->valueFraction() = 0.0;
92 }
93 
96 (
98 )
99 :
100  inletOutletFvPatchScalarField(ptf),
101  mixingLength_(ptf.mixingLength_),
102  kName_(ptf.kName_)
103 {}
104 
107 (
110 )
111 :
112  inletOutletFvPatchScalarField(ptf, iF),
113  mixingLength_(ptf.mixingLength_),
114  kName_(ptf.kName_)
115 {}
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
121 {
122  if (updated())
123  {
124  return;
125  }
126 
127  // Lookup Cmu corresponding to the turbulence model selected
128  const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
129  (
131  (
133  internalField().group()
134  )
135  );
136 
137  const scalar Cmu =
138  turbModel.coeffDict().getOrDefault<scalar>("Cmu", 0.09);
139 
140  const scalar Cmu25 = pow(Cmu, 0.25);
141 
142  const fvPatchScalarField& kp =
143  patch().lookupPatchField<volScalarField, scalar>(kName_);
144 
145  const fvsPatchScalarField& phip =
146  patch().lookupPatchField<surfaceScalarField, scalar>(this->phiName_);
147 
148  this->refValue() = sqrt(kp)/(Cmu25*mixingLength_);
149  this->valueFraction() = 1.0 - pos0(phip);
150 
151  inletOutletFvPatchScalarField::updateCoeffs();
152 }
153 
154 
156 (
157  Ostream& os
158 ) const
159 {
161  os.writeEntry("mixingLength", mixingLength_);
162  os.writeEntry("phi", this->phiName_);
163  os.writeEntry("k", kName_);
164  writeEntry("value", os);
165 }
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
171 (
174 );
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 } // End namespace Foam
180 
181 // ************************************************************************* //
Foam::turbulentMixingLengthFrequencyInletFvPatchScalarField::write
virtual void write(Ostream &) const
Write.
Definition: turbulentMixingLengthFrequencyInletFvPatchScalarField.C:156
Foam::fvPatchField< scalar >
volFields.H
Foam::fvPatchField< scalar >::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:364
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::constant::atomic::group
constexpr const char *const group
Group name for atomic constants.
Definition: atomicConstants.H:52
Foam::turbulentMixingLengthFrequencyInletFvPatchScalarField::turbulentMixingLengthFrequencyInletFvPatchScalarField
turbulentMixingLengthFrequencyInletFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: turbulentMixingLengthFrequencyInletFvPatchScalarField.C:45
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
Foam::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:100
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
Foam::pos0
dimensionedScalar pos0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:188
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
Foam::turbulentMixingLengthFrequencyInletFvPatchScalarField
This boundary condition provides a turbulence specific dissipation, (omega) inlet condition based on...
Definition: turbulentMixingLengthFrequencyInletFvPatchScalarField.H:129
Foam::turbulenceModel::coeffDict
virtual const dictionary & coeffDict() const =0
Const access to the coefficients dictionary.
turbulentMixingLengthFrequencyInletFvPatchScalarField.H
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::turbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: turbulenceModel.H:63
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
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:54
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
Foam::turbulentMixingLengthFrequencyInletFvPatchScalarField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: turbulentMixingLengthFrequencyInletFvPatchScalarField.C:120
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:232
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::IOobject::groupName
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
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:122
Foam::fvPatchField< scalar >::operator=
virtual void operator=(const UList< scalar > &)
Definition: fvPatchField.C:379
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:54