OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

turbulentIntensityKineticEnergyInletFvPatchScalarField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2006-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "turbulentIntensityKineticEnergyInletFvPatchScalarField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "surfaceFields.H"
00031 #include "volFields.H"
00032 
00033 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00034 
00035 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
00036 turbulentIntensityKineticEnergyInletFvPatchScalarField
00037 (
00038     const fvPatch& p,
00039     const DimensionedField<scalar, volMesh>& iF
00040 )
00041 :
00042     fixedValueFvPatchField<scalar>(p, iF),
00043     intensity_(0.05)
00044 {}
00045 
00046 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
00047 turbulentIntensityKineticEnergyInletFvPatchScalarField
00048 (
00049     const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf,
00050     const fvPatch& p,
00051     const DimensionedField<scalar, volMesh>& iF,
00052     const fvPatchFieldMapper& mapper
00053 )
00054 :
00055     fixedValueFvPatchField<scalar>(ptf, p, iF, mapper),
00056     intensity_(ptf.intensity_)
00057 {}
00058 
00059 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
00060 turbulentIntensityKineticEnergyInletFvPatchScalarField
00061 (
00062     const fvPatch& p,
00063     const DimensionedField<scalar, volMesh>& iF,
00064     const dictionary& dict
00065 )
00066 :
00067     fixedValueFvPatchField<scalar>(p, iF, dict),
00068     intensity_(readScalar(dict.lookup("intensity")))
00069 {
00070     if (intensity_ < 0 || intensity_ > 1)
00071     {
00072         FatalErrorIn
00073         (
00074             "turbulentIntensityKineticEnergyInletFvPatchScalarField::"
00075             "turbulentIntensityKineticEnergyInletFvPatchScalarField"
00076             "(const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, "
00077             "const dictionary& dict)"
00078         )   << "Turbulence intensity should be specified as a fraction 0-1 "
00079                "of the mean velocity\n"
00080                "    value given is " << intensity_
00081             << "\n    on patch " << this->patch().name()
00082             << " of field " << this->dimensionedInternalField().name()
00083             << " in file " << this->dimensionedInternalField().objectPath()
00084             << exit(FatalError);
00085     }
00086 }
00087 
00088 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
00089 turbulentIntensityKineticEnergyInletFvPatchScalarField
00090 (
00091     const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf
00092 )
00093 :
00094     fixedValueFvPatchField<scalar>(ptf),
00095     intensity_(ptf.intensity_)
00096 {}
00097 
00098 
00099 Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
00100 turbulentIntensityKineticEnergyInletFvPatchScalarField
00101 (
00102     const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf,
00103     const DimensionedField<scalar, volMesh>& iF
00104 )
00105 :
00106     fixedValueFvPatchField<scalar>(ptf, iF),
00107     intensity_(ptf.intensity_)
00108 {}
00109 
00110 
00111 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00112 
00113 void Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::
00114 updateCoeffs()
00115 {
00116     if (updated())
00117     {
00118         return;
00119     }
00120 
00121     const fvPatchField<vector>& Up =
00122         patch().lookupPatchField<volVectorField, vector>("U");
00123 
00124     operator==(1.5*sqr(intensity_)*magSqr(Up));
00125 
00126     fixedValueFvPatchField<scalar>::updateCoeffs();
00127 }
00128 
00129 
00130 void Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::write
00131 (
00132     Ostream& os
00133 ) const
00134 {
00135     fvPatchField<scalar>::write(os);
00136     os.writeKeyword("intensity") << intensity_ << token::END_STATEMENT << nl;
00137     writeEntry("value", os);
00138 }
00139 
00140 
00141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00142 
00143 namespace Foam
00144 {
00145     makePatchTypeField
00146     (
00147         fvPatchScalarField,
00148         turbulentIntensityKineticEnergyInletFvPatchScalarField
00149     );
00150 }
00151 
00152 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd