FreeFOAM The Cross-Platform CFD Toolkit
totalTemperatureFvPatchScalarField.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-2010 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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
37 (
38  const fvPatch& p,
40 )
41 :
42  fixedValueFvPatchScalarField(p, iF),
43  UName_("U"),
44  phiName_("phi"),
45  psiName_("psi"),
46  gamma_(0.0),
47  T0_(p.size(), 0.0)
48 {}
49 
50 
52 (
54  const fvPatch& p,
56  const fvPatchFieldMapper& mapper
57 )
58 :
59  fixedValueFvPatchScalarField(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 
69 (
70  const fvPatch& p,
72  const dictionary& dict
73 )
74 :
75  fixedValueFvPatchScalarField(p, iF),
76  UName_(dict.lookupOrDefault<word>("U", "U")),
77  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
78  psiName_(dict.lookupOrDefault<word>("psi", "psi")),
79  gamma_(readScalar(dict.lookup("gamma"))),
80  T0_("T0", dict, p.size())
81 {
82  if (dict.found("value"))
83  {
85  (
86  scalarField("value", dict, p.size())
87  );
88  }
89  else
90  {
92  }
93 }
94 
95 
97 (
99 )
100 :
101  fixedValueFvPatchScalarField(tppsf),
102  UName_(tppsf.UName_),
103  phiName_(tppsf.phiName_),
104  psiName_(tppsf.psiName_),
105  gamma_(tppsf.gamma_),
106  T0_(tppsf.T0_)
107 {}
108 
109 
111 (
114 )
115 :
116  fixedValueFvPatchScalarField(tppsf, iF),
117  UName_(tppsf.UName_),
118  phiName_(tppsf.phiName_),
119  psiName_(tppsf.psiName_),
120  gamma_(tppsf.gamma_),
121  T0_(tppsf.T0_)
122 {}
123 
124 
125 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126 
128 (
129  const fvPatchFieldMapper& m
130 )
131 {
132  fixedValueFvPatchScalarField::autoMap(m);
133  T0_.autoMap(m);
134 }
135 
136 
138 (
139  const fvPatchScalarField& ptf,
140  const labelList& addr
141 )
142 {
143  fixedValueFvPatchScalarField::rmap(ptf, addr);
144 
146  refCast<const totalTemperatureFvPatchScalarField>(ptf);
147 
148  T0_.rmap(tiptf.T0_, addr);
149 }
150 
151 
153 {
154  if (updated())
155  {
156  return;
157  }
158 
159  const fvPatchVectorField& Up =
160  patch().lookupPatchField<volVectorField, vector>(UName_);
161 
162  const fvsPatchField<scalar>& phip =
163  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
164 
165  const fvPatchField<scalar>& psip =
166  patch().lookupPatchField<volScalarField, scalar>(psiName_);
167 
168  scalar gM1ByG = (gamma_ - 1.0)/gamma_;
169 
170  operator==
171  (
172  T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up))
173  );
174 
176 }
177 
178 
180 {
182  if (UName_ != "U")
183  {
184  os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
185  }
186  if (phiName_ != "phi")
187  {
188  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
189  }
190  if (psiName_ != "psi")
191  {
192  os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
193  }
194  os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
195  T0_.writeEntry("T0", os);
196  writeEntry("value", os);
197 }
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 namespace Foam
203 {
205  (
208  );
209 }
210 
211 // ************************ vim: set sw=4 sts=4 et: ************************ //