SpECTRE Documentation Coverage Report
Current view: top level - DataStructures/Tensor/EagerMath - RaiseOrLowerIndex.hpp Hit Total Coverage
Commit: 923cd4a8ea30f5a5589baa60b0a93e358ca9f8e8 Lines: 4 5 80.0 %
Date: 2025-11-07 19:37:56
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14