1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "totalTemperatureFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "surfaceFields.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
37 const DimensionedField<scalar, volMesh>& iF
40 fixedValueFvPatchScalarField(p, iF),
49 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
51 const totalTemperatureFvPatchScalarField& ptf,
53 const DimensionedField<scalar, volMesh>& iF,
54 const fvPatchFieldMapper& mapper
57 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
59 phiName_(ptf.phiName_),
60 psiName_(ptf.psiName_),
66 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
69 const DimensionedField<scalar, volMesh>& iF,
70 const dictionary& dict
73 fixedValueFvPatchScalarField(p, iF),
74 UName_(dict.lookupOrDefault<word>("U", "U")),
75 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
76 psiName_(dict.lookupOrDefault<word>("psi", "psi")),
77 gamma_(readScalar(dict.lookup("gamma"))),
78 T0_("T0", dict, p.size())
80 if (dict.found("value"))
82 fvPatchScalarField::operator=
84 scalarField("value", dict, p.size())
89 fvPatchScalarField::operator=(T0_);
94 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
96 const totalTemperatureFvPatchScalarField& tppsf
99 fixedValueFvPatchScalarField(tppsf),
100 UName_(tppsf.UName_),
101 phiName_(tppsf.phiName_),
102 psiName_(tppsf.psiName_),
103 gamma_(tppsf.gamma_),
108 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
110 const totalTemperatureFvPatchScalarField& tppsf,
111 const DimensionedField<scalar, volMesh>& iF
114 fixedValueFvPatchScalarField(tppsf, iF),
115 UName_(tppsf.UName_),
116 phiName_(tppsf.phiName_),
117 psiName_(tppsf.psiName_),
118 gamma_(tppsf.gamma_),
123 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 void Foam::totalTemperatureFvPatchScalarField::autoMap
127 const fvPatchFieldMapper& m
130 fixedValueFvPatchScalarField::autoMap(m);
135 void Foam::totalTemperatureFvPatchScalarField::rmap
137 const fvPatchScalarField& ptf,
138 const labelList& addr
141 fixedValueFvPatchScalarField::rmap(ptf, addr);
143 const totalTemperatureFvPatchScalarField& tiptf =
144 refCast<const totalTemperatureFvPatchScalarField>(ptf);
146 T0_.rmap(tiptf.T0_, addr);
150 void Foam::totalTemperatureFvPatchScalarField::updateCoeffs()
157 const fvPatchVectorField& Up =
158 lookupPatchField<volVectorField, vector>(UName_);
160 const fvsPatchScalarField& phip =
161 lookupPatchField<surfaceScalarField, scalar>(phiName_);
163 const fvPatchScalarField& psip =
164 lookupPatchField<volScalarField, scalar>(psiName_);
166 scalar gM1ByG = (gamma_ - 1.0)/gamma_;
170 T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up))
173 fixedValueFvPatchScalarField::updateCoeffs();
177 Foam::tmp<Foam::scalarField>
178 Foam::totalTemperatureFvPatchScalarField::snGrad() const
180 return tmp<scalarField>
182 new scalarField(this->size(), 0.0)
187 Foam::tmp<Foam::scalarField>
188 Foam::totalTemperatureFvPatchScalarField::gradientInternalCoeffs() const
190 return tmp<scalarField>
192 new scalarField(this->size(), 0.0)
197 Foam::tmp<Foam::scalarField>
198 Foam::totalTemperatureFvPatchScalarField::gradientBoundaryCoeffs() const
200 return tmp<scalarField>
202 new scalarField(this->size(), 0.0)
207 void Foam::totalTemperatureFvPatchScalarField::write(Ostream& os) const
209 fvPatchScalarField::write(os);
212 os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
214 if (phiName_ != "phi")
216 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
218 if (psiName_ != "psi")
220 os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
222 os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
223 T0_.writeEntry("T0", os);
224 writeEntry("value", os);
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 totalTemperatureFvPatchScalarField
239 // ************************************************************************* //