SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/GeneralRelativity/GeneralizedHarmonic - GaugeSource.hpp Hit Total Coverage
Commit: 9b01d30df5d2e946e7e38cc43c008be18ae9b1d2 Lines: 4 13 30.8 %
Date: 2024-04-23 04:54:49
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 <cstddef>
       7             : 
       8             : #include "DataStructures/DataBox/Prefixes.hpp"
       9             : #include "DataStructures/DataBox/Tag.hpp"
      10             : #include "DataStructures/DataVector.hpp"
      11             : #include "DataStructures/Tensor/Tensor.hpp"
      12             : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
      13             : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp"
      14             : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      15             : #include "Utilities/Gsl.hpp"
      16             : #include "Utilities/TMPL.hpp"
      17             : 
      18             : // IWYU pragma: no_forward_declare Tags::deriv
      19             : 
      20             : /// \cond
      21             : namespace domain {
      22             : namespace Tags {
      23             : template <size_t Dim, typename Frame>
      24             : struct Coordinates;
      25             : }  // namespace Tags
      26             : }  // namespace domain
      27             : class DataVector;
      28             : template <typename X, typename Symm, typename IndexList>
      29             : class Tensor;
      30             : /// \endcond
      31             : 
      32             : namespace gh {
      33             : /// @{
      34             : /*!
      35             :  * \ingroup GeneralRelativityGroup
      36             :  * \brief  Computes generalized harmonic gauge source function.
      37             :  * \details If \f$\alpha, \beta^i, \gamma_{ij}, \Gamma_{ijk}, K\f$ are the
      38             :  * lapse, shift, spatial metric, spatial Christoffel symbols, and trace of the
      39             :  * extrinsic curvature, then we compute
      40             :  * \f{align}
      41             :  * H_l &=
      42             :  * \alpha^{-2} \gamma_{il}(\partial_t \beta^i - \beta^k \partial_k \beta^i)
      43             :  * + \alpha^{-1} \partial_l \alpha - \gamma^{km}\Gamma_{lkm} \\
      44             :  * H_0 &= -\alpha^{-1} \partial_t \alpha + \alpha^{-1} \beta^k\partial_k \alpha
      45             :  * + \beta^k H_k - \alpha K
      46             :  * \f}
      47             :  * See Eqs. 8 and 9 of \cite Lindblom2005qh
      48             :  */
      49             : template <typename DataType, size_t SpatialDim, typename Frame>
      50           1 : void gauge_source(
      51             :     gsl::not_null<tnsr::a<DataType, SpatialDim, Frame>*> gauge_source_h,
      52             :     const Scalar<DataType>& lapse, const Scalar<DataType>& dt_lapse,
      53             :     const tnsr::i<DataType, SpatialDim, Frame>& deriv_lapse,
      54             :     const tnsr::I<DataType, SpatialDim, Frame>& shift,
      55             :     const tnsr::I<DataType, SpatialDim, Frame>& dt_shift,
      56             :     const tnsr::iJ<DataType, SpatialDim, Frame>& deriv_shift,
      57             :     const tnsr::ii<DataType, SpatialDim, Frame>& spatial_metric,
      58             :     const Scalar<DataType>& trace_extrinsic_curvature,
      59             :     const tnsr::i<DataType, SpatialDim, Frame>& trace_christoffel_last_indices);
      60             : 
      61             : template <typename DataType, size_t SpatialDim, typename Frame>
      62           1 : tnsr::a<DataType, SpatialDim, Frame> gauge_source(
      63             :     const Scalar<DataType>& lapse, const Scalar<DataType>& dt_lapse,
      64             :     const tnsr::i<DataType, SpatialDim, Frame>& deriv_lapse,
      65             :     const tnsr::I<DataType, SpatialDim, Frame>& shift,
      66             :     const tnsr::I<DataType, SpatialDim, Frame>& dt_shift,
      67             :     const tnsr::iJ<DataType, SpatialDim, Frame>& deriv_shift,
      68             :     const tnsr::ii<DataType, SpatialDim, Frame>& spatial_metric,
      69             :     const Scalar<DataType>& trace_extrinsic_curvature,
      70             :     const tnsr::i<DataType, SpatialDim, Frame>& trace_christoffel_last_indices);
      71             : /// @}
      72             : 
      73             : namespace Tags {
      74             : /*!
      75             :  * \brief  Compute item to get the implicit gauge source function from 3 + 1
      76             :  * quantities.
      77             :  *
      78             :  * \details See `gauge_source()`. Can be retrieved using
      79             :  * `gh::Tags::GaugeH`.
      80             :  */
      81             : template <size_t SpatialDim, typename Frame>
      82           1 : struct GaugeHImplicitFrom3p1QuantitiesCompute
      83             :     : GaugeH<DataVector, SpatialDim, Frame>,
      84             :       db::ComputeTag {
      85           0 :   using argument_tags =
      86             :       tmpl::list<gr::Tags::Lapse<DataVector>,
      87             :                  ::Tags::dt<gr::Tags::Lapse<DataVector>>,
      88             :                  ::Tags::deriv<gr::Tags::Lapse<DataVector>,
      89             :                                tmpl::size_t<SpatialDim>, Frame>,
      90             :                  gr::Tags::Shift<DataVector, SpatialDim, Frame>,
      91             :                  ::Tags::dt<gr::Tags::Shift<DataVector, SpatialDim, Frame>>,
      92             :                  ::Tags::deriv<gr::Tags::Shift<DataVector, SpatialDim, Frame>,
      93             :                                tmpl::size_t<SpatialDim>, Frame>,
      94             :                  gr::Tags::SpatialMetric<DataVector, SpatialDim, Frame>,
      95             :                  gr::Tags::TraceExtrinsicCurvature<DataVector>,
      96             :                  gr::Tags::TraceSpatialChristoffelFirstKind<DataVector,
      97             :                                                             SpatialDim, Frame>>;
      98             : 
      99           0 :   using return_type = tnsr::a<DataVector, SpatialDim, Frame>;
     100             : 
     101           0 :   static constexpr auto function = static_cast<void (*)(
     102             :       gsl::not_null<tnsr::a<DataVector, SpatialDim, Frame>*>,
     103             :       const Scalar<DataVector>&, const Scalar<DataVector>&,
     104             :       const tnsr::i<DataVector, SpatialDim, Frame>&,
     105             :       const tnsr::I<DataVector, SpatialDim, Frame>&,
     106             :       const tnsr::I<DataVector, SpatialDim, Frame>&,
     107             :       const tnsr::iJ<DataVector, SpatialDim, Frame>&,
     108             :       const tnsr::ii<DataVector, SpatialDim, Frame>&, const Scalar<DataVector>&,
     109             :       const tnsr::i<DataVector, SpatialDim, Frame>&)>(
     110             :       &gauge_source<DataVector, SpatialDim, Frame>);
     111             : 
     112           0 :   using base = GaugeH<DataVector, SpatialDim, Frame>;
     113             : };
     114             : 
     115             : /*!
     116             :  * \brief  Compute item to get spacetime derivative of the gauge source function
     117             :  * from its spatial and time derivatives.
     118             :  *
     119             :  * \details Can be retrieved using
     120             :  * `gh::Tags::SpacetimeDerivGaugeH`.
     121             :  */
     122             : template <size_t SpatialDim, typename Frame>
     123           1 : struct SpacetimeDerivGaugeHCompute
     124             :     : SpacetimeDerivGaugeH<DataVector, SpatialDim, Frame>,
     125             :       db::ComputeTag {
     126           0 :   using argument_tags =
     127             :       tmpl::list<::Tags::dt<gh::Tags::GaugeH<DataVector, SpatialDim, Frame>>,
     128             :                  ::Tags::deriv<gh::Tags::GaugeH<DataVector, SpatialDim, Frame>,
     129             :                                tmpl::size_t<SpatialDim>, Frame>>;
     130             : 
     131           0 :   using return_type = tnsr::ab<DataVector, SpatialDim, Frame>;
     132             : 
     133           0 :   static constexpr void function(
     134             :       const gsl::not_null<tnsr::ab<DataVector, SpatialDim, Frame>*>
     135             :           spacetime_deriv_gauge_source,
     136             :       const tnsr::a<DataVector, SpatialDim, Frame>& time_deriv_gauge_source,
     137             :       const tnsr::ia<DataVector, SpatialDim, Frame>& deriv_gauge_source) {
     138             :     for (size_t b = 0; b < SpatialDim + 1; ++b) {
     139             :       spacetime_deriv_gauge_source->get(0, b) = time_deriv_gauge_source.get(b);
     140             :       for (size_t a = 1; a < SpatialDim + 1; ++a) {
     141             :         spacetime_deriv_gauge_source->get(a, b) =
     142             :             deriv_gauge_source.get(a - 1, b);
     143             :       }
     144             :     }
     145             :   }
     146             : 
     147           0 :   using base = SpacetimeDerivGaugeH<DataVector, SpatialDim, Frame>;
     148             : };
     149             : }  // namespace Tags
     150             : }  // namespace gh

Generated by: LCOV version 1.14