turbulentIntensityKineticEnergyInletFvPatchScalarField.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-2022 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 "fvPatchFieldMapper.H"
29 #include "surfaceFields.H"
30 #include "volFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const fvPatch& p,
39 )
40 :
41  inletOutletFvPatchScalarField(p, iF),
42  intensity_(0.0),
43  UName_("U")
44 {
45  this->refValue() = 0.0;
46  this->refGrad() = 0.0;
47  this->valueFraction() = 0.0;
48 }
49 
50 
53 (
54  const fvPatch& p,
56  const dictionary& dict
57 )
58 :
59  inletOutletFvPatchScalarField(p, iF),
60  intensity_(dict.lookup<scalar>("intensity")),
61  UName_(dict.lookupOrDefault<word>("U", "U"))
62 {
63  this->phiName_ = dict.lookupOrDefault<word>("phi", "phi");
64 
65  if (intensity_ < 0 || intensity_ > 1)
66  {
68  << "Turbulence intensity should be specified as a fraction 0-1 "
69  "of the mean velocity\n"
70  " value given is " << intensity_ << nl
71  << " on patch " << this->patch().name()
72  << " of field " << this->internalField().name()
73  << " in file " << this->internalField().objectPath()
74  << exit(FatalError);
75  }
76 
77  fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
78 
79  this->refValue() = 0.0;
80  this->refGrad() = 0.0;
81  this->valueFraction() = 0.0;
82 }
83 
84 
87 (
89  const fvPatch& p,
91  const fvPatchFieldMapper& mapper
92 )
93 :
94  inletOutletFvPatchScalarField(ptf, p, iF, mapper),
95  intensity_(ptf.intensity_),
96  UName_(ptf.UName_)
97 {}
98 
99 
102 (
105 )
106 :
107  inletOutletFvPatchScalarField(ptf, iF),
108  intensity_(ptf.intensity_),
109  UName_(ptf.UName_)
110 {}
111 
112 
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 
117 {
118  if (updated())
119  {
120  return;
121  }
122 
123  const fvPatchVectorField& Up =
124  patch().lookupPatchField<volVectorField, vector>(UName_);
125 
126  const fvsPatchScalarField& phip =
127  patch().lookupPatchField<surfaceScalarField, scalar>(this->phiName_);
128 
129  this->refValue() = 1.5*sqr(intensity_)*magSqr(Up);
130  this->valueFraction() = neg(phip);
131 
132  inletOutletFvPatchScalarField::updateCoeffs();
133 }
134 
135 
137 (
138  Ostream& os
139 ) const
140 {
142  writeEntry(os, "intensity", intensity_);
143  writeEntryIfDifferent<word>(os, "U", "U", UName_);
144  writeEntryIfDifferent<word>(os, "phi", "phi", this->phiName_);
145  writeEntry(os, "value", *this);
146 }
147 
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 namespace Foam
152 {
154  (
157  );
158 }
159 
160 // ************************************************************************* //
Foam::surfaceFields.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:243
This boundary condition provides a turbulent kinetic energy condition, based on user-supplied turbule...
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:59
dimensionedScalar neg(const dimensionedScalar &ds)
Macros for easy insertion into run-time selection tables.
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual label size() const
Return size.
Definition: fvPatch.H:157
dimensioned< scalar > magSqr(const dimensioned< Type > &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
volScalarField scalarField(fieldObject, mesh)
static const char nl
Definition: Ostream.H:260
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
turbulentIntensityKineticEnergyInletFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864