FreeFOAM The Cross-Platform CFD Toolkit
hsRhoThermo.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) 2010-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 "hsRhoThermo.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class MixtureType>
32 {
33  const scalarField& hsCells = this->hs_.internalField();
34  const scalarField& pCells = this->p_.internalField();
35 
36  scalarField& TCells = this->T_.internalField();
37  scalarField& psiCells = this->psi_.internalField();
38  scalarField& rhoCells = this->rho_.internalField();
39  scalarField& muCells = this->mu_.internalField();
40  scalarField& alphaCells = this->alpha_.internalField();
41 
42  forAll(TCells, celli)
43  {
44  const typename MixtureType::thermoType& mixture_ =
45  this->cellMixture(celli);
46 
47  TCells[celli] = mixture_.THs(hsCells[celli], TCells[celli]);
48  psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
49  rhoCells[celli] = mixture_.rho(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  fvPatchScalarField& prho = this->rho_.boundaryField()[patchi];
61 
62  fvPatchScalarField& phs = this->hs_.boundaryField()[patchi];
63 
64  fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
65  fvPatchScalarField& palpha = this->alpha_.boundaryField()[patchi];
66 
67  if (pT.fixesValue())
68  {
69  forAll(pT, facei)
70  {
71  const typename MixtureType::thermoType& mixture_ =
72  this->patchFaceMixture(patchi, facei);
73 
74  phs[facei] = mixture_.Hs(pT[facei]);
75 
76  ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
77  prho[facei] = mixture_.rho(pp[facei], pT[facei]);
78  pmu[facei] = mixture_.mu(pT[facei]);
79  palpha[facei] = mixture_.alpha(pT[facei]);
80  }
81  }
82  else
83  {
84  forAll(pT, facei)
85  {
86  const typename MixtureType::thermoType& mixture_ =
87  this->patchFaceMixture(patchi, facei);
88 
89  pT[facei] = mixture_.THs(phs[facei], pT[facei]);
90 
91  ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
92  prho[facei] = mixture_.rho(pp[facei], pT[facei]);
93  pmu[facei] = mixture_.mu(pT[facei]);
94  palpha[facei] = mixture_.alpha(pT[facei]);
95  }
96  }
97  }
98 }
99 
100 
101 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
102 
103 template<class MixtureType>
105 :
106  basicRhoThermo(mesh),
107  MixtureType(*this, mesh),
108 
109  hs_
110  (
111  IOobject
112  (
113  "hs",
114  mesh.time().timeName(),
115  mesh,
116  IOobject::NO_READ,
117  IOobject::NO_WRITE
118  ),
119  mesh,
121  this->hBoundaryTypes()
122  )
123 {
124  scalarField& hsCells = hs_.internalField();
125  const scalarField& TCells = this->T_.internalField();
126 
127  forAll(hsCells, celli)
128  {
129  hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
130  }
131 
132  forAll(hs_.boundaryField(), patchi)
133  {
134  hs_.boundaryField()[patchi] ==
135  hs(this->T_.boundaryField()[patchi], patchi);
136  }
137 
138  hBoundaryCorrection(hs_);
139 
140  calculate();
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 hsRhoThermo<MixtureType>::correct()" << endl;
159  }
160 
161  calculate();
162 
163  if (debug)
164  {
165  Info<< "exiting hsRhoThermo<MixtureType>::correct()" << endl;
166  }
167 }
168 
169 
170 template<class MixtureType>
172 (
173  const scalarField& T,
174  const labelList& cells
175 ) const
176 {
177  tmp<scalarField> ths(new scalarField(T.size()));
178  scalarField& hs = ths();
179 
180  forAll(T, celli)
181  {
182  hs[celli] = this->cellMixture(cells[celli]).Hs(T[celli]);
183  }
184 
185  return ths;
186 }
187 
188 
189 template<class MixtureType>
191 (
192  const scalarField& T,
193  const label patchi
194 ) const
195 {
196  tmp<scalarField> ths(new scalarField(T.size()));
197  scalarField& hs = ths();
198 
199  forAll(T, facei)
200  {
201  hs[facei] = this->patchFaceMixture(patchi, facei).Hs(T[facei]);
202  }
203 
204  return ths;
205 }
206 
207 
208 template<class MixtureType>
210 (
211  const scalarField& T,
212  const label patchi
213 ) const
214 {
215  tmp<scalarField> tCp(new scalarField(T.size()));
216  scalarField& cp = tCp();
217 
218  forAll(T, facei)
219  {
220  cp[facei] = this->patchFaceMixture(patchi, facei).Cp(T[facei]);
221  }
222 
223  return tCp;
224 }
225 
226 
227 template<class MixtureType>
229 {
230  const fvMesh& mesh = this->T_.mesh();
231 
233  (
234  new volScalarField
235  (
236  IOobject
237  (
238  "Cp",
239  mesh.time().timeName(),
240  mesh,
243  ),
244  mesh,
246  )
247  );
248 
249  volScalarField& cp = tCp();
250 
251  forAll(this->T_, celli)
252  {
253  cp[celli] = this->cellMixture(celli).Cp(this->T_[celli]);
254  }
255 
256  forAll(this->T_.boundaryField(), patchi)
257  {
258  const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
259  fvPatchScalarField& pCp = cp.boundaryField()[patchi];
260 
261  forAll(pT, facei)
262  {
263  pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
264  }
265  }
266 
267  return tCp;
268 }
269 
270 
271 template<class MixtureType>
273 (
274  const scalarField& T,
275  const label patchi
276 ) const
277 {
278  tmp<scalarField> tCv(new scalarField(T.size()));
279  scalarField& cv = tCv();
280 
281  forAll(T, facei)
282  {
283  cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
284  }
285 
286  return tCv;
287 }
288 
289 
290 template<class MixtureType>
292 {
293  const fvMesh& mesh = this->T_.mesh();
294 
296  (
297  new volScalarField
298  (
299  IOobject
300  (
301  "Cv",
302  mesh.time().timeName(),
303  mesh,
306  ),
307  mesh,
309  )
310  );
311 
312  volScalarField& cv = tCv();
313 
314  forAll(this->T_, celli)
315  {
316  cv[celli] = this->cellMixture(celli).Cv(this->T_[celli]);
317  }
318 
319  forAll(this->T_.boundaryField(), patchi)
320  {
321  cv.boundaryField()[patchi] =
322  Cv(this->T_.boundaryField()[patchi], patchi);
323  }
324 
325  return tCv;
326 }
327 
328 
329 template<class MixtureType>
331 {
332  if (basicRhoThermo::read())
333  {
334  MixtureType::read(*this);
335  return true;
336  }
337  else
338  {
339  return false;
340  }
341 }
342 
343 
344 // ************************ vim: set sw=4 sts=4 et: ************************ //