1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "inletOutletTotalTemperatureFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 Foam::inletOutletTotalTemperatureFvPatchScalarField::
35 inletOutletTotalTemperatureFvPatchScalarField
38 const DimensionedField<scalar, volMesh>& iF
41 inletOutletFvPatchScalarField(p, iF),
48 this->refValue() = pTraits<scalar>::zero;
49 this->refGrad() = pTraits<scalar>::zero;
50 this->valueFraction() = 0.0;
54 Foam::inletOutletTotalTemperatureFvPatchScalarField::
55 inletOutletTotalTemperatureFvPatchScalarField
57 const inletOutletTotalTemperatureFvPatchScalarField& ptf,
59 const DimensionedField<scalar, volMesh>& iF,
60 const fvPatchFieldMapper& mapper
63 inletOutletFvPatchScalarField(ptf, p, iF, mapper),
65 phiName_(ptf.phiName_),
66 psiName_(ptf.psiName_),
72 Foam::inletOutletTotalTemperatureFvPatchScalarField::
73 inletOutletTotalTemperatureFvPatchScalarField
76 const DimensionedField<scalar, volMesh>& iF,
77 const dictionary& dict
80 inletOutletFvPatchScalarField(p, iF),
81 UName_(dict.lookupOrDefault<word>("U", "U")),
82 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
83 psiName_(dict.lookupOrDefault<word>("psi", "psi")),
84 gamma_(readScalar(dict.lookup("gamma"))),
85 T0_("T0", dict, p.size())
87 this->refValue() = pTraits<scalar>::zero;
88 if (dict.found("value"))
90 fvPatchField<scalar>::operator=
92 scalarField("value", dict, p.size())
97 fvPatchField<scalar>::operator=(T0_);
100 this->refGrad() = pTraits<scalar>::zero;
101 this->valueFraction() = 0.0;
105 Foam::inletOutletTotalTemperatureFvPatchScalarField::
106 inletOutletTotalTemperatureFvPatchScalarField
108 const inletOutletTotalTemperatureFvPatchScalarField& tppsf
111 inletOutletFvPatchScalarField(tppsf),
112 UName_(tppsf.UName_),
113 phiName_(tppsf.phiName_),
114 psiName_(tppsf.psiName_),
115 gamma_(tppsf.gamma_),
120 Foam::inletOutletTotalTemperatureFvPatchScalarField::
121 inletOutletTotalTemperatureFvPatchScalarField
123 const inletOutletTotalTemperatureFvPatchScalarField& tppsf,
124 const DimensionedField<scalar, volMesh>& iF
127 inletOutletFvPatchScalarField(tppsf, iF),
128 UName_(tppsf.UName_),
129 phiName_(tppsf.phiName_),
130 psiName_(tppsf.psiName_),
131 gamma_(tppsf.gamma_),
136 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
138 void Foam::inletOutletTotalTemperatureFvPatchScalarField::autoMap
140 const fvPatchFieldMapper& m
143 inletOutletFvPatchScalarField::autoMap(m);
148 void Foam::inletOutletTotalTemperatureFvPatchScalarField::rmap
150 const fvPatchScalarField& ptf,
151 const labelList& addr
154 inletOutletFvPatchScalarField::rmap(ptf, addr);
156 const inletOutletTotalTemperatureFvPatchScalarField& tiptf =
157 refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
159 T0_.rmap(tiptf.T0_, addr);
163 void Foam::inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
170 const fvPatchVectorField& Up =
171 patch().lookupPatchField<volVectorField, vector>(UName_);
173 const fvsPatchField<scalar>& phip =
174 patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
176 const fvPatchField<scalar>& psip =
177 patch().lookupPatchField<volScalarField, scalar>(psiName_);
179 scalar gM1ByG = (gamma_ - 1.0)/gamma_;
182 T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up));
183 this->valueFraction() = 1.0 - pos(phip);
185 inletOutletFvPatchScalarField::updateCoeffs();
189 void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os)
192 fvPatchScalarField::write(os);
193 writeEntryIfDifferent<word>(os, "U", "U", UName_);
194 writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
195 writeEntryIfDifferent<word>(os, "psi", "psi", psiName_);
196 os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
197 T0_.writeEntry("T0", os);
198 writeEntry("value", os);
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 inletOutletTotalTemperatureFvPatchScalarField
213 // ************************************************************************* //