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