Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / finiteVolume / fields / fvPatchFields / derived / totalTemperature / totalTemperatureFvPatchScalarField.C
blob66e51e8a1ed20114fd58d41c1fdff36f3784b59f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
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 -------------------------------------------------------------------------------
8 License
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
36     const fvPatch& p,
37     const DimensionedField<scalar, volMesh>& iF
40     fixedValueFvPatchScalarField(p, iF),
41     UName_("U"),
42     phiName_("phi"),
43     psiName_("psi"),
44     gamma_(0.0),
45     T0_(p.size(), 0.0)
49 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
51     const totalTemperatureFvPatchScalarField& ptf,
52     const fvPatch& p,
53     const DimensionedField<scalar, volMesh>& iF,
54     const fvPatchFieldMapper& mapper
57     fixedValueFvPatchScalarField(ptf, p, iF, mapper),
58     UName_(ptf.UName_),
59     phiName_(ptf.phiName_),
60     psiName_(ptf.psiName_),
61     gamma_(ptf.gamma_),
62     T0_(ptf.T0_, mapper)
66 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
68     const fvPatch& p,
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"))
81     {
82         fvPatchScalarField::operator=
83         (
84             scalarField("value", dict, p.size())
85         );
86     }
87     else
88     {
89         fvPatchScalarField::operator=(T0_);
90     }
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_),
104     T0_(tppsf.T0_)
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_),
119     T0_(tppsf.T0_)
123 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
125 void Foam::totalTemperatureFvPatchScalarField::autoMap
127     const fvPatchFieldMapper& m
130     fixedValueFvPatchScalarField::autoMap(m);
131     T0_.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()
152     if (updated())
153     {
154         return;
155     }
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_;
168     operator==
169     (
170         T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up))
171     );
173     fixedValueFvPatchScalarField::updateCoeffs();
177 Foam::tmp<Foam::scalarField>
178 Foam::totalTemperatureFvPatchScalarField::snGrad() const
180     return tmp<scalarField>
181     (
182         new scalarField(this->size(), 0.0)
183     );
187 Foam::tmp<Foam::scalarField>
188 Foam::totalTemperatureFvPatchScalarField::gradientInternalCoeffs() const
190     return tmp<scalarField>
191     (
192         new scalarField(this->size(), 0.0)
193     );
197 Foam::tmp<Foam::scalarField>
198 Foam::totalTemperatureFvPatchScalarField::gradientBoundaryCoeffs() const
200     return tmp<scalarField>
201     (
202         new scalarField(this->size(), 0.0)
203     );
207 void Foam::totalTemperatureFvPatchScalarField::write(Ostream& os) const
209     fvPatchScalarField::write(os);
210     if (UName_ != "U")
211     {
212         os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
213     }
214     if (phiName_ != "phi")
215     {
216         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
217     }
218     if (psiName_ != "psi")
219     {
220         os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
221     }
222     os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
223     T0_.writeEntry("T0", os);
224     writeEntry("value", os);
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 namespace Foam
232     makePatchTypeField
233     (
234         fvPatchScalarField,
235         totalTemperatureFvPatchScalarField
236     );
239 // ************************************************************************* //