FreeFOAM The Cross-Platform CFD Toolkit
turbulentIntensityKineticEnergyInletFvPatchScalarField.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 | Copyright (C) 2006-2010 OpenCFD Ltd.
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 
30 #include <finiteVolume/volFields.H>
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const fvPatch& p,
39 )
40 :
41  inletOutletFvPatchScalarField(p, iF),
42  intensity_(0.0),
43  UName_("undefined-U"),
44  phiName_("undefined-phi")
45 {
46  this->refValue() = 0.0;
47  this->refGrad() = 0.0;
48  this->valueFraction() = 0.0;
49 }
50 
53 (
55  const fvPatch& p,
57  const fvPatchFieldMapper& mapper
58 )
59 :
60  inletOutletFvPatchScalarField(ptf, p, iF, mapper),
61  intensity_(ptf.intensity_),
62  UName_(ptf.UName_),
63  phiName_(ptf.phiName_)
64 {}
65 
68 (
69  const fvPatch& p,
71  const dictionary& dict
72 )
73 :
74  inletOutletFvPatchScalarField(p, iF),
75  intensity_(readScalar(dict.lookup("intensity"))),
76  UName_(dict.lookupOrDefault<word>("U", "U")),
77  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
78 {
79  if (intensity_ < 0 || intensity_ > 1)
80  {
82  (
83  "turbulentIntensityKineticEnergyInletFvPatchScalarField::"
84  "turbulentIntensityKineticEnergyInletFvPatchScalarField"
85  "(const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, "
86  "const dictionary& dict)"
87  ) << "Turbulence intensity should be specified as a fraction 0-1 "
88  "of the mean velocity\n"
89  " value given is " << intensity_
90  << "\n on patch " << this->patch().name()
91  << " of field " << this->dimensionedInternalField().name()
92  << " in file " << this->dimensionedInternalField().objectPath()
93  << exit(FatalError);
94  }
95 
96  fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
97 
98  this->refValue() = 0.0;
99  this->refGrad() = 0.0;
100  this->valueFraction() = 0.0;
101 }
102 
105 (
107 )
108 :
109  inletOutletFvPatchScalarField(ptf),
110  intensity_(ptf.intensity_),
111  UName_(ptf.UName_),
112  phiName_(ptf.phiName_)
113 {}
114 
115 
118 (
121 )
122 :
123  inletOutletFvPatchScalarField(ptf, iF),
124  intensity_(ptf.intensity_),
125  UName_(ptf.UName_),
126  phiName_(ptf.phiName_)
127 {}
128 
129 
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 
134 {
135  if (updated())
136  {
137  return;
138  }
139 
140  const fvPatchVectorField& Up =
141  patch().lookupPatchField<volVectorField, vector>(UName_);
142 
143  const fvsPatchScalarField& phip =
144  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
145 
146  this->refValue() = 1.5*sqr(intensity_)*magSqr(Up);
147  this->valueFraction() = 1.0 - pos(phip);
148 
150 }
151 
152 
154 (
155  Ostream& os
156 ) const
157 {
159  os.writeKeyword("intensity") << intensity_ << token::END_STATEMENT << nl;
160  os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
161  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
162  writeEntry("value", os);
163 }
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 namespace Foam
169 {
171  (
174  );
175 }
176 
177 // ************************ vim: set sw=4 sts=4 et: ************************ //