initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / fields / fvPatchFields / derived / totalTemperature / totalTemperatureFvPatchScalarField.C
blobca77c9aed47381c493bd2ee8b8a3e84717a1b502
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
39     const fvPatch& p,
40     const DimensionedField<scalar, volMesh>& iF
43     fixedValueFvPatchScalarField(p, iF),
44     UName_("U"),
45     phiName_("phi"),
46     psiName_("psi"),
47     gamma_(0.0),
48     T0_(p.size(), 0.0)
52 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
54     const totalTemperatureFvPatchScalarField& ptf,
55     const fvPatch& p,
56     const DimensionedField<scalar, volMesh>& iF,
57     const fvPatchFieldMapper& mapper
60     fixedValueFvPatchScalarField(ptf, p, iF, mapper),
61     UName_(ptf.UName_),
62     phiName_(ptf.phiName_),
63     psiName_(ptf.psiName_),
64     gamma_(ptf.gamma_),
65     T0_(ptf.T0_, mapper)
69 Foam::totalTemperatureFvPatchScalarField::totalTemperatureFvPatchScalarField
71     const fvPatch& p,
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"))
84     {
85         fvPatchField<scalar>::operator=
86         (
87             scalarField("value", dict, p.size())
88         );
89     }
90     else
91     {
92         fvPatchField<scalar>::operator=(T0_);
93     }
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_),
107     T0_(tppsf.T0_)
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_),
122     T0_(tppsf.T0_)
126 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
128 void Foam::totalTemperatureFvPatchScalarField::autoMap
130     const fvPatchFieldMapper& m
133     fixedValueFvPatchScalarField::autoMap(m);
134     T0_.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()
155     if (updated())
156     {
157         return;
158     }
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_;
171     operator==
172     (
173         T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up))
174     );
176     fixedValueFvPatchScalarField::updateCoeffs();
180 void Foam::totalTemperatureFvPatchScalarField::write(Ostream& os) const
182     fvPatchScalarField::write(os);
183     if (UName_ != "U")
184     {
185         os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
186     }
187     if (phiName_ != "phi")
188     {
189         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
190     }
191     if (phiName_ != "psi")
192     {
193         os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
194     }
195     os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
196     T0_.writeEntry("T0", os);
197     writeEntry("value", os);
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 namespace Foam
205     makePatchTypeField
206     (
207         fvPatchScalarField, 
208         totalTemperatureFvPatchScalarField
209     );
212 // ************************************************************************* //