FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

inletOutletTotalTemperatureFvPatchScalarField.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) 1991-2011 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "inletOutletTotalTemperatureFvPatchScalarField.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/fvPatchFieldMapper.H>
00029 #include <finiteVolume/volFields.H>
00030 #include <finiteVolume/surfaceFields.H>
00031 
00032 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00033 
00034 Foam::inletOutletTotalTemperatureFvPatchScalarField::
00035 inletOutletTotalTemperatureFvPatchScalarField
00036 (
00037     const fvPatch& p,
00038     const DimensionedField<scalar, volMesh>& iF
00039 )
00040 :
00041     inletOutletFvPatchScalarField(p, iF),
00042     UName_("U"),
00043     phiName_("phi"),
00044     psiName_("psi"),
00045     gamma_(0.0),
00046     T0_(p.size(), 0.0)
00047 {}
00048 
00049 
00050 Foam::inletOutletTotalTemperatureFvPatchScalarField::
00051 inletOutletTotalTemperatureFvPatchScalarField
00052 (
00053     const inletOutletTotalTemperatureFvPatchScalarField& ptf,
00054     const fvPatch& p,
00055     const DimensionedField<scalar, volMesh>& iF,
00056     const fvPatchFieldMapper& mapper
00057 )
00058 :
00059     inletOutletFvPatchScalarField(ptf, p, iF, mapper),
00060     UName_(ptf.UName_),
00061     phiName_(ptf.phiName_),
00062     psiName_(ptf.psiName_),
00063     gamma_(ptf.gamma_),
00064     T0_(ptf.T0_, mapper)
00065 {}
00066 
00067 
00068 Foam::inletOutletTotalTemperatureFvPatchScalarField::
00069 inletOutletTotalTemperatureFvPatchScalarField
00070 (
00071     const fvPatch& p,
00072     const DimensionedField<scalar, volMesh>& iF,
00073     const dictionary& dict
00074 )
00075 :
00076     inletOutletFvPatchScalarField(p, iF),
00077     UName_(dict.lookupOrDefault<word>("U", "U")),
00078     phiName_(dict.lookupOrDefault<word>("phi", "phi")),
00079     psiName_(dict.lookupOrDefault<word>("psi", "psi")),
00080     gamma_(readScalar(dict.lookup("gamma"))),
00081     T0_("T0", dict, p.size())
00082 {
00083     this->refValue() = pTraits<scalar>::zero;
00084     if (dict.found("value"))
00085     {
00086         fvPatchField<scalar>::operator=
00087         (
00088             scalarField("value", dict, p.size())
00089         );
00090     }
00091     else
00092     {
00093         fvPatchField<scalar>::operator=(T0_);
00094     }
00095 
00096     this->refGrad() = pTraits<scalar>::zero;
00097     this->valueFraction() = 0.0;
00098 }
00099 
00100 
00101 Foam::inletOutletTotalTemperatureFvPatchScalarField::
00102 inletOutletTotalTemperatureFvPatchScalarField
00103 (
00104     const inletOutletTotalTemperatureFvPatchScalarField& tppsf
00105 )
00106 :
00107     inletOutletFvPatchScalarField(tppsf),
00108     UName_(tppsf.UName_),
00109     phiName_(tppsf.phiName_),
00110     psiName_(tppsf.psiName_),
00111     gamma_(tppsf.gamma_),
00112     T0_(tppsf.T0_)
00113 {}
00114 
00115 
00116 Foam::inletOutletTotalTemperatureFvPatchScalarField::
00117 inletOutletTotalTemperatureFvPatchScalarField
00118 (
00119     const inletOutletTotalTemperatureFvPatchScalarField& tppsf,
00120     const DimensionedField<scalar, volMesh>& iF
00121 )
00122 :
00123     inletOutletFvPatchScalarField(tppsf, iF),
00124     UName_(tppsf.UName_),
00125     phiName_(tppsf.phiName_),
00126     psiName_(tppsf.psiName_),
00127     gamma_(tppsf.gamma_),
00128     T0_(tppsf.T0_)
00129 {}
00130 
00131 
00132 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00133 
00134 void Foam::inletOutletTotalTemperatureFvPatchScalarField::autoMap
00135 (
00136     const fvPatchFieldMapper& m
00137 )
00138 {
00139     inletOutletFvPatchScalarField::autoMap(m);
00140     T0_.autoMap(m);
00141 }
00142 
00143 
00144 void Foam::inletOutletTotalTemperatureFvPatchScalarField::rmap
00145 (
00146     const fvPatchScalarField& ptf,
00147     const labelList& addr
00148 )
00149 {
00150     inletOutletFvPatchScalarField::rmap(ptf, addr);
00151 
00152     const inletOutletTotalTemperatureFvPatchScalarField& tiptf =
00153         refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
00154 
00155     T0_.rmap(tiptf.T0_, addr);
00156 }
00157 
00158 
00159 void Foam::inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
00160 {
00161     if (updated())
00162     {
00163         return;
00164     }
00165 
00166     const fvPatchVectorField& Up =
00167         patch().lookupPatchField<volVectorField, vector>(UName_);
00168 
00169     const fvsPatchField<scalar>& phip =
00170         patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
00171 
00172     const fvPatchField<scalar>& psip =
00173         patch().lookupPatchField<volScalarField, scalar>(psiName_);
00174 
00175     scalar gM1ByG = (gamma_ - 1.0)/gamma_;
00176 
00177     this->refValue() =
00178         T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up));
00179     this->valueFraction() = 1.0 - pos(phip);
00180 
00181     inletOutletFvPatchScalarField::updateCoeffs();
00182 }
00183 
00184 
00185 void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os)
00186 const
00187 {
00188     fvPatchScalarField::write(os);
00189     if (UName_ != "U")
00190     {
00191         os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
00192     }
00193     if (phiName_ != "phi")
00194     {
00195         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00196     }
00197     if (phiName_ != "psi")
00198     {
00199         os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
00200     }
00201     os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
00202     T0_.writeEntry("T0", os);
00203     writeEntry("value", os);
00204 }
00205 
00206 
00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00208 
00209 namespace Foam
00210 {
00211     makePatchTypeField
00212     (
00213         fvPatchScalarField,
00214         inletOutletTotalTemperatureFvPatchScalarField
00215     );
00216 }
00217 
00218 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines