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/Tags.hpp" 11 : #include "Utilities/TMPL.hpp" 12 : 13 : /// \cond 14 : namespace gsl { 15 : template <typename T> 16 : class not_null; 17 : } // namespace gsl 18 : 19 : class DataVector; 20 : /// \endcond 21 : 22 : // IWYU pragma: no_forward_declare Tensor 23 : 24 : namespace NewtonianEuler { 25 : 26 : /*! 27 : * \brief Compute the conservative variables from the primitive variables. 28 : * 29 : * \f{align*} 30 : * S^i &= \rho v^i \\ 31 : * e &= \dfrac{1}{2}\rho v^2 + \rho\epsilon 32 : * \f} 33 : * 34 : * where \f$S^i\f$ is the momentum density, \f$e\f$ is the energy density, 35 : * \f$\rho\f$ is the mass density, \f$v^i\f$ is the velocity, \f$v^2\f$ is its 36 : * magnitude squared, and \f$\epsilon\f$ is the specific internal energy. 37 : * In addition, this method returns the mass density as a conservative. 38 : */ 39 : template <size_t Dim> 40 1 : struct ConservativeFromPrimitive { 41 0 : using return_tags = 42 : tmpl::list<Tags::MassDensityCons, Tags::MomentumDensity<Dim>, 43 : Tags::EnergyDensity>; 44 : 45 0 : using argument_tags = 46 : tmpl::list<hydro::Tags::RestMassDensity<DataVector>, 47 : hydro::Tags::SpatialVelocity<DataVector, Dim>, 48 : hydro::Tags::SpecificInternalEnergy<DataVector>>; 49 : 50 0 : static void apply(gsl::not_null<Scalar<DataVector>*> mass_density_cons, 51 : gsl::not_null<tnsr::I<DataVector, Dim>*> momentum_density, 52 : gsl::not_null<Scalar<DataVector>*> energy_density, 53 : const Scalar<DataVector>& mass_density, 54 : const tnsr::I<DataVector, Dim>& velocity, 55 : const Scalar<DataVector>& specific_internal_energy); 56 : }; 57 : } // namespace NewtonianEuler