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 "isentropicTotalPressureFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "basicThermo.H"
30 #include "isentropicTotalTemperatureFvPatchScalarField.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 Foam::isentropicTotalPressureFvPatchScalarField::
35 isentropicTotalPressureFvPatchScalarField
38 const DimensionedField<scalar, volMesh>& iF
41 fixedValueFvPatchScalarField(p, iF),
48 Foam::isentropicTotalPressureFvPatchScalarField::
49 isentropicTotalPressureFvPatchScalarField
52 const DimensionedField<scalar, volMesh>& iF,
53 const dictionary& dict
56 fixedValueFvPatchScalarField(p, iF),
57 UName_(dict.lookupOrDefault<word>("U", "U")),
58 TName_(dict.lookupOrDefault<word>("T", "T")),
59 p0_("p0", dict, p.size())
61 if (dict.found("value"))
63 fvPatchField<scalar>::operator=
65 scalarField("value", dict, p.size())
70 fvPatchField<scalar>::operator=(p0_);
75 Foam::isentropicTotalPressureFvPatchScalarField::
76 isentropicTotalPressureFvPatchScalarField
78 const isentropicTotalPressureFvPatchScalarField& ptf,
80 const DimensionedField<scalar, volMesh>& iF,
81 const fvPatchFieldMapper& mapper
84 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
91 Foam::isentropicTotalPressureFvPatchScalarField::
92 isentropicTotalPressureFvPatchScalarField
94 const isentropicTotalPressureFvPatchScalarField& ptf
97 fixedValueFvPatchScalarField(ptf),
104 Foam::isentropicTotalPressureFvPatchScalarField::
105 isentropicTotalPressureFvPatchScalarField
107 const isentropicTotalPressureFvPatchScalarField& ptf,
108 const DimensionedField<scalar, volMesh>& iF
111 fixedValueFvPatchScalarField(ptf, iF),
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 void Foam::isentropicTotalPressureFvPatchScalarField::autoMap
122 const fvPatchFieldMapper& m
125 fixedValueFvPatchScalarField::autoMap(m);
130 void Foam::isentropicTotalPressureFvPatchScalarField::rmap
132 const fvPatchScalarField& ptf,
133 const labelList& addr
136 fixedValueFvPatchScalarField::rmap(ptf, addr);
138 const isentropicTotalPressureFvPatchScalarField& tiptf =
139 refCast<const isentropicTotalPressureFvPatchScalarField>(ptf);
141 p0_.rmap(tiptf.p0_, addr);
145 void Foam::isentropicTotalPressureFvPatchScalarField::updateCoeffs()
153 const fvPatchVectorField& U =
154 patch().lookupPatchField<volVectorField, scalar>(UName_);
157 const fvPatchScalarField& T =
158 patch().lookupPatchField<volScalarField, scalar>(TName_);
160 const basicThermo& thermo =
161 db().lookupObject<basicThermo>("thermophysicalProperties");
163 scalarField Cp = thermo.Cp(T, patch().index());
164 scalarField Cv = thermo.Cv(T, patch().index());
166 scalarField gamma = Cp/Cv;
167 scalarField R = Cp - Cv;
169 scalarField Ma = -(patch().nf() & U)/sqrt(gamma*R*T);
171 scalarField a = 1 + 0.5*(gamma - 1)*sqr(Ma);
173 operator==(p0_*pow(a, -gamma/(gamma - 1)));
175 fixedValueFvPatchScalarField::updateCoeffs();
178 void Foam::isentropicTotalPressureFvPatchScalarField::updateCoeffs
180 const vectorField& Up
187 Foam::tmp<Foam::scalarField>
188 Foam::isentropicTotalPressureFvPatchScalarField::snGrad() const
190 return tmp<scalarField>
192 new scalarField(this->size(), 0.0)
197 Foam::tmp<Foam::scalarField>
198 Foam::isentropicTotalPressureFvPatchScalarField::gradientInternalCoeffs() const
200 return tmp<scalarField>
202 new scalarField(this->size(), 0.0)
207 Foam::tmp<Foam::scalarField>
208 Foam::isentropicTotalPressureFvPatchScalarField::gradientBoundaryCoeffs() const
210 return tmp<scalarField>
212 new scalarField(this->size(), 0.0)
217 void Foam::isentropicTotalPressureFvPatchScalarField::write
222 fixedValueFvPatchScalarField::write(os);
223 writeEntryIfDifferent<word>(os, "T", "T", TName_);
224 p0_.writeEntry("p0", os);
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 isentropicTotalPressureFvPatchScalarField
239 } // End namespace Foam
242 // ************************************************************************* //