Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cmath> 7 : #include <cstddef> 8 : #include <cstdint> 9 : 10 : #include "DataStructures/DataBox/Tag.hpp" 11 : #include "DataStructures/Tensor/EagerMath/DeterminantAndInverse.hpp" 12 : #include "DataStructures/Tensor/Tensor.hpp" 13 : #include "DataStructures/VariablesTag.hpp" 14 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp" 15 : #include "Utilities/Gsl.hpp" 16 : #include "Utilities/TMPL.hpp" 17 : 18 : /// \ingroup GeneralRelativityGroup 19 : /// Holds functions related to general relativity. 20 : namespace gr { 21 : 22 : namespace Tags { 23 : /*! 24 : * \brief Compute item for spatial metric determinant \f$\gamma\f$ and inverse 25 : * \f$\gamma^{ij}\f$ in terms of the spatial metric \f$\gamma_{ij}\f$. 26 : * 27 : * \details Can be retrieved using `gr::Tags::DetSpatialMetric` and 28 : * `gr::Tags::InverseSpatialMetric`. 29 : */ 30 : template <typename DataType, size_t SpatialDim, typename Frame> 31 1 : struct DetAndInverseSpatialMetricCompute 32 : : ::Tags::Variables< 33 : tmpl::list<DetSpatialMetric<DataType>, 34 : InverseSpatialMetric<DataType, SpatialDim, Frame>>>, 35 : db::ComputeTag { 36 0 : using argument_tags = tmpl::list<SpatialMetric<DataType, SpatialDim, Frame>>; 37 0 : using base = ::Tags::Variables< 38 : tmpl::list<DetSpatialMetric<DataType>, 39 : InverseSpatialMetric<DataType, SpatialDim, Frame>>>; 40 0 : using return_type = typename base::type; 41 0 : static constexpr auto function = static_cast<void (*)( 42 : const gsl::not_null<return_type*>, 43 : const Tensor<DataType, tmpl::integral_list<std::int32_t, 1, 1>, 44 : tmpl::list<SpatialIndex<SpatialDim, UpLo::Lo, Frame>, 45 : SpatialIndex<SpatialDim, UpLo::Lo, Frame>>>&)>( 46 : &determinant_and_inverse); 47 : }; 48 : 49 : /*! 50 : * \brief Compute item to get the square root of the determinant of the spatial 51 : * metric \f$\sqrt{\gamma}\f$ via `gr::Tags::DetAndInverseSpatialMetric`. 52 : * 53 : * \details Can be retrieved using `gr::Tags::SqrtDetSpatialMetric`. 54 : */ 55 : template <typename DataType, size_t SpatialDim, typename Frame> 56 1 : struct SqrtDetSpatialMetricCompute : SqrtDetSpatialMetric<DataType>, 57 : db::ComputeTag { 58 0 : using argument_tags = tmpl::list<DetSpatialMetric<DataType>>; 59 : 60 0 : using return_type = Scalar<DataType>; 61 : 62 0 : static void function(const gsl::not_null<Scalar<DataType>*> result, 63 : const Scalar<DataType>& det_spatial_metric) { 64 : get(*result) = sqrt(get(det_spatial_metric)); 65 : } 66 : 67 0 : using base = SqrtDetSpatialMetric<DataType>; 68 : }; 69 : } // namespace Tags 70 : } // namespace gr