1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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 "inletOutletTotalTemperatureFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 inletOutletTotalTemperatureFvPatchScalarField::
41 inletOutletTotalTemperatureFvPatchScalarField
44 const DimensionedField<scalar, volMesh>& iF
47 mixedFvPatchScalarField(p, iF),
54 this->refValue() = pTraits<scalar>::zero;
55 this->refGrad() = pTraits<scalar>::zero;
56 this->valueFraction() = 0.0;
60 inletOutletTotalTemperatureFvPatchScalarField::
61 inletOutletTotalTemperatureFvPatchScalarField
63 const inletOutletTotalTemperatureFvPatchScalarField& ptf,
65 const DimensionedField<scalar, volMesh>& iF,
66 const fvPatchFieldMapper& mapper
69 mixedFvPatchScalarField(ptf, p, iF, mapper),
71 phiName_(ptf.phiName_),
72 psiName_(ptf.psiName_),
78 inletOutletTotalTemperatureFvPatchScalarField::
79 inletOutletTotalTemperatureFvPatchScalarField
82 const DimensionedField<scalar, volMesh>& iF,
83 const dictionary& dict
86 mixedFvPatchScalarField(p, iF),
87 UName_(dict.lookup("U")),
88 phiName_(dict.lookup("phi")),
89 psiName_(dict.lookup("psi")),
90 gamma_(readScalar(dict.lookup("gamma"))),
91 T0_("T0", dict, p.size())
93 this->refValue() = pTraits<scalar>::zero;
94 if (dict.found("value"))
96 fvPatchField<scalar>::operator=
98 scalarField("value", dict, p.size())
103 fvPatchField<scalar>::operator=(T0_);
106 this->refGrad() = pTraits<scalar>::zero;
107 this->valueFraction() = 0.0;
111 inletOutletTotalTemperatureFvPatchScalarField::
112 inletOutletTotalTemperatureFvPatchScalarField
114 const inletOutletTotalTemperatureFvPatchScalarField& tppsf
117 mixedFvPatchScalarField(tppsf),
118 UName_(tppsf.UName_),
119 phiName_(tppsf.phiName_),
120 psiName_(tppsf.psiName_),
121 gamma_(tppsf.gamma_),
126 inletOutletTotalTemperatureFvPatchScalarField::
127 inletOutletTotalTemperatureFvPatchScalarField
129 const inletOutletTotalTemperatureFvPatchScalarField& tppsf,
130 const DimensionedField<scalar, volMesh>& iF
133 mixedFvPatchScalarField(tppsf, iF),
134 UName_(tppsf.UName_),
135 phiName_(tppsf.phiName_),
136 psiName_(tppsf.psiName_),
137 gamma_(tppsf.gamma_),
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 void inletOutletTotalTemperatureFvPatchScalarField::autoMap
146 const fvPatchFieldMapper& m
149 mixedFvPatchScalarField::autoMap(m);
154 void inletOutletTotalTemperatureFvPatchScalarField::rmap
156 const fvPatchScalarField& ptf,
157 const labelList& addr
160 mixedFvPatchScalarField::rmap(ptf, addr);
162 const inletOutletTotalTemperatureFvPatchScalarField& tiptf =
163 refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
165 T0_.rmap(tiptf.T0_, addr);
169 void inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
176 const fvPatchVectorField& Up =
177 patch().lookupPatchField<volVectorField, vector>(UName_);
179 const fvsPatchField<scalar>& phip =
180 patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
182 const fvPatchField<scalar>& psip =
183 patch().lookupPatchField<volScalarField, scalar>(psiName_);
185 scalar gM1ByG = (gamma_ - 1.0)/gamma_;
188 T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up));
189 this->valueFraction() = 1.0 - pos(phip);
191 mixedFvPatchScalarField::updateCoeffs();
195 void inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os) const
197 fvPatchScalarField::write(os);
198 os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
199 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
200 os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
201 os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << endl;
202 T0_.writeEntry("T0", os);
203 writeEntry("value", os);
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 inletOutletTotalTemperatureFvPatchScalarField
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 } // End namespace Foam
219 // ************************************************************************* //