Nektar++
Loading...
Searching...
No Matches
IdealGasEoS.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: IdealGasEoS.hpp
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: Ideal gas equation of state
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
37// definition of standard conversions
39// definition of parameters held in struct
41
42namespace Nektar::detail
43{
44
45/**
46 * @brief Ideal gas equation of state Helper function
47 * p = rho * R * T
48 */
49template <typename TData, typename TScalar>
51 const TData &rho, const TData &e)
52{
53 // Ideal gas law: P = (gamma - 1) * rho * e
54 return (TData(EoS.gamma()) - TData(1.0)) * rho * e;
55}
56
57template <typename TData, typename TScalar>
59 const TData &rho, const TData &e)
60{
61 using std::sqrt;
62
63 // Ideal gas law: P = (gamma - 1) * rho * e
64 TData p = GetPressure(EoS, rho, e);
65 return sqrt(TData(EoS.gamma()) * p / rho);
66}
67
68template <typename TData, typename TScalar>
70 const IdealGasEoS<TScalar> &EoS, [[maybe_unused]] const TData &rhoL,
71 [[maybe_unused]] const TData &pL, [[maybe_unused]] const TData &eL,
72 [[maybe_unused]] const TData &HL, [[maybe_unused]] const TData &srL,
73 [[maybe_unused]] const TData &rhoR, [[maybe_unused]] const TData &pR,
74 [[maybe_unused]] const TData &eR, [[maybe_unused]] const TData &HR,
75 [[maybe_unused]] const TData &srR, const TData &HRoe, const TData &URoe2,
76 [[maybe_unused]] const TData &srLR)
77{
78 using std::sqrt;
79 // Calculate sound speed using ideal gas relation
80 return sqrt((TData(EoS.gamma()) - TData(1.0)) *
81 (HRoe - TData(0.5) * URoe2));
82}
83
84template <typename TData, typename TScalar>
86 [[maybe_unused]] const TData &rho,
87 const TData &e)
88{
89 return e * TData(EoS.gammaMoneOgasConst());
90}
91
92/**
93 * @brief Specific internal energy at a prescribed pressure; the inverse of
94 * GetPressure() in its second argument.
95 *
96 * Needed by a pressure outflow, which prescribes p and extrapolates rho, and
97 * must recover the energy state that goes with the pair.
98 */
99template <typename TData, typename TScalar>
101 const IdealGasEoS<TScalar> &EoS, const TData &rho, const TData &p)
102{
103 return p / ((TData(EoS.gamma()) - TData(1.0)) * rho);
104}
105
106/**
107 * @brief Specific internal energy at a prescribed temperature; the inverse of
108 * GetTemperature().
109 *
110 * Needed by an isothermal wall, which prescribes T and must recover the energy
111 * state that goes with it.
112 */
113template <typename TData, typename TScalar>
116 [[maybe_unused]] const TData &rho, const TData &T)
117{
118 return T / TData(EoS.gammaMoneOgasConst());
119}
120
121} // namespace Nektar::detail
#define NEK_HOSTDEVICE_INLINE
Definition Backends.hpp:268
NEK_HOSTDEVICE_INLINE TData GetSoundSpeed(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &e)
NEK_HOSTDEVICE_INLINE TData GetTemperature(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &e)
NEK_HOSTDEVICE_INLINE TData GetRoeSoundSpeed(const IdealGasEoS< TScalar > &EoS, const TData &rhoL, const TData &pL, const TData &eL, const TData &HL, const TData &srL, const TData &rhoR, const TData &pR, const TData &eR, const TData &HR, const TData &srR, const TData &HRoe, const TData &URoe2, const TData &srLR)
NEK_HOSTDEVICE_INLINE TData GetIntEnergyFromPressure(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &p)
Specific internal energy at a prescribed pressure; the inverse of GetPressure() in its second argumen...
NEK_HOSTDEVICE_INLINE TData GetIntEnergyFromTemperature(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &T)
Specific internal energy at a prescribed temperature; the inverse of GetTemperature().
NEK_HOSTDEVICE_INLINE TData GetPressure(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &e)
Ideal gas equation of state Helper function p = rho * R * T.
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:289
Ideal gas equation of state: p = rho * R * T.