thermoTypeFunctions.H
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) 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 template<class ThermoType>
27 scalarList W(const rhoReactionThermo& thermo)
28 {
29  const PtrList<ThermoType>& specieData =
30  dynamicCast<const reactingMixture<ThermoType>>(thermo)
31  .speciesData();
32 
33  scalarList W(specieData.size());
34 
35  forAll(specieData, i)
36  {
37  W[i] = specieData[i].W();
38  }
39 
40  return W;
41 }
42 
43 
44 template<class ThermoType>
45 scalar h0
46 (
47  const rhoReactionThermo& thermo,
48  const scalarList& Y,
49  const scalar p,
50  const scalar T
51 )
52 {
53  const PtrList<ThermoType>& specieData =
54  dynamic_cast<const reactingMixture<ThermoType>&>(thermo)
55  .speciesData();
56 
57  scalar h0 = 0;
58  forAll(Y, i)
59  {
60  h0 += Y[i]*specieData[i].Hs(p, T);
61  }
62 
63  return h0;
64 }
65 
66 
67 scalarList W(const rhoReactionThermo& thermo)
68 {
69  if (isA<reactingMixture<gasHThermoPhysics>>(thermo))
70  {
71  return W<gasHThermoPhysics>(thermo);
72  }
73  else if (isA<reactingMixture<constFluidHThermoPhysics>>(thermo))
74  {
75  return W<constFluidHThermoPhysics>(thermo);
76  }
77  else
78  {
80  << "Thermodynamics type " << thermo.type()
81  << " not supported by chemFoam"
82  << exit(FatalError);
83 
84  return scalarList::null();
85  }
86 }
87 
88 
89 scalar h0
90 (
91  const rhoReactionThermo& thermo,
92  const scalarList& Y,
93  const scalar p,
94  const scalar T
95 )
96 {
97  if (isA<reactingMixture<gasHThermoPhysics>>(thermo))
98  {
99  return h0<gasHThermoPhysics>(thermo, Y, p, T);
100  }
101  else if (isA<reactingMixture<constFluidHThermoPhysics>>(thermo))
102  {
103  return h0<constFluidHThermoPhysics>(thermo, Y, p, T);
104  }
105  else
106  {
108  << "Thermodynamics type " << thermo.type()
109  << " not supported by chemFoam"
110  << exit(FatalError);
111 
112  return 0;
113  }
114 }
115 
116 
117 // ************************************************************************* //
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:134
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
rhoReactionThermo & thermo
Definition: createFields.H:28
scalarList W(const rhoReactionThermo &thermo)
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:50
scalar h0(const rhoReactionThermo &thermo, const scalarList &Y, const scalar p, const scalar T)
const volScalarField & T
PtrList< volScalarField > & Y
volScalarField & p