heheuPsiThermo.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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 "heheuPsiThermo.H"
27 #include "fvMesh.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class BasicPsiThermo, class MixtureType>
34 {
35  const scalarField& hCells = this->he_;
36  const scalarField& heuCells = this->heu_;
37  const scalarField& pCells = this->p_;
38 
39  scalarField& TCells = this->T_.primitiveFieldRef();
40  scalarField& TuCells = this->Tu_.primitiveFieldRef();
41  scalarField& psiCells = this->psi_.primitiveFieldRef();
42  scalarField& muCells = this->mu_.primitiveFieldRef();
43  scalarField& alphaCells = this->alpha_.primitiveFieldRef();
44 
45  forAll(TCells, celli)
46  {
47  const typename MixtureType::thermoType& mixture_ =
48  this->cellMixture(celli);
49 
50  TCells[celli] = mixture_.THE
51  (
52  hCells[celli],
53  pCells[celli],
54  TCells[celli]
55  );
56 
57  psiCells[celli] = mixture_.psi(pCells[celli], TCells[celli]);
58 
59  muCells[celli] = mixture_.mu(pCells[celli], TCells[celli]);
60  alphaCells[celli] = mixture_.alphah(pCells[celli], TCells[celli]);
61 
62  TuCells[celli] = this->cellReactants(celli).THE
63  (
64  heuCells[celli],
65  pCells[celli],
66  TuCells[celli]
67  );
68  }
69 
70  volScalarField::Boundary& pBf =
71  this->p_.boundaryFieldRef();
72 
73  volScalarField::Boundary& TBf =
74  this->T_.boundaryFieldRef();
75 
76  volScalarField::Boundary& TuBf =
77  this->Tu_.boundaryFieldRef();
78 
79  volScalarField::Boundary& psiBf =
80  this->psi_.boundaryFieldRef();
81 
82  volScalarField::Boundary& heBf =
83  this->he().boundaryFieldRef();
84 
85  volScalarField::Boundary& heuBf =
86  this->heu().boundaryFieldRef();
87 
88  volScalarField::Boundary& muBf =
89  this->mu_.boundaryFieldRef();
90 
91  volScalarField::Boundary& alphaBf =
92  this->alpha_.boundaryFieldRef();
93 
94  forAll(this->T_.boundaryField(), patchi)
95  {
96  fvPatchScalarField& pp = pBf[patchi];
97  fvPatchScalarField& pT = TBf[patchi];
98  fvPatchScalarField& pTu = TuBf[patchi];
99  fvPatchScalarField& ppsi = psiBf[patchi];
100  fvPatchScalarField& phe = heBf[patchi];
101  fvPatchScalarField& pheu = heuBf[patchi];
102  fvPatchScalarField& pmu = muBf[patchi];
103  fvPatchScalarField& palpha = alphaBf[patchi];
104 
105  if (pT.fixesValue())
106  {
107  forAll(pT, facei)
108  {
109  const typename MixtureType::thermoType& mixture_ =
110  this->patchFaceMixture(patchi, facei);
111 
112  phe[facei] = mixture_.HE(pp[facei], pT[facei]);
113 
114  ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
115  pmu[facei] = mixture_.mu(pp[facei], pT[facei]);
116  palpha[facei] = mixture_.alphah(pp[facei], pT[facei]);
117  }
118  }
119  else
120  {
121  forAll(pT, facei)
122  {
123  const typename MixtureType::thermoType& mixture_ =
124  this->patchFaceMixture(patchi, facei);
125 
126  pT[facei] = mixture_.THE(phe[facei], pp[facei], pT[facei]);
127 
128  ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
129  pmu[facei] = mixture_.mu(pp[facei], pT[facei]);
130  palpha[facei] = mixture_.alphah(pp[facei], pT[facei]);
131 
132  pTu[facei] =
133  this->patchFaceReactants(patchi, facei)
134  .THE(pheu[facei], pp[facei], pTu[facei]);
135  }
136  }
137  }
138 }
139 
140 
141 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
142 
143 template<class BasicPsiThermo, class MixtureType>
145 (
146  const fvMesh& mesh,
147  const word& phaseName
148 )
149 :
151  Tu_
152  (
153  IOobject
154  (
155  "Tu",
156  mesh.time().timeName(),
157  mesh,
158  IOobject::MUST_READ,
159  IOobject::AUTO_WRITE
160  ),
161  mesh
162  ),
163 
164  heu_
165  (
166  IOobject
167  (
168  MixtureType::thermoType::heName() + 'u',
169  mesh.time().timeName(),
170  mesh,
171  IOobject::NO_READ,
172  IOobject::NO_WRITE
173  ),
174  mesh,
175  dimensionSet(0, 2, -2, 0, 0),
176  this->heuBoundaryTypes()
177  )
178 {
179  scalarField& heuCells = this->heu_.primitiveFieldRef();
180  const scalarField& pCells = this->p_;
181  const scalarField& TuCells = this->Tu_;
182 
183  forAll(heuCells, celli)
184  {
185  heuCells[celli] = this->cellReactants(celli).HE
186  (
187  pCells[celli],
188  TuCells[celli]
189  );
190  }
191 
192  volScalarField::Boundary& heuBf = heu_.boundaryFieldRef();
193 
194  forAll(heuBf, patchi)
195  {
196  fvPatchScalarField& pheu = heuBf[patchi];
197  const fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
198  const fvPatchScalarField& pTu = this->Tu_.boundaryField()[patchi];
199 
200  forAll(pheu, facei)
201  {
202  pheu[facei] = this->patchFaceReactants(patchi, facei).HE
203  (
204  pp[facei],
205  pTu[facei]
206  );
207  }
208  }
209 
210  this->heuBoundaryCorrection(this->heu_);
211 
212  calculate();
213  this->psi_.oldTime(); // Switch on saving old time
214 }
215 
216 
217 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
218 
219 template<class BasicPsiThermo, class MixtureType>
221 {}
222 
223 
224 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
225 
226 template<class BasicPsiThermo, class MixtureType>
228 {
229  if (debug)
230  {
231  InfoInFunction << endl;
232  }
233 
234  // force the saving of the old-time values
235  this->psi_.oldTime();
236 
237  calculate();
238 
239  if (debug)
240  {
241  Info<< " Finished" << endl;
242  }
243 }
244 
245 
246 template<class BasicPsiThermo, class MixtureType>
249 (
250  const scalarField& p,
251  const scalarField& Tu,
252  const labelList& cells
253 ) const
254 {
255  tmp<scalarField> theu(new scalarField(Tu.size()));
256  scalarField& heu = theu.ref();
257 
258  forAll(Tu, celli)
259  {
260  heu[celli] = this->cellReactants(cells[celli]).HE(p[celli], Tu[celli]);
261  }
262 
263  return theu;
264 }
265 
266 
267 template<class BasicPsiThermo, class MixtureType>
270 (
271  const scalarField& p,
272  const scalarField& Tu,
273  const label patchi
274 ) const
275 {
276  tmp<scalarField> theu(new scalarField(Tu.size()));
277  scalarField& heu = theu.ref();
278 
279  forAll(Tu, facei)
280  {
281  heu[facei] =
282  this->patchFaceReactants(patchi, facei).HE(p[facei], Tu[facei]);
283  }
284 
285  return theu;
286 }
287 
288 
289 template<class BasicPsiThermo, class MixtureType>
292 {
293  tmp<volScalarField> tTb(volScalarField::New("Tb", this->T_));
294 
295  volScalarField& Tb_ = tTb.ref();
296  scalarField& TbCells = Tb_.primitiveFieldRef();
297  const scalarField& pCells = this->p_;
298  const scalarField& TCells = this->T_;
299  const scalarField& hCells = this->he_;
300 
301  forAll(TbCells, celli)
302  {
303  TbCells[celli] = this->cellProducts(celli).THE
304  (
305  hCells[celli],
306  pCells[celli],
307  TCells[celli]
308  );
309  }
310 
311  volScalarField::Boundary& TbBf = Tb_.boundaryFieldRef();
312 
313  forAll(TbBf, patchi)
314  {
315  fvPatchScalarField& pTb = TbBf[patchi];
316 
317  const fvPatchScalarField& ph = this->he_.boundaryField()[patchi];
318  const fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
319  const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
320 
321  forAll(pTb, facei)
322  {
323  pTb[facei] =
324  this->patchFaceProducts(patchi, facei)
325  .THE(ph[facei], pp[facei], pT[facei]);
326  }
327  }
328 
329  return tTb;
330 }
331 
332 
333 template<class BasicPsiThermo, class MixtureType>
336 {
337  tmp<volScalarField> tpsiu
338  (
340  (
341  "psiu",
342  this->psi_.mesh(),
343  this->psi_.dimensions()
344  )
345  );
346 
347  volScalarField& psiu = tpsiu.ref();
348  scalarField& psiuCells = psiu.primitiveFieldRef();
349  const scalarField& TuCells = this->Tu_;
350  const scalarField& pCells = this->p_;
351 
352  forAll(psiuCells, celli)
353  {
354  psiuCells[celli] =
355  this->cellReactants(celli).psi(pCells[celli], TuCells[celli]);
356  }
357 
358  volScalarField::Boundary& psiuBf = psiu.boundaryFieldRef();
359 
360  forAll(psiuBf, patchi)
361  {
362  fvPatchScalarField& ppsiu = psiuBf[patchi];
363 
364  const fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
365  const fvPatchScalarField& pTu = this->Tu_.boundaryField()[patchi];
366 
367  forAll(ppsiu, facei)
368  {
369  ppsiu[facei] =
370  this->
371  patchFaceReactants(patchi, facei).psi(pp[facei], pTu[facei]);
372  }
373  }
374 
375  return tpsiu;
376 }
377 
378 
379 template<class BasicPsiThermo, class MixtureType>
382 {
383  tmp<volScalarField> tpsib
384  (
386  (
387  "psib",
388  this->psi_.mesh(),
389  this->psi_.dimensions()
390  )
391  );
392 
393  volScalarField& psib = tpsib.ref();
394  scalarField& psibCells = psib.primitiveFieldRef();
395  const volScalarField Tb_(Tb());
396  const scalarField& TbCells = Tb_;
397  const scalarField& pCells = this->p_;
398 
399  forAll(psibCells, celli)
400  {
401  psibCells[celli] =
402  this->cellReactants(celli).psi(pCells[celli], TbCells[celli]);
403  }
404 
405  volScalarField::Boundary& psibBf = psib.boundaryFieldRef();
406 
407  forAll(psibBf, patchi)
408  {
409  fvPatchScalarField& ppsib = psibBf[patchi];
410 
411  const fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
412  const fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
413 
414  forAll(ppsib, facei)
415  {
416  ppsib[facei] =
417  this->patchFaceReactants
418  (patchi, facei).psi(pp[facei], pTb[facei]);
419  }
420  }
421 
422  return tpsib;
423 }
424 
425 
426 template<class BasicPsiThermo, class MixtureType>
429 {
431  (
433  (
434  "muu",
435  this->T_.mesh(),
436  dimensionSet(1, -1, -1, 0, 0)
437  )
438  );
439 
440  volScalarField& muu_ = tmuu.ref();
441  scalarField& muuCells = muu_.primitiveFieldRef();
442  const scalarField& pCells = this->p_;
443  const scalarField& TuCells = this->Tu_;
444 
445  forAll(muuCells, celli)
446  {
447  muuCells[celli] = this->cellReactants(celli).mu
448  (
449  pCells[celli],
450  TuCells[celli]
451  );
452  }
453 
454  volScalarField::Boundary& muuBf = muu_.boundaryFieldRef();
455 
456  forAll(muuBf, patchi)
457  {
458  fvPatchScalarField& pMuu = muuBf[patchi];
459  const fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
460  const fvPatchScalarField& pTu = this->Tu_.boundaryField()[patchi];
461 
462  forAll(pMuu, facei)
463  {
464  pMuu[facei] = this->patchFaceReactants(patchi, facei).mu
465  (
466  pp[facei],
467  pTu[facei]
468  );
469  }
470  }
471 
472  return tmuu;
473 }
474 
475 
476 template<class BasicPsiThermo, class MixtureType>
479 {
481  (
483  (
484  "mub",
485  this->T_.mesh(),
486  dimensionSet(1, -1, -1, 0, 0)
487  )
488  );
489 
490  volScalarField& mub_ = tmub.ref();
491  scalarField& mubCells = mub_.primitiveFieldRef();
492  const volScalarField Tb_(Tb());
493  const scalarField& pCells = this->p_;
494  const scalarField& TbCells = Tb_;
495 
496  forAll(mubCells, celli)
497  {
498  mubCells[celli] = this->cellProducts(celli).mu
499  (
500  pCells[celli],
501  TbCells[celli]
502  );
503  }
504 
505  volScalarField::Boundary& mubBf = mub_.boundaryFieldRef();
506 
507  forAll(mubBf, patchi)
508  {
509  fvPatchScalarField& pMub = mubBf[patchi];
510  const fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
511  const fvPatchScalarField& pTb = Tb_.boundaryField()[patchi];
512 
513  forAll(pMub, facei)
514  {
515  pMub[facei] = this->patchFaceProducts(patchi, facei).mu
516  (
517  pp[facei],
518  pTb[facei]
519  );
520  }
521  }
522 
523  return tmub;
524 }
525 
526 
527 // ************************************************************************* //
volScalarField & he
Definition: YEEqn.H:50
virtual tmp< volScalarField > mub() const
Dynamic viscosity of burnt gas [kg/m/s].
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
virtual tmp< volScalarField > psiu() const
Unburnt gas compressibility [s^2/m^2].
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual tmp< volScalarField > Tb() const
Burnt gas temperature [K].
const Boundary & boundaryField() const
Return const-reference to the boundary field.
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
virtual tmp< volScalarField > psib() const
Burnt gas compressibility [s^2/m^2].
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual tmp< volScalarField > muu() const
Dynamic viscosity of unburnt gas [kg/m/s].
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Dimension set for the base types.
Definition: dimensionSet.H:120
dynamicFvMesh & mesh
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from string.
Definition: word.H:59
virtual void correct()
Update properties.
volScalarField scalarField(fieldObject, mesh)
virtual ~heheuPsiThermo()
Destructor.
Internal::FieldType & primitiveFieldRef()
Return a reference to the internal field.
label patchi
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
Enthalpy/Internal energy for a mixture.
Definition: heThermo.H:49
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
A class for managing temporary objects.
Definition: PtrList.H:53
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
virtual volScalarField & heu()
Unburnt gas enthalpy [J/kg].
#define InfoInFunction
Report an information message using Foam::Info.