FreeFOAM The Cross-Platform CFD Toolkit
inletOutletTotalTemperatureFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2011 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
29 #include <finiteVolume/volFields.H>
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const fvPatch& p,
39 )
40 :
41  inletOutletFvPatchScalarField(p, iF),
42  UName_("U"),
43  phiName_("phi"),
44  psiName_("psi"),
45  gamma_(0.0),
46  T0_(p.size(), 0.0)
47 {}
48 
49 
52 (
54  const fvPatch& p,
56  const fvPatchFieldMapper& mapper
57 )
58 :
59  inletOutletFvPatchScalarField(ptf, p, iF, mapper),
60  UName_(ptf.UName_),
61  phiName_(ptf.phiName_),
62  psiName_(ptf.psiName_),
63  gamma_(ptf.gamma_),
64  T0_(ptf.T0_, mapper)
65 {}
66 
67 
70 (
71  const fvPatch& p,
73  const dictionary& dict
74 )
75 :
76  inletOutletFvPatchScalarField(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())
82 {
83  this->refValue() = pTraits<scalar>::zero;
84  if (dict.found("value"))
85  {
87  (
88  scalarField("value", dict, p.size())
89  );
90  }
91  else
92  {
94  }
95 
96  this->refGrad() = pTraits<scalar>::zero;
97  this->valueFraction() = 0.0;
98 }
99 
100 
103 (
105 )
106 :
107  inletOutletFvPatchScalarField(tppsf),
108  UName_(tppsf.UName_),
109  phiName_(tppsf.phiName_),
110  psiName_(tppsf.psiName_),
111  gamma_(tppsf.gamma_),
112  T0_(tppsf.T0_)
113 {}
114 
115 
118 (
121 )
122 :
123  inletOutletFvPatchScalarField(tppsf, iF),
124  UName_(tppsf.UName_),
125  phiName_(tppsf.phiName_),
126  psiName_(tppsf.psiName_),
127  gamma_(tppsf.gamma_),
128  T0_(tppsf.T0_)
129 {}
130 
131 
132 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 
135 (
136  const fvPatchFieldMapper& m
137 )
138 {
139  inletOutletFvPatchScalarField::autoMap(m);
140  T0_.autoMap(m);
141 }
142 
143 
145 (
146  const fvPatchScalarField& ptf,
147  const labelList& addr
148 )
149 {
150  inletOutletFvPatchScalarField::rmap(ptf, addr);
151 
153  refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
154 
155  T0_.rmap(tiptf.T0_, addr);
156 }
157 
158 
160 {
161  if (updated())
162  {
163  return;
164  }
165 
166  const fvPatchVectorField& Up =
167  patch().lookupPatchField<volVectorField, vector>(UName_);
168 
169  const fvsPatchField<scalar>& phip =
170  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
171 
172  const fvPatchField<scalar>& psip =
173  patch().lookupPatchField<volScalarField, scalar>(psiName_);
174 
175  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
176 
177  this->refValue() =
178  T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up));
179  this->valueFraction() = 1.0 - pos(phip);
180 
182 }
183 
184 
186 const
187 {
189  if (UName_ != "U")
190  {
191  os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
192  }
193  if (phiName_ != "phi")
194  {
195  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
196  }
197  if (phiName_ != "psi")
198  {
199  os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
200  }
201  os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
202  T0_.writeEntry("T0", os);
203  writeEntry("value", os);
204 }
205 
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 namespace Foam
210 {
212  (
215  );
216 }
217 
218 // ************************ vim: set sw=4 sts=4 et: ************************ //