1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 Foam::inletOutletTotalTemperatureFvPatchScalarField::
38 inletOutletTotalTemperatureFvPatchScalarField
41 const DimensionedField<scalar, volMesh>& iF
44 mixedFvPatchScalarField(p, iF),
51 this->refValue() = pTraits<scalar>::zero;
52 this->refGrad() = pTraits<scalar>::zero;
53 this->valueFraction() = 0.0;
57 Foam::inletOutletTotalTemperatureFvPatchScalarField::
58 inletOutletTotalTemperatureFvPatchScalarField
60 const inletOutletTotalTemperatureFvPatchScalarField& ptf,
62 const DimensionedField<scalar, volMesh>& iF,
63 const fvPatchFieldMapper& mapper
66 mixedFvPatchScalarField(ptf, p, iF, mapper),
68 phiName_(ptf.phiName_),
69 psiName_(ptf.psiName_),
75 Foam::inletOutletTotalTemperatureFvPatchScalarField::
76 inletOutletTotalTemperatureFvPatchScalarField
79 const DimensionedField<scalar, volMesh>& iF,
80 const dictionary& dict
83 mixedFvPatchScalarField(p, iF),
84 UName_(dict.lookupOrDefault<word>("U", "U")),
85 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
86 psiName_(dict.lookupOrDefault<word>("psi", "psi")),
87 gamma_(readScalar(dict.lookup("gamma"))),
88 T0_("T0", dict, p.size())
90 this->refValue() = pTraits<scalar>::zero;
91 if (dict.found("value"))
93 fvPatchField<scalar>::operator=
95 scalarField("value", dict, p.size())
100 fvPatchField<scalar>::operator=(T0_);
103 this->refGrad() = pTraits<scalar>::zero;
104 this->valueFraction() = 0.0;
108 Foam::inletOutletTotalTemperatureFvPatchScalarField::
109 inletOutletTotalTemperatureFvPatchScalarField
111 const inletOutletTotalTemperatureFvPatchScalarField& tppsf
114 mixedFvPatchScalarField(tppsf),
115 UName_(tppsf.UName_),
116 phiName_(tppsf.phiName_),
117 psiName_(tppsf.psiName_),
118 gamma_(tppsf.gamma_),
123 Foam::inletOutletTotalTemperatureFvPatchScalarField::
124 inletOutletTotalTemperatureFvPatchScalarField
126 const inletOutletTotalTemperatureFvPatchScalarField& tppsf,
127 const DimensionedField<scalar, volMesh>& iF
130 mixedFvPatchScalarField(tppsf, iF),
131 UName_(tppsf.UName_),
132 phiName_(tppsf.phiName_),
133 psiName_(tppsf.psiName_),
134 gamma_(tppsf.gamma_),
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 void Foam::inletOutletTotalTemperatureFvPatchScalarField::autoMap
143 const fvPatchFieldMapper& m
146 mixedFvPatchScalarField::autoMap(m);
151 void Foam::inletOutletTotalTemperatureFvPatchScalarField::rmap
153 const fvPatchScalarField& ptf,
154 const labelList& addr
157 mixedFvPatchScalarField::rmap(ptf, addr);
159 const inletOutletTotalTemperatureFvPatchScalarField& tiptf =
160 refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
162 T0_.rmap(tiptf.T0_, addr);
166 void Foam::inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
173 const fvPatchVectorField& Up =
174 patch().lookupPatchField<volVectorField, vector>(UName_);
176 const fvsPatchField<scalar>& phip =
177 patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
179 const fvPatchField<scalar>& psip =
180 patch().lookupPatchField<volScalarField, scalar>(psiName_);
182 scalar gM1ByG = (gamma_ - 1.0)/gamma_;
185 T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up));
186 this->valueFraction() = 1.0 - pos(phip);
188 mixedFvPatchScalarField::updateCoeffs();
192 void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os)
195 fvPatchScalarField::write(os);
198 os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
200 if (phiName_ != "phi")
202 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
204 if (phiName_ != "psi")
206 os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
208 os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
209 T0_.writeEntry("T0", os);
210 writeEntry("value", os);
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 inletOutletTotalTemperatureFvPatchScalarField
225 // ************************************************************************* //