FreeFOAM The Cross-Platform CFD Toolkit
ePsiThermo.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 
26 #include "ePsiThermo.H"
27 #include <finiteVolume/fvMesh.H>
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class MixtureType>
34 {
35  const scalarField& eCells = e_.internalField();
36  const scalarField& pCells = this->p_.internalField();
37 
38  scalarField& TCells = this->T_.internalField();
39  scalarField& psiCells = this->psi_.internalField();
40  scalarField& muCells = this->mu_.internalField();
41  scalarField& alphaCells = this->alpha_.internalField();
42 
43  forAll(TCells, celli)
44  {
45  const typename MixtureType::thermoType& mixture_ =
46  this->cellMixture(celli);
47 
48  TCells[celli] = mixture_.TE(eCells[celli], TCells[celli]);
49  psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
50 
51  muCells[celli] = mixture_.mu(TCells[celli]);
52  alphaCells[celli] = mixture_.alpha(TCells[celli]);
53  }
54 
55  forAll(this->T_.boundaryField(), patchi)
56  {
57  fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
58  fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
59  fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
60 
61  fvPatchScalarField& pe = e_.boundaryField()[patchi];
62 
63  fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
64  fvPatchScalarField& palpha = this->alpha_.boundaryField()[patchi];
65 
66  if (pT.fixesValue())
67  {
68  forAll(pT, facei)
69  {
70  const typename MixtureType::thermoType& mixture_ =
71  this->patchFaceMixture(patchi, facei);
72 
73  pe[facei] = mixture_.E(pT[facei]);
74 
75  ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
76  pmu[facei] = mixture_.mu(pT[facei]);
77  palpha[facei] = mixture_.alpha(pT[facei]);
78  }
79  }
80  else
81  {
82  forAll(pT, facei)
83  {
84  const typename MixtureType::thermoType& mixture_ =
85  this->patchFaceMixture(patchi, facei);
86 
87  pT[facei] = mixture_.TE(pe[facei], pT[facei]);
88 
89  ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
90  pmu[facei] = mixture_.mu(pT[facei]);
91  palpha[facei] = mixture_.alpha(pT[facei]);
92  }
93  }
94  }
95 }
96 
97 
98 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
99 
100 template<class MixtureType>
102 :
103  basicPsiThermo(mesh),
104  MixtureType(*this, mesh),
105 
106  e_
107  (
108  IOobject
109  (
110  "e",
111  mesh.time().timeName(),
112  mesh,
113  IOobject::NO_READ,
114  IOobject::NO_WRITE
115  ),
116  mesh,
117  dimensionSet(0, 2, -2, 0, 0),
118  this->eBoundaryTypes()
119  )
120 {
121  scalarField& eCells = e_.internalField();
122  const scalarField& TCells = this->T_.internalField();
123 
124  forAll(eCells, celli)
125  {
126  eCells[celli] = this->cellMixture(celli).E(TCells[celli]);
127  }
128 
130  {
131  e_.boundaryField()[patchi] ==
132  e(this->T_.boundaryField()[patchi], patchi);
133  }
134 
135  this->eBoundaryCorrection(e_);
136 
137  calculate();
138 
139  // Switch on saving old time
140  this->psi_.oldTime();
141 }
142 
143 
144 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
145 
146 template<class MixtureType>
148 {}
149 
150 
151 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152 
153 template<class MixtureType>
155 {
156  if (debug)
157  {
158  Info<< "entering ePsiThermo<MixtureType>::correct()" << endl;
159  }
160 
161  // force the saving of the old-time values
162  this->psi_.oldTime();
163 
164  calculate();
165 
166  if (debug)
167  {
168  Info<< "exiting ePsiThermo<MixtureType>::correct()" << endl;
169  }
170 }
171 
172 
173 template<class MixtureType>
175 (
176  const scalarField& T,
177  const labelList& cells
178 ) const
179 {
180  tmp<scalarField> te(new scalarField(T.size()));
181  scalarField& h = te();
182 
183  forAll(T, celli)
184  {
185  h[celli] = this->cellMixture(cells[celli]).E(T[celli]);
186  }
187 
188  return te;
189 }
190 
191 
192 template<class MixtureType>
194 (
195  const scalarField& T,
196  const label patchi
197 ) const
198 {
199  tmp<scalarField> te(new scalarField(T.size()));
200  scalarField& h = te();
201 
202  forAll(T, facei)
203  {
204  h[facei] = this->patchFaceMixture(patchi, facei).E(T[facei]);
205  }
206 
207  return te;
208 }
209 
210 
211 template<class MixtureType>
213 (
214  const scalarField& T,
215  const label patchi
216 ) const
217 {
218  tmp<scalarField> tCp(new scalarField(T.size()));
219  scalarField& cp = tCp();
220 
221  forAll(T, facei)
222  {
223  cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
224  }
225 
226  return tCp;
227 }
228 
229 
230 template<class MixtureType>
232 {
233  const fvMesh& mesh = this->T_.mesh();
234 
236  (
237  new volScalarField
238  (
239  IOobject
240  (
241  "Cp",
242  mesh.time().timeName(),
243  mesh,
246  ),
247  mesh,
248  dimensionSet(0, 2, -2, -1, 0)
249  )
250  );
251 
252  volScalarField& cp = tCp();
253 
254  forAll(this->T_, celli)
255  {
256  cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
257  }
258 
259  forAll(this->T_.boundaryField(), patchi)
260  {
261  const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
263 
264  forAll(pT, facei)
265  {
266  pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
267  }
268  }
269 
270  return tCp;
271 }
272 
273 
274 template<class MixtureType>
276 (
277  const scalarField& T,
278  const label patchi
279 ) const
280 {
281  tmp<scalarField> tCv(new scalarField(T.size()));
282  scalarField& cv = tCv();
283 
284  forAll(T, facei)
285  {
286  cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
287  }
288 
289  return tCv;
290 }
291 
292 
293 template<class MixtureType>
295 {
296  const fvMesh& mesh = this->T_.mesh();
297 
299  (
300  new volScalarField
301  (
302  IOobject
303  (
304  "Cv",
305  mesh.time().timeName(),
306  mesh,
309  ),
310  mesh,
311  dimensionSet(0, 2, -2, -1, 0)
312  )
313  );
314 
315  volScalarField& cv = tCv();
316 
317  forAll(this->T_, celli)
318  {
319  cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
320  }
321 
322  forAll(this->T_.boundaryField(), patchi)
323  {
324  cv.boundaryField()[patchi] =
325  Cv(this->T_.boundaryField()[patchi], patchi);
326  }
327 
328  return tCv;
329 }
330 
331 
332 template<class MixtureType>
334 {
335  if (basicPsiThermo::read())
336  {
337  MixtureType::read(*this);
338  return true;
339  }
340  else
341  {
342  return false;
343  }
344 }
345 
346 
347 // ************************ vim: set sw=4 sts=4 et: ************************ //