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 "totalTemperatureFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
40 const DimensionedField<scalar, volMesh>& iF
43 fixedValueFvPatchScalarField(p, iF),
52 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
54 const totalTemperatureFvPatchScalarField& ptf,
56 const DimensionedField<scalar, volMesh>& iF,
57 const fvPatchFieldMapper& mapper
60 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
62 phiName_(ptf.phiName_),
63 psiName_(ptf.psiName_),
69 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
72 const DimensionedField<scalar, volMesh>& iF,
73 const dictionary& dict
76 fixedValueFvPatchScalarField(p, iF),
77 UName_(dict.lookupOrDefault<word>("U", "U")),
78 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
79 psiName_(dict.lookupOrDefault<word>("psi", "psi")),
80 gamma_(readScalar(dict.lookup("gamma"))),
81 T0_("T0", dict, p.size())
83 if (dict.found("value"))
85 fvPatchField<scalar>::operator=
87 scalarField("value", dict, p.size())
92 fvPatchField<scalar>::operator=(T0_);
97 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
99 const totalTemperatureFvPatchScalarField& tppsf
102 fixedValueFvPatchScalarField(tppsf),
103 UName_(tppsf.UName_),
104 phiName_(tppsf.phiName_),
105 psiName_(tppsf.psiName_),
106 gamma_(tppsf.gamma_),
111 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
113 const totalTemperatureFvPatchScalarField& tppsf,
114 const DimensionedField<scalar, volMesh>& iF
117 fixedValueFvPatchScalarField(tppsf, iF),
118 UName_(tppsf.UName_),
119 phiName_(tppsf.phiName_),
120 psiName_(tppsf.psiName_),
121 gamma_(tppsf.gamma_),
126 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128 void Foam::totalTemperatureFvPatchScalarField::autoMap
130 const fvPatchFieldMapper& m
133 fixedValueFvPatchScalarField::autoMap(m);
138 void Foam::totalTemperatureFvPatchScalarField::rmap
140 const fvPatchScalarField& ptf,
141 const labelList& addr
144 fixedValueFvPatchScalarField::rmap(ptf, addr);
146 const totalTemperatureFvPatchScalarField& tiptf =
147 refCast<const totalTemperatureFvPatchScalarField>(ptf);
149 T0_.rmap(tiptf.T0_, addr);
153 void Foam::totalTemperatureFvPatchScalarField::updateCoeffs()
160 const fvPatchVectorField& Up =
161 patch().lookupPatchField<volVectorField, vector>(UName_);
163 const fvsPatchField<scalar>& phip =
164 patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
166 const fvPatchField<scalar>& psip =
167 patch().lookupPatchField<volScalarField, scalar>(psiName_);
169 scalar gM1ByG = (gamma_ - 1.0)/gamma_;
173 T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up))
176 fixedValueFvPatchScalarField::updateCoeffs();
180 void Foam::totalTemperatureFvPatchScalarField::write(Ostream& os) const
182 fvPatchScalarField::write(os);
185 os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
187 if (phiName_ != "phi")
189 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
191 if (psiName_ != "psi")
193 os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
195 os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
196 T0_.writeEntry("T0", os);
197 writeEntry("value", os);
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 totalTemperatureFvPatchScalarField
212 // ************************************************************************* //