Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / derived / turbulentIntensityKineticEnergyInlet / turbulentIntensityKineticEnergyInletFvPatchScalarField.C
blobe84c58a5d650805fc80ba31060814f6d0983f9e9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
38     const fvPatch& p,
39     const DimensionedField<scalar, volMesh>& iF
42     fixedValueFvPatchField<scalar>(p, iF),
43     UName_("U"),
44     intensity_(0.05)
47 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
48 turbulentIntensityKineticEnergyInletFvPatchScalarField
50     const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf,
51     const fvPatch& p,
52     const DimensionedField<scalar, volMesh>& iF,
53     const fvPatchFieldMapper& mapper
56     fixedValueFvPatchField<scalar>(ptf, p, iF, mapper),
57     UName_(ptf.UName_),
58     intensity_(ptf.intensity_)
61 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
62 turbulentIntensityKineticEnergyInletFvPatchScalarField
64     const fvPatch& p,
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)
74     {
75         FatalErrorIn
76         (
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()
87             << exit(FatalError);
88     }
91 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
92 turbulentIntensityKineticEnergyInletFvPatchScalarField
94     const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf
97     fixedValueFvPatchField<scalar>(ptf),
98     UName_(ptf.UName_),
99     intensity_(ptf.intensity_)
103 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
104 turbulentIntensityKineticEnergyInletFvPatchScalarField
106     const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf,
107     const DimensionedField<scalar, volMesh>& iF
110     fixedValueFvPatchField<scalar>(ptf, iF),
111     UName_(ptf.UName_),
112     intensity_(ptf.intensity_)
116 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
118 void
119 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
120 updateCoeffs()
122     if (updated())
123     {
124         return;
125     }
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
138     Ostream& os
139 ) const
141     fvPatchField<scalar>::write(os);
142     if (UName_ != "U")
143     {
144         os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
145     }
146     os.writeKeyword("intensity") << intensity_ << token::END_STATEMENT << nl;
147     writeEntry("value", os);
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 namespace Foam
155     makePatchTypeField
156     (
157         fvPatchScalarField,
158         turbulentIntensityKineticEnergyInletFvPatchScalarField
159     );
162 // ************************************************************************* //