1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "turbulentIntensityKineticEnergyInletFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "surfaceFields.H"
31 #include "volFields.H"
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
36 turbulentIntensityKineticEnergyInletFvPatchScalarField
39 const DimensionedField<scalar, volMesh>& iF
42 fixedValueFvPatchField<scalar>(p, iF),
47 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
48 turbulentIntensityKineticEnergyInletFvPatchScalarField
50 const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf,
52 const DimensionedField<scalar, volMesh>& iF,
53 const fvPatchFieldMapper& mapper
56 fixedValueFvPatchField<scalar>(ptf, p, iF, mapper),
58 intensity_(ptf.intensity_)
61 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
62 turbulentIntensityKineticEnergyInletFvPatchScalarField
65 const DimensionedField<scalar, volMesh>& iF,
66 const dictionary& dict
69 fixedValueFvPatchField<scalar>(p, iF, dict),
70 UName_(dict.lookupOrDefault<word>("U", "U")),
71 intensity_(readScalar(dict.lookup("intensity")))
73 if (intensity_ < 0 || intensity_ > 1)
77 "turbulentIntensityKineticEnergyInletFvPatchScalarField::"
78 "turbulentIntensityKineticEnergyInletFvPatchScalarField"
79 "(const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, "
80 "const dictionary& dict)"
81 ) << "Turbulence intensity should be specified as a fraction 0-1 "
82 "of the mean velocity\n"
83 " value given is " << intensity_
84 << "\n on patch " << this->patch().name()
85 << " of field " << this->dimensionedInternalField().name()
86 << " in file " << this->dimensionedInternalField().objectPath()
91 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
92 turbulentIntensityKineticEnergyInletFvPatchScalarField
94 const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf
97 fixedValueFvPatchField<scalar>(ptf),
99 intensity_(ptf.intensity_)
103 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
104 turbulentIntensityKineticEnergyInletFvPatchScalarField
106 const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf,
107 const DimensionedField<scalar, volMesh>& iF
110 fixedValueFvPatchField<scalar>(ptf, iF),
112 intensity_(ptf.intensity_)
116 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
127 const fvPatchField<vector>& Up =
128 patch().lookupPatchField<volVectorField, vector>(UName_);
130 operator==(1.5*sqr(intensity_)*magSqr(Up));
132 fixedValueFvPatchField<scalar>::updateCoeffs();
136 void Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::write
141 fvPatchField<scalar>::write(os);
144 os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
146 os.writeKeyword("intensity") << intensity_ << token::END_STATEMENT << nl;
147 writeEntry("value", os);
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 turbulentIntensityKineticEnergyInletFvPatchScalarField
162 // ************************************************************************* //