Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 :
8 : #include "DataStructures/DataBox/Tag.hpp"
9 : #include "DataStructures/Tensor/Tensor.hpp"
10 : #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
11 : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
12 : #include "PointwiseFunctions/Hydro/Tags.hpp"
13 : #include "Utilities/Gsl.hpp"
14 : #include "Utilities/TMPL.hpp"
15 :
16 : namespace NewtonianEuler {
17 : /// @{
18 : /*!
19 : * Compute the Newtonian sound speed squared
20 : * \f$c_s^2 = \chi + p\kappa / \rho^2\f$, where
21 : * \f$p\f$ is the fluid pressure, \f$\rho\f$ is the mass density,
22 : * \f$\chi = (\partial p/\partial\rho)_\epsilon\f$ and
23 : * \f$\kappa = (\partial p/ \partial \epsilon)_\rho\f$, where
24 : * \f$\epsilon\f$ is the specific internal energy.
25 : */
26 : template <typename DataType, size_t ThermodynamicDim>
27 1 : void sound_speed_squared(
28 : gsl::not_null<Scalar<DataType>*> result,
29 : const Scalar<DataType>& mass_density,
30 : const Scalar<DataType>& specific_internal_energy,
31 : const EquationsOfState::EquationOfState<false, ThermodynamicDim>&
32 : equation_of_state);
33 :
34 : template <typename DataType, size_t ThermodynamicDim>
35 1 : Scalar<DataType> sound_speed_squared(
36 : const Scalar<DataType>& mass_density,
37 : const Scalar<DataType>& specific_internal_energy,
38 : const EquationsOfState::EquationOfState<false, ThermodynamicDim>&
39 : equation_of_state);
40 : /// @}
41 :
42 : namespace Tags {
43 : /// Compute item for the sound speed \f$c_s\f$.
44 : ///
45 : /// Can be retrieved using `NewtonianEuler::Tags::SoundSpeed`
46 : template <typename DataType>
47 1 : struct SoundSpeedCompute : SoundSpeed<DataType>, db::ComputeTag {
48 0 : using argument_tags = tmpl::list<hydro::Tags::SoundSpeedSquared<DataType>>;
49 :
50 0 : using return_type = Scalar<DataType>;
51 :
52 0 : static void function(const gsl::not_null<Scalar<DataType>*> result,
53 : const Scalar<DataType>& sound_speed_squared) {
54 : get(*result) = sqrt(get(sound_speed_squared));
55 : }
56 :
57 0 : using base = SoundSpeed<DataType>;
58 : };
59 :
60 : /// Compute item for the sound speed squared \f$c_s^2\f$.
61 : /// \see NewtonianEuler::sound_speed_squared
62 : ///
63 : /// Can be retrieved using `NewtonianEuler::Tags::SoundSpeedSquared`
64 : template <typename DataType>
65 1 : struct SoundSpeedSquaredCompute : hydro::Tags::SoundSpeedSquared<DataType>,
66 : db::ComputeTag {
67 0 : using argument_tags =
68 : tmpl::list<hydro::Tags::RestMassDensity<DataType>,
69 : hydro::Tags::SpecificInternalEnergy<DataType>,
70 : hydro::Tags::EquationOfState<false, 2>>;
71 :
72 0 : using return_type = Scalar<DataType>;
73 :
74 : template <typename EquationOfStateType>
75 0 : static void function(const gsl::not_null<Scalar<DataType>*> result,
76 : const Scalar<DataType>& mass_density,
77 : const Scalar<DataType>& specific_internal_energy,
78 : const EquationOfStateType& equation_of_state) {
79 : sound_speed_squared(result, mass_density, specific_internal_energy,
80 : equation_of_state);
81 : }
82 :
83 0 : using base = hydro::Tags::SoundSpeedSquared<DataType>;
84 : };
85 : } // namespace Tags
86 : } // namespace NewtonianEuler
|