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
37namespace Nektar
38{
40{
41 static EquationOfStateFactory instance;
42 return instance;
43}
44
47{
48 pSession->LoadParameter("Gamma", m_gamma, 1.4);
49 pSession->LoadParameter("GasConstant", m_gasConstant, 287.058);
50
51 m_gammaMone = m_gamma - 1.0;
53}
54
56 const NekDouble &gasConstant)
57 : m_gamma{gamma}, m_gasConstant{gasConstant}
58{
59}
60
61// General implementation for v_GetSoundSpeed: c^2 = xi + kappa * h
62// where xi = dpdrho - e/rho * dp/de and kappa = dp/de / rho
64 const NekDouble &e)
65{
66 NekDouble p = GetPressure(rho, e);
67 NekDouble dpde = GetDPDe_rho(rho, e);
68 NekDouble dpdrho = GetDPDrho_e(rho, e);
69
70 NekDouble enthalpy = e + p / rho;
71
72 NekDouble chi = dpdrho - e / rho * dpde;
73 NekDouble kappa = dpde / rho;
74
75 return std::sqrt(chi + kappa * enthalpy);
76}
77
78} // namespace Nektar
virtual NekDouble v_GetSoundSpeed(const NekDouble &rho, const NekDouble &e)
NekDouble GetPressure(const NekDouble &rho, const NekDouble &e)
Calculate the pressure.
EquationOfState(const LibUtilities::SessionReaderSharedPtr &pSession)
Constructor.
NekDouble GetDPDrho_e(const NekDouble &rho, const NekDouble &e)
Calculate the partial derivative of P(rho,e) with respect to rho.
NekDouble GetDPDe_rho(const NekDouble &rho, const NekDouble &e)
Calculate the partial derivative of P(rho,e) with respect to e.
Provides a generic Factory class.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
EquationOfStateFactory & GetEquationOfStateFactory()
Declaration of the equation of state factory singleton.
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:285