initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / finiteVolume / fields / fvPatchFields / derived / inletOutletTotalTemperature / inletOutletTotalTemperatureFvPatchScalarField.C
blob0a2dff4a4c578b3a8bb728dff75096e089ea1511
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 "inletOutletTotalTemperatureFvPatchScalarField.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
40 inletOutletTotalTemperatureFvPatchScalarField::
41 inletOutletTotalTemperatureFvPatchScalarField
43     const fvPatch& p,
44     const DimensionedField<scalar, volMesh>& iF
47     mixedFvPatchScalarField(p, iF),
48     UName_(),
49     phiName_(),
50     psiName_(),
51     gamma_(0.0),
52     T0_(p.size(), 0.0)
54     this->refValue() = pTraits<scalar>::zero;
55     this->refGrad() = pTraits<scalar>::zero;
56     this->valueFraction() = 0.0;
60 inletOutletTotalTemperatureFvPatchScalarField::
61 inletOutletTotalTemperatureFvPatchScalarField
63     const inletOutletTotalTemperatureFvPatchScalarField& ptf,
64     const fvPatch& p,
65     const DimensionedField<scalar, volMesh>& iF,
66     const fvPatchFieldMapper& mapper
69     mixedFvPatchScalarField(ptf, p, iF, mapper),
70     UName_(ptf.UName_),
71     phiName_(ptf.phiName_),
72     psiName_(ptf.psiName_),
73     gamma_(ptf.gamma_),
74     T0_(ptf.T0_, mapper)
78 inletOutletTotalTemperatureFvPatchScalarField::
79 inletOutletTotalTemperatureFvPatchScalarField
81     const fvPatch& p,
82     const DimensionedField<scalar, volMesh>& iF,
83     const dictionary& dict
86     mixedFvPatchScalarField(p, iF),
87     UName_(dict.lookup("U")),
88     phiName_(dict.lookup("phi")),
89     psiName_(dict.lookup("psi")),
90     gamma_(readScalar(dict.lookup("gamma"))),
91     T0_("T0", dict, p.size())
93     this->refValue() = pTraits<scalar>::zero;
94     if (dict.found("value"))
95     {
96         fvPatchField<scalar>::operator=
97         (
98             scalarField("value", dict, p.size())
99         );
100     }
101     else
102     {
103         fvPatchField<scalar>::operator=(T0_);
104     }
106     this->refGrad() = pTraits<scalar>::zero;
107     this->valueFraction() = 0.0;
111 inletOutletTotalTemperatureFvPatchScalarField::
112 inletOutletTotalTemperatureFvPatchScalarField
114     const inletOutletTotalTemperatureFvPatchScalarField& tppsf
117     mixedFvPatchScalarField(tppsf),
118     UName_(tppsf.UName_),
119     phiName_(tppsf.phiName_),
120     psiName_(tppsf.psiName_),
121     gamma_(tppsf.gamma_),
122     T0_(tppsf.T0_)
126 inletOutletTotalTemperatureFvPatchScalarField::
127 inletOutletTotalTemperatureFvPatchScalarField
129     const inletOutletTotalTemperatureFvPatchScalarField& tppsf,
130     const DimensionedField<scalar, volMesh>& iF
133     mixedFvPatchScalarField(tppsf, iF),
134     UName_(tppsf.UName_),
135     phiName_(tppsf.phiName_),
136     psiName_(tppsf.psiName_),
137     gamma_(tppsf.gamma_),
138     T0_(tppsf.T0_)
142 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
144 void inletOutletTotalTemperatureFvPatchScalarField::autoMap
146     const fvPatchFieldMapper& m
149     mixedFvPatchScalarField::autoMap(m);
150     T0_.autoMap(m);
154 void inletOutletTotalTemperatureFvPatchScalarField::rmap
156     const fvPatchScalarField& ptf,
157     const labelList& addr
160     mixedFvPatchScalarField::rmap(ptf, addr);
162     const inletOutletTotalTemperatureFvPatchScalarField& tiptf =
163         refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
165     T0_.rmap(tiptf.T0_, addr);
169 void inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
171     if (updated())
172     {
173         return;
174     }
176     const fvPatchVectorField& Up =
177         patch().lookupPatchField<volVectorField, vector>(UName_);
179     const fvsPatchField<scalar>& phip =
180         patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
182     const fvPatchField<scalar>& psip =
183         patch().lookupPatchField<volScalarField, scalar>(psiName_);
185     scalar gM1ByG = (gamma_ - 1.0)/gamma_;
187     this->refValue() =
188         T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up));
189     this->valueFraction() = 1.0 - pos(phip);
191     mixedFvPatchScalarField::updateCoeffs();
195 void inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os) const
197     fvPatchScalarField::write(os);
198     os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
199     os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
200     os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
201     os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << endl;
202     T0_.writeEntry("T0", os);
203     writeEntry("value", os);
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 makePatchTypeField
211     fvPatchScalarField,
212     inletOutletTotalTemperatureFvPatchScalarField
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 } // End namespace Foam
219 // ************************************************************************* //