heThermo.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-2022 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 "heThermo.H"
29 
30 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
31 
32 template<class BasicThermo, class MixtureType>
33 template
34 <
35  class CellMixture,
36  class PatchFaceMixture,
37  class Method,
38  class ... Args
39 >
42 (
43  const word& psiName,
44  const dimensionSet& psiDim,
45  CellMixture cellMixture,
46  PatchFaceMixture patchFaceMixture,
47  Method psiMethod,
48  const Args& ... args
49 ) const
50 {
52  (
54  (
55  IOobject::groupName(psiName, this->group()),
56  this->T_.mesh(),
57  psiDim
58  )
59  );
60 
61  volScalarField& psi = tPsi.ref();
62 
63  forAll(this->T_, celli)
64  {
65  psi[celli] = ((this->*cellMixture)(celli).*psiMethod)(args[celli] ...);
66  }
67 
69 
70  forAll(psiBf, patchi)
71  {
72  fvPatchScalarField& pPsi = psiBf[patchi];
73 
74  forAll(this->T_.boundaryField()[patchi], facei)
75  {
76  pPsi[facei] =
77  ((this->*patchFaceMixture)(patchi, facei).*psiMethod)
78  (
79  args.boundaryField()[patchi][facei] ...
80  );
81  }
82  }
83 
84  return tPsi;
85 }
86 
87 
88 template<class BasicThermo, class MixtureType>
89 template<class CellMixture, class Method, class ... Args>
92 (
93  CellMixture cellMixture,
94  Method psiMethod,
95  const labelList& cells,
96  const Args& ... args
97 ) const
98 {
99  // Note: Args are fields for the set, not for the mesh as a whole. The
100  // cells list is only used to get the mixture.
101 
102  tmp<scalarField> tPsi(new scalarField(cells.size()));
103  scalarField& psi = tPsi.ref();
104 
105  forAll(cells, celli)
106  {
107  psi[celli] =
108  ((this->*cellMixture)(cells[celli]).*psiMethod)(args[celli] ...);
109  }
110 
111  return tPsi;
112 }
113 
114 
115 template<class BasicThermo, class MixtureType>
116 template<class PatchFaceMixture, class Method, class ... Args>
119 (
120  PatchFaceMixture patchFaceMixture,
121  Method psiMethod,
122  const label patchi,
123  const Args& ... args
124 ) const
125 {
126  tmp<scalarField> tPsi
127  (
128  new scalarField(this->T_.boundaryField()[patchi].size())
129  );
130  scalarField& psi = tPsi.ref();
131 
132  forAll(this->T_.boundaryField()[patchi], facei)
133  {
134  psi[facei] =
135  ((this->*patchFaceMixture)(patchi, facei).*psiMethod)
136  (
137  args[facei] ...
138  );
139  }
140 
141  return tPsi;
142 }
143 
144 
145 template<class BasicThermo, class MixtureType>
148 (
149  const volScalarField& psi,
150  const labelList& cells
151 )
152 {
154 }
155 
156 
157 template<class BasicThermo, class MixtureType>
160 (
161  const uniformGeometricScalarField& psi,
162  const labelList&
163 )
164 {
165  return psi.primitiveField();
166 }
167 
168 
169 template<class BasicThermo, class MixtureType>
172 {
174 
175  forAll(hBf, patchi)
176  {
177  if (isA<gradientEnergyFvPatchScalarField>(hBf[patchi]))
178  {
179  refCast<gradientEnergyFvPatchScalarField>(hBf[patchi]).gradient()
180  = hBf[patchi].fvPatchField::snGrad();
181  }
182  else if (isA<mixedEnergyFvPatchScalarField>(hBf[patchi]))
183  {
184  refCast<mixedEnergyFvPatchScalarField>(hBf[patchi]).refGrad()
185  = hBf[patchi].fvPatchField::snGrad();
186  }
187  }
188 }
189 
190 
191 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
192 
193 template<class BasicThermo, class MixtureType>
195 (
196  const fvMesh& mesh,
197  const word& phaseName
198 )
199 :
200  BasicThermo(mesh, phaseName),
201  MixtureType(*this, mesh, phaseName),
202 
203  he_
204  (
205  IOobject
206  (
207  BasicThermo::phasePropertyName
208  (
209  MixtureType::thermoType::heName(),
210  phaseName
211  ),
212  mesh.time().timeName(),
213  mesh,
214  IOobject::NO_READ,
215  IOobject::NO_WRITE
216  ),
217  volScalarFieldProperty
218  (
219  "he",
221  &MixtureType::cellThermoMixture,
222  &MixtureType::patchFaceThermoMixture,
223  &MixtureType::thermoMixtureType::HE,
224  this->p_,
225  this->T_
226  ),
227  this->heBoundaryTypes(),
228  this->heBoundaryBaseTypes()
229  ),
230 
231  Cp_
232  (
233  IOobject
234  (
235  BasicThermo::phasePropertyName("Cp", phaseName),
236  mesh.time().timeName(),
237  mesh
238  ),
239  mesh,
241  ),
242 
243  Cv_
244  (
245  IOobject
246  (
247  BasicThermo::phasePropertyName("Cv", phaseName),
248  mesh.time().timeName(),
249  mesh
250  ),
251  mesh,
253  )
254 {
255  heBoundaryCorrection(he_);
256 }
257 
258 
259 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
260 
261 template<class BasicThermo, class MixtureType>
263 {}
264 
265 
266 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
267 
268 template<class BasicThermo, class MixtureType>
270 (
271  const volScalarField& p,
272  const volScalarField& T
273 ) const
274 {
275  return volScalarFieldProperty
276  (
277  "he",
279  &MixtureType::cellThermoMixture,
280  &MixtureType::patchFaceThermoMixture,
281  &MixtureType::thermoMixtureType::HE,
282  p,
283  T
284  );
285 }
286 
287 
288 template<class BasicThermo, class MixtureType>
290 (
291  const scalarField& T,
292  const labelList& cells
293 ) const
294 {
295  return cellSetProperty
296  (
297  &MixtureType::cellThermoMixture,
298  &MixtureType::thermoMixtureType::HE,
299  cells,
300  cellSetScalarList(this->p_, cells),
301  T
302  );
303 }
304 
305 
306 template<class BasicThermo, class MixtureType>
308 (
309  const scalarField& T,
310  const label patchi
311 ) const
312 {
313  return patchFieldProperty
314  (
315  &MixtureType::patchFaceThermoMixture,
316  &MixtureType::thermoMixtureType::HE,
317  patchi,
318  this->p_.boundaryField()[patchi],
319  T
320  );
321 }
322 
323 
324 template<class BasicThermo, class MixtureType>
327 {
328  return volScalarFieldProperty
329  (
330  "hs",
332  &MixtureType::cellThermoMixture,
333  &MixtureType::patchFaceThermoMixture,
335  this->p_,
336  this->T_
337  );
338 }
339 
340 
341 template<class BasicThermo, class MixtureType>
343 (
344  const volScalarField& p,
345  const volScalarField& T
346 ) const
347 {
348  return volScalarFieldProperty
349  (
350  "hs",
352  &MixtureType::cellThermoMixture,
353  &MixtureType::patchFaceThermoMixture,
355  p,
356  T
357  );
358 }
359 
360 
361 template<class BasicThermo, class MixtureType>
363 (
364  const scalarField& T,
365  const labelList& cells
366 ) const
367 {
368  return cellSetProperty
369  (
370  &MixtureType::cellThermoMixture,
372  cells,
373  cellSetScalarList(this->p_, cells),
374  T
375  );
376 }
377 
378 
379 template<class BasicThermo, class MixtureType>
381 (
382  const scalarField& T,
383  const label patchi
384 ) const
385 {
386  return patchFieldProperty
387  (
388  &MixtureType::patchFaceThermoMixture,
390  patchi,
391  this->p_.boundaryField()[patchi],
392  T
393  );
394 }
395 
396 
397 template<class BasicThermo, class MixtureType>
400 {
401  return volScalarFieldProperty
402  (
403  "ha",
405  &MixtureType::cellThermoMixture,
406  &MixtureType::patchFaceThermoMixture,
408  this->p_,
409  this->T_
410  );
411 }
412 
413 
414 template<class BasicThermo, class MixtureType>
416 (
417  const volScalarField& p,
418  const volScalarField& T
419 ) const
420 {
421  return volScalarFieldProperty
422  (
423  "ha",
425  &MixtureType::cellThermoMixture,
426  &MixtureType::patchFaceThermoMixture,
428  p,
429  T
430  );
431 }
432 
433 
434 template<class BasicThermo, class MixtureType>
436 (
437  const scalarField& T,
438  const labelList& cells
439 ) const
440 {
441  return cellSetProperty
442  (
443  &MixtureType::cellThermoMixture,
445  cells,
446  cellSetScalarList(this->p_, cells),
447  T
448  );
449 }
450 
451 
452 template<class BasicThermo, class MixtureType>
454 (
455  const scalarField& T,
456  const label patchi
457 ) const
458 {
459  return patchFieldProperty
460  (
461  &MixtureType::patchFaceThermoMixture,
463  patchi,
464  this->p_.boundaryField()[patchi],
465  T
466  );
467 }
468 
469 
470 template<class BasicThermo, class MixtureType>
473 {
474  return volScalarFieldProperty
475  (
476  "hc",
478  &MixtureType::cellThermoMixture,
479  &MixtureType::patchFaceThermoMixture,
480  &MixtureType::thermoMixtureType::Hf
481  );
482 }
483 
484 
485 template<class BasicThermo, class MixtureType>
487 (
488  const scalarField& T,
489  const label patchi
490 ) const
491 {
492  return patchFieldProperty
493  (
494  &MixtureType::patchFaceThermoMixture,
496  patchi,
497  this->p_.boundaryField()[patchi],
498  T
499  );
500 }
501 
502 
503 template<class BasicThermo, class MixtureType>
506 (
507  const scalarField& T,
508  const label patchi
509 ) const
510 {
511  return patchFieldProperty
512  (
513  &MixtureType::patchFaceThermoMixture,
515  patchi,
516  this->p_.boundaryField()[patchi],
517  T
518  );
519 }
520 
521 
522 template<class BasicThermo, class MixtureType>
524 (
525  const scalarField& T,
526  const label patchi
527 ) const
528 {
529  return patchFieldProperty
530  (
531  &MixtureType::patchFaceThermoMixture,
532  &MixtureType::thermoMixtureType::gamma,
533  patchi,
534  this->p_.boundaryField()[patchi],
535  T
536  );
537 }
538 
539 
540 template<class BasicThermo, class MixtureType>
543 {
544  return volScalarField::New("gamma", Cp_/Cv_);
545 }
546 
547 
548 template<class BasicThermo, class MixtureType>
550 (
551  const scalarField& T,
552  const label patchi
553 ) const
554 {
555  if (MixtureType::thermoType::enthalpy())
556  {
557  return Cp(T, patchi);
558  }
559  else
560  {
561  return Cv(T, patchi);
562  }
563 }
564 
565 
566 template<class BasicThermo, class MixtureType>
569 {
570  if (MixtureType::thermoType::enthalpy())
571  {
572  return Cp_;
573  }
574  else
575  {
576  return Cv_;
577  }
578 }
579 
580 
581 template<class BasicThermo, class MixtureType>
583 (
584  const volScalarField& h,
585  const volScalarField& p,
586  const volScalarField& T0
587 ) const
588 {
589  return volScalarFieldProperty
590  (
591  "T",
593  &MixtureType::cellThermoMixture,
594  &MixtureType::patchFaceThermoMixture,
595  &MixtureType::thermoMixtureType::THE,
596  h,
597  p,
598  T0
599  );
600 }
601 
602 
603 template<class BasicThermo, class MixtureType>
605 (
606  const scalarField& h,
607  const scalarField& T0,
608  const labelList& cells
609 ) const
610 {
611  return cellSetProperty
612  (
613  &MixtureType::cellThermoMixture,
614  &MixtureType::thermoMixtureType::THE,
615  cells,
616  h,
617  cellSetScalarList(this->p_, cells),
618  T0
619  );
620 }
621 
622 
623 template<class BasicThermo, class MixtureType>
625 (
626  const scalarField& h,
627  const scalarField& T0,
628  const label patchi
629 ) const
630 {
631  return patchFieldProperty
632  (
633  &MixtureType::patchFaceThermoMixture,
634  &MixtureType::thermoMixtureType::THE,
635  patchi,
636  h,
637  this->p_.boundaryField()[patchi],
638  T0
639  );
640 }
641 
642 
643 template<class BasicThermo, class MixtureType>
646 {
647  return volScalarFieldProperty
648  (
649  "W",
651  &MixtureType::cellThermoMixture,
652  &MixtureType::patchFaceThermoMixture,
654  );
655 }
656 
657 
658 template<class BasicThermo, class MixtureType>
660 (
661  const label patchi
662 ) const
663 {
664  return patchFieldProperty
665  (
666  &MixtureType::patchFaceThermoMixture,
668  patchi
669  );
670 }
671 
672 
673 template<class BasicThermo, class MixtureType>
676 {
677  if (MixtureType::thermoType::enthalpy())
678  {
679  return volScalarField::New("alphahe", this->kappa_/Cp_);
680  }
681  else
682  {
683  return volScalarField::New("alphahe", this->kappa_/Cv_);
684  }
685 }
686 
687 
688 template<class BasicThermo, class MixtureType>
691 {
692  if (MixtureType::thermoType::enthalpy())
693  {
694  return this->kappa_.boundaryField()[patchi]/Cp_.boundaryField()[patchi];
695  }
696  else
697  {
698  return this->kappa_.boundaryField()[patchi]/Cv_.boundaryField()[patchi];
699  }
700 }
701 
702 
703 template<class BasicThermo, class MixtureType>
706 (
707  const volScalarField& alphat
708 ) const
709 {
710  return volScalarField::New("kappaEff", this->kappa_ + Cp_*alphat);
711 }
712 
713 
714 template<class BasicThermo, class MixtureType>
717 (
718  const scalarField& alphat,
719  const label patchi
720 ) const
721 {
722  return
723  this->kappa_.boundaryField()[patchi]
724  + Cp(this->T_.boundaryField()[patchi], patchi)*alphat;
725 }
726 
727 
728 template<class BasicThermo, class MixtureType>
731 (
732  const volScalarField& alphat
733 ) const
734 {
735  if (MixtureType::thermoType::enthalpy())
736  {
737  return volScalarField::New("alphaEff", this->kappa_/Cp_ + alphat);
738  }
739  else
740  {
741  return volScalarField::New
742  (
743  "alphaEff",
744  (this->kappa_ + Cp_*alphat)/Cv_
745  );
746  }
747 }
748 
749 
750 template<class BasicThermo, class MixtureType>
753 (
754  const scalarField& alphat,
755  const label patchi
756 ) const
757 {
758  if (MixtureType::thermoType::enthalpy())
759  {
760  return
761  this->kappa_.boundaryField()[patchi]/Cp_.boundaryField()[patchi]
762  + alphat;
763  }
764  else
765  {
766  return
767  (
768  this->kappa_.boundaryField()[patchi]
769  + Cp_.boundaryField()[patchi]*alphat
770  )/Cv_.boundaryField()[patchi];
771  }
772 }
773 
774 
775 template<class BasicThermo, class MixtureType>
777 {
778  if (BasicThermo::read())
779  {
780  MixtureType::read(*this);
781  return true;
782  }
783  else
784  {
785  return false;
786  }
787 }
788 
789 
790 // ************************************************************************* //
const char *const group
Group name for atomic constants.
A class representing the concept of a uniform field which stores only the single value and providing ...
Definition: UniformField.H:47
scalar Cv(const scalar p, const scalar T) const
Definition: HtoEthermo.H:2
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
virtual tmp< volScalarField > gamma() const
Gamma = Cp/Cv [].
Definition: heThermo.C:542
scalar Hs(const scalar p, const scalar T) const
Definition: EtoHthermo.H:11
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
virtual ~heThermo()
Destructor.
Definition: heThermo.C:262
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
virtual tmp< volScalarField > Cpv() const
Heat capacity at constant pressure/volume [J/kg/K].
Definition: heThermo.C:568
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:372
virtual volScalarField & he()
Enthalpy/Internal energy [J/kg].
Definition: heThermo.H:188
fvMesh & mesh
virtual tmp< volScalarField > hc() const
Enthalpy of formation [J/kg].
Definition: heThermo.C:472
Internal::FieldType primitiveField() const
tmp< scalarField > patchFieldProperty(PatchFaceMixture patchFaceMixture, Method psiMethod, const label patchi, const Args &... args) const
Return a scalarField of the given property on a patch.
Dimension set for the base types.
Definition: dimensionSet.H:121
const cellShapeList & cells
static word timeName(const scalar, const int precision=curPrecision_)
Return time name of given scalar time.
Definition: Time.C:666
A class for handling words, derived from string.
Definition: word.H:59
static UIndirectList< scalar > cellSetScalarList(const volScalarField &psi, const labelList &cells)
Return an indirect list of a field for the given set of cells.
Definition: heThermo.C:148
const volScalarField & psi
static const zero Zero
Definition: zero.H:97
virtual tmp< volScalarField > THE(const volScalarField &h, const volScalarField &p, const volScalarField &T0) const
Temperature from enthalpy/internal energy.
Definition: heThermo.C:583
virtual tmp< volScalarField > alphahe() const
Thermal diffusivity of energy of mixture [kg/m/s].
Definition: heThermo.C:675
virtual tmp< volScalarField > hs() const
Sensible enthalpy [J/kg/K].
Definition: heThermo.C:326
virtual tmp< volScalarField > ha() const
Absolute enthalpy [J/kg/K].
Definition: heThermo.C:399
volScalarField scalarField(fieldObject, mesh)
virtual tmp< volScalarField > alphaEff(const volScalarField &alphat) const
Effective turbulent thermal diffusivity of energy.
Definition: heThermo.C:731
virtual const volScalarField & Cv() const
Heat capacity at constant volume [J/kg/K].
Definition: heThermo.H:206
tmp< scalarField > cellSetProperty(CellMixture cellMixture, Method psiMethod, const labelList &cells, const Args &... args) const
Return a scalarField of the given property on a cell set.
const dimensionSet dimEnergy
const dimensionSet dimMass
const volScalarField & T
heThermo(const fvMesh &, const word &phaseName)
Construct from mesh.
Definition: heThermo.C:195
virtual bool read()
Read thermophysical properties dictionary.
Definition: heThermo.C:776
label patchi
virtual tmp< volScalarField > kappaEff(const volScalarField &) const
Effective thermal turbulent conductivity of mixture [W/m/K].
Definition: heThermo.C:706
const dimensionSet dimMoles
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
virtual const volScalarField & Cp() const
Heat capacity at constant pressure [J/kg/K].
Definition: heThermo.H:200
const scalarList W(::W(thermo))
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
A List with indirect addressing.
Definition: fvMatrix.H:106
scalar Cp(const scalar p, const scalar T) const
Definition: EtoHthermo.H:2
scalar Ha(const scalar p, const scalar T) const
Definition: EtoHthermo.H:20
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:98
void heBoundaryCorrection(volScalarField &he)
Correct the enthalpy/internal energy field boundaries.
Definition: heThermo.C:171
tmp< volScalarField > volScalarFieldProperty(const word &psiName, const dimensionSet &psiDim, CellMixture cellMixture, PatchFaceMixture patchFaceMixture, Method psiMethod, const Args &... args) const
Return a volScalarField of the given property.
const dimensionSet dimTemperature
virtual tmp< volScalarField > W() const
Molecular weight [kg/kmol].
Definition: heThermo.C:645
scalar T0
Definition: createFields.H:22