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

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