Nektar++
EquationOfState.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: EquationOfState.cpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Abstract base class for equations of state.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include "EquationOfState.h"
36 
37 using namespace std;
38 
39 namespace Nektar
40 {
42 {
43  static EquationOfStateFactory instance;
44  return instance;
45 }
46 
47 EquationOfState::EquationOfState(
49 {
50  pSession->LoadParameter("Gamma", m_gamma, 1.4);
51  pSession->LoadParameter("GasConstant", m_gasConstant, 287.058);
52 }
53 
54 NekDouble EquationOfState::GetTemperature(const NekDouble &rho,
55  const NekDouble &e)
56 {
57  return v_GetTemperature(rho, e);
58 }
59 
60 NekDouble EquationOfState::GetPressure(const NekDouble &rho, const NekDouble &e)
61 {
62  return v_GetPressure(rho, e);
63 }
64 
65 NekDouble EquationOfState::GetSoundSpeed(const NekDouble &rho,
66  const NekDouble &e)
67 {
68  return v_GetSoundSpeed(rho, e);
69 }
70 
71 NekDouble EquationOfState::GetEntropy(const NekDouble &rho, const NekDouble &e)
72 {
73  return v_GetEntropy(rho, e);
74 }
75 
76 NekDouble EquationOfState::GetDPDrho_e(const NekDouble &rho, const NekDouble &e)
77 {
78  return v_GetDPDrho_e(rho, e);
79 }
80 
81 NekDouble EquationOfState::GetDPDe_rho(const NekDouble &rho, const NekDouble &e)
82 {
83  return v_GetDPDe_rho(rho, e);
84 }
85 
86 NekDouble EquationOfState::GetEFromRhoP(const NekDouble &rho,
87  const NekDouble &p)
88 {
89  return v_GetEFromRhoP(rho, p);
90 }
91 
92 NekDouble EquationOfState::GetRhoFromPT(const NekDouble &p, const NekDouble &T)
93 {
94  return v_GetRhoFromPT(p, T);
95 }
96 
97 // General implementation for v_GetSoundSpeed: c^2 = xi + kappa * h
98 // where xi = dpdrho - e/rho * dp/de and kappa = dp/de / rho
99 NekDouble EquationOfState::v_GetSoundSpeed(const NekDouble &rho,
100  const NekDouble &e)
101 {
102  NekDouble p = GetPressure(rho, e);
103  NekDouble dpde = GetDPDe_rho(rho, e);
104  NekDouble dpdrho = GetDPDrho_e(rho, e);
105 
106  NekDouble enthalpy = e + p / rho;
107 
108  NekDouble chi = dpdrho - e / rho * dpde;
109  NekDouble kappa = dpde / rho;
110 
111  return sqrt(chi + kappa * enthalpy);
112 }
113 }
STL namespace.
EquationOfStateFactory & GetEquationOfStateFactory()
Declaration of the equation of state factory singleton.
double NekDouble
std::shared_ptr< SessionReader > SessionReaderSharedPtr
Provides a generic Factory class.
Definition: NekFactory.hpp:103