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/Tensor/TypeAliases.hpp"
9 : #include "Evolution/Systems/NewtonianEuler/TagsDeclarations.hpp"
10 : #include "PointwiseFunctions/Hydro/EquationsOfState/EquationOfState.hpp"
11 : #include "PointwiseFunctions/Hydro/Tags.hpp"
12 : #include "Utilities/TMPL.hpp"
13 :
14 : /// \cond
15 : namespace gsl {
16 : template <typename T>
17 : class not_null;
18 : } // namespace gsl
19 :
20 : class DataVector;
21 : /// \endcond
22 :
23 : namespace NewtonianEuler {
24 :
25 : /*!
26 : * \brief Compute the primitive variables from the conservative variables.
27 : *
28 : * \f{align*}
29 : * v^i &= \frac{S^i}{\rho} \\
30 : * \epsilon &= \frac{e}{\rho} - \frac{1}{2}\frac{S^2}{\rho^2}
31 : * \f}
32 : *
33 : * where \f$v^i\f$ is the velocity, \f$\epsilon\f$ is the specific
34 : * internal energy, \f$e\f$ is the energy density, \f$\rho\f$
35 : * is the mass density, \f$S^i\f$ is the momentum density, and
36 : * \f$S^2\f$ is the momentum density squared.
37 : *
38 : * This routine also returns the mass density as a primitive, and the pressure
39 : * from a generic equation of state \f$p = p(\rho, \epsilon)\f$.
40 : */
41 : template <size_t Dim>
42 1 : struct PrimitiveFromConservative {
43 0 : using return_tags =
44 : tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
45 : hydro::Tags::SpatialVelocity<DataVector, Dim>,
46 : hydro::Tags::SpecificInternalEnergy<DataVector>,
47 : hydro::Tags::Pressure<DataVector>>;
48 :
49 0 : using argument_tags =
50 : tmpl::list<Tags::MassDensityCons, Tags::MomentumDensity<Dim>,
51 : Tags::EnergyDensity, hydro::Tags::EquationOfState<false, 2>>;
52 :
53 : template <size_t ThermodynamicDim>
54 0 : static void apply(
55 : gsl::not_null<Scalar<DataVector>*> mass_density,
56 : gsl::not_null<tnsr::I<DataVector, Dim>*> velocity,
57 : gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
58 : gsl::not_null<Scalar<DataVector>*> pressure,
59 : const Scalar<DataVector>& mass_density_cons,
60 : const tnsr::I<DataVector, Dim>& momentum_density,
61 : const Scalar<DataVector>& energy_density,
62 : const EquationsOfState::EquationOfState<false, ThermodynamicDim>&
63 : equation_of_state);
64 : };
65 : } // namespace NewtonianEuler
|