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

totalTemperatureFvPatchScalarField.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-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 "totalTemperatureFvPatchScalarField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "surfaceFields.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
00038 (
00039     const fvPatch& p,
00040     const DimensionedField<scalar, volMesh>& iF
00041 )
00042 :
00043     fixedValueFvPatchScalarField(p, iF),
00044     UName_("U"),
00045     phiName_("phi"),
00046     psiName_("psi"),
00047     gamma_(0.0),
00048     T0_(p.size(), 0.0)
00049 {}
00050 
00051 
00052 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
00053 (
00054     const totalTemperatureFvPatchScalarField& ptf,
00055     const fvPatch& p,
00056     const DimensionedField<scalar, volMesh>& iF,
00057     const fvPatchFieldMapper& mapper
00058 )
00059 :
00060     fixedValueFvPatchScalarField(ptf, p, iF, mapper),
00061     UName_(ptf.UName_),
00062     phiName_(ptf.phiName_),
00063     psiName_(ptf.psiName_),
00064     gamma_(ptf.gamma_),
00065     T0_(ptf.T0_, mapper)
00066 {}
00067 
00068 
00069 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
00070 (
00071     const fvPatch& p,
00072     const DimensionedField<scalar, volMesh>& iF,
00073     const dictionary& dict
00074 )
00075 :
00076     fixedValueFvPatchScalarField(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     if (dict.found("value"))
00084     {
00085         fvPatchField<scalar>::operator=
00086         (
00087             scalarField("value", dict, p.size())
00088         );
00089     }
00090     else
00091     {
00092         fvPatchField<scalar>::operator=(T0_);
00093     }
00094 }
00095 
00096 
00097 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
00098 (
00099     const totalTemperatureFvPatchScalarField& tppsf
00100 )
00101 :
00102     fixedValueFvPatchScalarField(tppsf),
00103     UName_(tppsf.UName_),
00104     phiName_(tppsf.phiName_),
00105     psiName_(tppsf.psiName_),
00106     gamma_(tppsf.gamma_),
00107     T0_(tppsf.T0_)
00108 {}
00109 
00110 
00111 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
00112 (
00113     const totalTemperatureFvPatchScalarField& tppsf,
00114     const DimensionedField<scalar, volMesh>& iF
00115 )
00116 :
00117     fixedValueFvPatchScalarField(tppsf, iF),
00118     UName_(tppsf.UName_),
00119     phiName_(tppsf.phiName_),
00120     psiName_(tppsf.psiName_),
00121     gamma_(tppsf.gamma_),
00122     T0_(tppsf.T0_)
00123 {}
00124 
00125 
00126 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00127 
00128 void Foam::totalTemperatureFvPatchScalarField::autoMap
00129 (
00130     const fvPatchFieldMapper& m
00131 )
00132 {
00133     fixedValueFvPatchScalarField::autoMap(m);
00134     T0_.autoMap(m);
00135 }
00136 
00137 
00138 void Foam::totalTemperatureFvPatchScalarField::rmap
00139 (
00140     const fvPatchScalarField& ptf,
00141     const labelList& addr
00142 )
00143 {
00144     fixedValueFvPatchScalarField::rmap(ptf, addr);
00145 
00146     const totalTemperatureFvPatchScalarField& tiptf =
00147         refCast<const totalTemperatureFvPatchScalarField>(ptf);
00148 
00149     T0_.rmap(tiptf.T0_, addr);
00150 }
00151 
00152 
00153 void Foam::totalTemperatureFvPatchScalarField::updateCoeffs()
00154 {
00155     if (updated())
00156     {
00157         return;
00158     }
00159 
00160     const fvPatchVectorField& Up =
00161         patch().lookupPatchField<volVectorField, vector>(UName_);
00162 
00163     const fvsPatchField<scalar>& phip =
00164         patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
00165 
00166     const fvPatchField<scalar>& psip =
00167         patch().lookupPatchField<volScalarField, scalar>(psiName_);
00168 
00169     scalar gM1ByG = (gamma_ - 1.0)/gamma_;
00170 
00171     operator==
00172     (
00173         T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up))
00174     );
00175 
00176     fixedValueFvPatchScalarField::updateCoeffs();
00177 }
00178 
00179 
00180 void Foam::totalTemperatureFvPatchScalarField::write(Ostream& os) const
00181 {
00182     fvPatchScalarField::write(os);
00183     if (UName_ != "U")
00184     {
00185         os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
00186     }
00187     if (phiName_ != "phi")
00188     {
00189         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00190     }
00191     if (phiName_ != "psi")
00192     {
00193         os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
00194     }
00195     os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
00196     T0_.writeEntry("T0", os);
00197     writeEntry("value", os);
00198 }
00199 
00200 
00201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00202 
00203 namespace Foam
00204 {
00205     makePatchTypeField
00206     (
00207         fvPatchScalarField, 
00208         totalTemperatureFvPatchScalarField
00209     );
00210 }
00211 
00212 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd