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 : #include <limits> 8 : 9 : #include "DataStructures/Tensor/TypeAliases.hpp" 10 : #include "Evolution/Systems/NewtonianEuler/TagsDeclarations.hpp" 11 : #include "Utilities/MakeArray.hpp" 12 : #include "Utilities/TMPL.hpp" 13 : 14 : /// \cond 15 : class DataVector; 16 : 17 : namespace PUP { 18 : class er; 19 : } // namespace PUP 20 : 21 : namespace gsl { 22 : template <typename> 23 : struct not_null; 24 : } // namespace gsl 25 : /// \endcond 26 : 27 : namespace NewtonianEuler { 28 : namespace Sources { 29 : 30 : /*! 31 : * \brief Source generated from an external uniform acceleration. 32 : * 33 : * The NewtonianEuler system with source terms is written as 34 : * 35 : * \f{align*} 36 : * \partial_t\rho + \partial_i F^i(\rho) &= S(\rho)\\ 37 : * \partial_t S^i + \partial_j F^{j}(S^i) &= S(S^i)\\ 38 : * \partial_t e + \partial_i F^i(e) &= S(e), 39 : * \f} 40 : * 41 : * where \f$F^i(u)\f$ is the volume flux of the conserved quantity \f$u\f$ 42 : * (see ComputeFluxes). For an external acceleration \f$a^i\f$, one has 43 : * 44 : * \f{align*} 45 : * S(\rho) &= 0\\ 46 : * S(S^i) &= \rho a^i\\ 47 : * S(e) &= S_ia^i, 48 : * \f} 49 : * 50 : * where \f$\rho\f$ is the mass density, \f$S^i\f$ is the momentum density, 51 : * and \f$e\f$ is the energy density. 52 : */ 53 : template <size_t Dim> 54 1 : struct UniformAcceleration { 55 0 : UniformAcceleration() noexcept = default; 56 0 : UniformAcceleration(const UniformAcceleration& /*rhs*/) = default; 57 0 : UniformAcceleration& operator=(const UniformAcceleration& /*rhs*/) = default; 58 0 : UniformAcceleration(UniformAcceleration&& /*rhs*/) noexcept = default; 59 0 : UniformAcceleration& operator=(UniformAcceleration&& /*rhs*/) noexcept = 60 : default; 61 0 : ~UniformAcceleration() = default; 62 : 63 0 : explicit UniformAcceleration( 64 : const std::array<double, Dim>& acceleration_field) noexcept; 65 : 66 : // clang-tidy: google-runtime-references 67 0 : void pup(PUP::er& /*p*/) noexcept; // NOLINT 68 : 69 0 : using sourced_variables = 70 : tmpl::list<Tags::MomentumDensity<Dim>, Tags::EnergyDensity>; 71 : 72 0 : using argument_tags = 73 : tmpl::list<Tags::MassDensityCons, Tags::MomentumDensity<Dim>>; 74 : 75 0 : void apply(gsl::not_null<tnsr::I<DataVector, Dim>*> source_momentum_density, 76 : gsl::not_null<Scalar<DataVector>*> source_energy_density, 77 : const Scalar<DataVector>& mass_density_cons, 78 : const tnsr::I<DataVector, Dim>& momentum_density) const noexcept; 79 : 80 : private: 81 : template <size_t SpatialDim> 82 0 : friend bool operator==( // NOLINT(readability-redundant-declaration) 83 : const UniformAcceleration<SpatialDim>& lhs, 84 : const UniformAcceleration<SpatialDim>& rhs) noexcept; 85 : 86 0 : std::array<double, Dim> acceleration_field_ = 87 : make_array<Dim>(std::numeric_limits<double>::signaling_NaN()); 88 : }; 89 : 90 : template <size_t Dim> 91 : bool operator!=(const UniformAcceleration<Dim>& lhs, 92 : const UniformAcceleration<Dim>& rhs) noexcept; 93 : } // namespace Sources 94 : } // namespace NewtonianEuler