Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include "DataStructures/Tensor/Tensor.hpp"
7 : #include "Utilities/Gsl.hpp"
8 : #include "Utilities/Kokkos/KokkosMacros.hpp"
9 : #include "Utilities/MakeWithValue.hpp"
10 : #include "Utilities/TMPL.hpp"
11 :
12 : /// @{
13 : /*!
14 : * \ingroup GeneralRelativityGroup
15 : * \brief Raises or lowers the first index of a rank 3 tensor which is symmetric
16 : * in the last two indices.
17 : *
18 : * \details If \f$T_{abc}\f$ is a tensor with \f$T_{abc} = T_{acb}\f$ and the
19 : * indices \f$a,b,c,...\f$ can represent either spatial or spacetime indices,
20 : * then the tensor \f$ T^a_{bc} = g^{ad} T_{abc} \f$ is computed, where \f$
21 : * g^{ab}\f$ is the inverse metric, which is either a spatial or spacetime
22 : * metric. If a tensor \f$ S^a_{bc} \f$ is passed as an argument than the
23 : * corresponding tensor \f$ S_{abc} \f$ is calculated with respect to the metric
24 : * \f$g_{ab}\f$. You may have to add a new instantiation of this template if
25 : * you need a new use case.
26 : *
27 : * These functions can be called in Kokkos kernels with `double`s.
28 : */
29 : template <typename DataType, typename Index0, typename Index1>
30 1 : KOKKOS_FUNCTION void raise_or_lower_first_index(
31 : gsl::not_null<
32 : Tensor<DataType, Symmetry<2, 1, 1>,
33 : index_list<change_index_up_lo<Index0>, Index1, Index1>>*>
34 : result,
35 : const Tensor<DataType, Symmetry<2, 1, 1>,
36 : index_list<Index0, Index1, Index1>>& tensor,
37 : const Tensor<DataType, Symmetry<1, 1>,
38 : index_list<change_index_up_lo<Index0>,
39 : change_index_up_lo<Index0>>>& metric);
40 :
41 : SPECTRE_KOKKOS_DISABLE_EXEC_CHECK
42 : template <typename DataType, typename Index0, typename Index1>
43 : KOKKOS_FUNCTION Tensor<DataType, Symmetry<2, 1, 1>,
44 : index_list<change_index_up_lo<Index0>, Index1, Index1>>
45 1 : raise_or_lower_first_index(
46 : const Tensor<DataType, Symmetry<2, 1, 1>,
47 : index_list<Index0, Index1, Index1>>& tensor,
48 : const Tensor<DataType, Symmetry<1, 1>,
49 : index_list<change_index_up_lo<Index0>,
50 : change_index_up_lo<Index0>>>& metric) {
51 : Tensor<DataType, Symmetry<2, 1, 1>,
52 : index_list<change_index_up_lo<Index0>, Index1, Index1>>
53 : result{};
54 : raise_or_lower_first_index(make_not_null(&result), tensor, metric);
55 : return result;
56 : }
57 : /// @}
58 :
59 : /// @{
60 : /*!
61 : * \ingroup GeneralRelativityGroup
62 : * \brief Raises or lowers the index of a rank 1 tensor.
63 : *
64 : * \details If \f$T_{a}\f$ is a tensor and the
65 : * index \f$a\f$ can represent either a spatial or spacetime index,
66 : * then the tensor \f$ T^a = g^{ad} T_{d} \f$ is computed, where \f$
67 : * g^{ab}\f$ is the inverse metric, which is either a spatial or spacetime
68 : * metric. If a tensor \f$ S^a \f$ is passed as an argument than the
69 : * corresponding tensor \f$ S_{a} \f$ is calculated with respect to the metric
70 : * \f$g_{ab}\f$.
71 : *
72 : * These functions can be called in Kokkos kernels with `double`s.
73 : */
74 : template <typename DataTypeTensor, typename DataTypeMetric, typename Index0>
75 1 : KOKKOS_FUNCTION void raise_or_lower_index(
76 : gsl::not_null<Tensor<DataTypeTensor, Symmetry<1>,
77 : index_list<change_index_up_lo<Index0>>>*>
78 : result,
79 : const Tensor<DataTypeTensor, Symmetry<1>, index_list<Index0>>& tensor,
80 : const Tensor<DataTypeMetric, Symmetry<1, 1>,
81 : index_list<change_index_up_lo<Index0>,
82 : change_index_up_lo<Index0>>>& metric);
83 :
84 : SPECTRE_KOKKOS_DISABLE_EXEC_CHECK
85 : template <typename DataTypeTensor, typename DataTypeMetric, typename Index0>
86 : KOKKOS_FUNCTION
87 : Tensor<DataTypeTensor, Symmetry<1>, index_list<change_index_up_lo<Index0>>>
88 1 : raise_or_lower_index(
89 : const Tensor<DataTypeTensor, Symmetry<1>, index_list<Index0>>& tensor,
90 : const Tensor<DataTypeMetric, Symmetry<1, 1>,
91 : index_list<change_index_up_lo<Index0>,
92 : change_index_up_lo<Index0>>>& metric) {
93 : Tensor<DataTypeTensor, Symmetry<1>, index_list<change_index_up_lo<Index0>>>
94 : result{};
95 : raise_or_lower_index(make_not_null(&result), tensor, metric);
96 : return result;
97 : }
98 : /// @}
|