absoluteInternalEnergy.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::absoluteInternalEnergy
28 
29 Group
30  grpSpecieThermo
31 
32 Description
33  Thermodynamics mapping class to expose the absolute internal energy
34  functions.
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef absoluteInternalEnergy_H
39 #define absoluteInternalEnergy_H
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class absoluteInternalEnergy Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 template<class Thermo>
52 {
53 
54 public:
55 
56  // Constructors
57 
58  //- Construct
60  {}
61 
62 
63  // Member Functions
64 
65  //- Return the instantiated type name
66  static word typeName()
67  {
68  return "absoluteInternalEnergy";
69  }
70 
71  // Fundamental properties
72 
73  static word energyName()
74  {
75  return "ea";
76  }
77 
78  // Heat capacity at constant volume [J/(kg K)]
79  scalar Cpv
80  (
81  const Thermo& thermo,
82  const scalar p,
83  const scalar T
84  ) const
85  {
86  #ifdef __clang__
87  // Using volatile to prevent compiler optimisations leading to
88  // a sigfpe
89  volatile const scalar cv = thermo.Cv(p, T);
90  return cv;
91  #else
92  return thermo.Cv(p, T);
93  #endif
94  }
95 
96  //- Cp/Cv []
97  scalar CpByCpv
98  (
99  const Thermo& thermo,
100  const scalar p,
101  const scalar T
102  ) const
103  {
104  #ifdef __clang__
105  // Using volatile to prevent compiler optimisations leading to
106  // a sigfpe
107  volatile const scalar gamma = thermo.gamma(p, T);
108  return gamma;
109  #else
110  return thermo.gamma(p, T);
111  #endif
112  }
113 
114  // Absolute internal energy [J/kg]
115  scalar HE
116  (
117  const Thermo& thermo,
118  const scalar p,
119  const scalar T
120  ) const
121  {
122  #ifdef __clang__
123  // Using volatile to prevent compiler optimisations leading to
124  // a sigfpe
125  volatile const scalar ea = thermo.Ea(p, T);
126  return ea;
127  #else
128  return thermo.Ea(p, T);
129  #endif
130  }
131 
132  //- Temperature from absolute internal energy
133  // given an initial temperature T0
134  scalar THE
135  (
136  const Thermo& thermo,
137  const scalar e,
138  const scalar p,
139  const scalar T0
140  ) const
141  {
142  #ifdef __clang__
143  // Using volatile to prevent compiler optimisations leading to
144  // a sigfpe
145  volatile const scalar tea = thermo.TEa(e, p, T0);
146  return tea;
147  #else
148  return thermo.TEa(e, p, T0);
149  #endif
150  }
151 };
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #endif
161 
162 // ************************************************************************* //
scalar Cpv(const Thermo &thermo, const scalar p, const scalar T) const
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
scalar HE(const Thermo &thermo, const scalar p, const scalar T) const
A class for handling words, derived from Foam::string.
Definition: word.H:63
scalar CpByCpv(const Thermo &thermo, const scalar p, const scalar T) const
Cp/Cv [].
scalar THE(const Thermo &thermo, const scalar e, const scalar p, const scalar T0) const
Temperature from absolute internal energy.
Thermodynamics mapping class to expose the absolute internal energy functions.
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
static word typeName()
Return the instantiated type name.
const scalar gamma
Definition: EEqn.H:9
volScalarField & p
Namespace for OpenFOAM.
scalar T0
Definition: createFields.H:22