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