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/TypeAliases.hpp" 10 : #include "Evolution/Systems/ScalarWave/Tags.hpp" 11 : #include "Utilities/TMPL.hpp" 12 : 13 : /// \cond 14 : class DataVector; 15 : namespace gsl { 16 : template <typename T> 17 : class not_null; 18 : } // namespace gsl 19 : /// \endcond 20 : 21 : namespace ScalarWave { 22 : /// @{ 23 : /*! 24 : * \brief Computes the energy density of the scalar wave system. 25 : * 26 : * Below is the function used to calculate the energy density. 27 : * 28 : * \f{align*} 29 : * \epsilon = \frac{1}{2}\left( \Pi^{2} + \abs{\Phi}^{2} \right) 30 : * \f} 31 : */ 32 : template <size_t SpatialDim> 33 1 : void energy_density( 34 : gsl::not_null<Scalar<DataVector>*> result, const Scalar<DataVector>& pi, 35 : const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi); 36 : 37 : template <size_t SpatialDim> 38 1 : Scalar<DataVector> energy_density( 39 : const Scalar<DataVector>& pi, 40 : const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi); 41 : /// @} 42 : 43 : namespace Tags { 44 : /// \brief Computes the energy density using ScalarWave::energy_density() 45 : template <size_t SpatialDim> 46 1 : struct EnergyDensityCompute : EnergyDensity<SpatialDim>, db::ComputeTag { 47 0 : using argument_tags = tmpl::list<Pi, Phi<SpatialDim>>; 48 : 49 0 : using return_type = Scalar<DataVector>; 50 : 51 0 : static constexpr auto function = static_cast<void (*)( 52 : gsl::not_null<Scalar<DataVector>*> result, const Scalar<DataVector>&, 53 : const tnsr::i<DataVector, SpatialDim, Frame::Inertial>&)>( 54 : &energy_density<SpatialDim>); 55 : 56 0 : using base = EnergyDensity<SpatialDim>; 57 : }; 58 : } // namespace Tags 59 : } // namespace ScalarWave