SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/GeneralizedHarmonic - Characteristics.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 29.9 % 67 20
Test Date: 2026-10-22 17:29:42
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              : #include <optional>
       8              : 
       9              : #include "DataStructures/DataBox/Tag.hpp"
      10              : #include "DataStructures/Tensor/TypeAliases.hpp"
      11              : #include "Domain/FaceNormal.hpp"
      12              : #include "Domain/TagsTimeDependent.hpp"
      13              : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
      14              : #include "ParallelAlgorithms/ApparentHorizonFinder/HorizonAliases.hpp"
      15              : #include "PointwiseFunctions/GeneralRelativity/GeneralizedHarmonic/ConstraintDampingTags.hpp"
      16              : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      17              : #include "Utilities/TMPL.hpp"
      18              : 
      19              : /// \cond
      20              : class DataVector;
      21              : namespace gsl {
      22              : template <class T>
      23              : class not_null;
      24              : }  // namespace gsl
      25              : namespace Tags {
      26              : template <typename Tag>
      27              : struct Normalized;
      28              : }  // namespace Tags
      29              : /// \endcond
      30              : 
      31              : namespace gh {
      32              : 
      33              : /// @{
      34              : /*!
      35              :  * \brief Computes the spacetime metric characteristic speed in `SourceFrame`.
      36              :  *
      37              :  * This function is meant to be used for observing, as it is not optimized and
      38              :  * computations that are redundant across other characteristic speed
      39              :  * functions.
      40              :  *
      41              :  * It computes
      42              :  * \f[
      43              :  * v_g^{\hat{\imath}} = -(1 + \gamma_1) \beta^{\hat{\imath}}
      44              :  *                           -(1 + \gamma_1) v^{\hat{\imath}},
      45              :  * \f]
      46              :  * where \f$\hat{\imath}\f$ is in `SourceFrame`.
      47              :  *
      48              :  * \see VSpacetimeMetricSpeed
      49              :  */
      50              : template <size_t Dim, typename Frame, typename SourceFrame>
      51            1 : void vspacetimemetric_speed(
      52              :     gsl::not_null<tnsr::I<DataVector, Dim, SourceFrame>*> char_speed,
      53              :     const Scalar<DataVector>& gamma_1,
      54              :     const tnsr::I<DataVector, Dim, Frame>& shift,
      55              :     const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&
      56              :         inverse_jacobian,
      57              :     const tnsr::II<DataVector, Dim, Frame>& inverse_spatial_metric,
      58              :     const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity);
      59              : template <size_t Dim, typename Frame, typename SourceFrame>
      60            1 : tnsr::I<DataVector, Dim, SourceFrame> vspacetimemetric_speed(
      61              :     const Scalar<DataVector>& gamma_1,
      62              :     const tnsr::I<DataVector, Dim, Frame>& shift,
      63              :     const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&
      64              :         inverse_jacobian,
      65              :     const tnsr::II<DataVector, Dim, Frame>& inverse_spatial_metric,
      66              :     const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity);
      67              : /// @}
      68              : 
      69              : /// @{
      70              : /*!
      71              :  * \brief Computes the zero characteristic speed in `SourceFrame`.
      72              :  *
      73              :  * This function is meant to be used for observing, as it is not optimized and
      74              :  * shares computations that are redundant across other characteristic speed
      75              :  * functions.
      76              :  *
      77              :  * It computes
      78              :  * \f[
      79              :  * (v_0)^{\hat{\imath}} = -\beta^{\hat{\imath}} - v^{\hat{\imath}},
      80              :  * \f]
      81              :  * where \f$\hat{\imath}\f$ is in `SourceFrame`.
      82              :  *
      83              :  * \see VZeroSpeed
      84              :  */
      85              : template <size_t Dim, typename Frame, typename SourceFrame>
      86            1 : void vzero_speed(
      87              :     gsl::not_null<tnsr::I<DataVector, Dim, SourceFrame>*> char_speed,
      88              :     const Scalar<DataVector>& lapse,
      89              :     const tnsr::I<DataVector, Dim, Frame>& shift,
      90              :     const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&
      91              :         inverse_jacobian,
      92              :     const tnsr::II<DataVector, Dim, Frame>& inverse_spatial_metric,
      93              :     const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity);
      94              : template <size_t Dim, typename Frame, typename SourceFrame>
      95            1 : tnsr::I<DataVector, Dim, SourceFrame> vzero_speed(
      96              :     const Scalar<DataVector>& lapse,
      97              :     const tnsr::I<DataVector, Dim, Frame>& shift,
      98              :     const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&
      99              :         inverse_jacobian,
     100              :     const tnsr::II<DataVector, Dim, Frame>& inverse_spatial_metric,
     101              :     const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity);
     102              : /// @}
     103              : 
     104              : /// @{
     105              : /*!
     106              :  * \brief Computes the plus characteristic speed in `SourceFrame`.
     107              :  *
     108              :  * This function is meant to be used for observing, as it is not optimized and
     109              :  * shares computations that are redundant across other characteristic speed
     110              :  * functions.
     111              :  *
     112              :  * It computes
     113              :  * \f[
     114              :  * v_{+}^{\hat{\imath}} = \alpha -\beta^{\hat{\imath}} - v^{\hat{\imath}},
     115              :  * \f]
     116              :  * where \f$\hat{\imath}\f$ is in `SourceFrame`.
     117              :  *
     118              :  * \see VPlusSpeed
     119              : */
     120              : template <size_t Dim, typename Frame, typename SourceFrame>
     121            1 : void vplus_speed(
     122              :     gsl::not_null<tnsr::I<DataVector, Dim, SourceFrame>*> char_speed,
     123              :     const Scalar<DataVector>& lapse,
     124              :     const tnsr::I<DataVector, Dim, Frame>& shift,
     125              :     const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&
     126              :         inverse_jacobian,
     127              :     const tnsr::II<DataVector, Dim, Frame>& inverse_spatial_metric,
     128              :     const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity);
     129              : template <size_t Dim, typename Frame, typename SourceFrame>
     130            1 : tnsr::I<DataVector, Dim, SourceFrame> vplus_speed(
     131              :     const Scalar<DataVector>& lapse,
     132              :     const tnsr::I<DataVector, Dim, Frame>& shift,
     133              :     const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&
     134              :         inverse_jacobian,
     135              :     const tnsr::II<DataVector, Dim, Frame>& inverse_spatial_metric,
     136              :     const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity);
     137              : /// @}
     138              : 
     139              : /// @{
     140              : /*!
     141              :  * \brief Computes the minus characteristic speed in `SourceFrame`.
     142              :  *
     143              :  * This function is meant to be used for observing, as it is not optimized and
     144              :  * shares computations that are redundant across other characteristic speed
     145              :  * functions.
     146              :  *
     147              :  * It computes
     148              :  * \f[
     149              :  * v_{-}^{\hat{\imath}} = -\alpha -\beta^{\hat{\imath}} - v^{\hat{\imath}},
     150              :  * \f]
     151              :  * where \f$\hat{\imath}\f$ is in `SourceFrame`.
     152              :  *
     153              :  * \see VMinusSpeed
     154              :  */
     155              : template <size_t Dim, typename Frame, typename SourceFrame>
     156            1 : void vminus_speed(
     157              :     gsl::not_null<tnsr::I<DataVector, Dim, SourceFrame>*> char_speed,
     158              :     const Scalar<DataVector>& lapse,
     159              :     const tnsr::I<DataVector, Dim, Frame>& shift,
     160              :     const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&
     161              :         inverse_jacobian,
     162              :     const tnsr::II<DataVector, Dim, Frame>& inverse_spatial_metric,
     163              :     const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity);
     164              : template <size_t Dim, typename Frame, typename SourceFrame>
     165            1 : tnsr::I<DataVector, Dim, SourceFrame> vminus_speed(
     166              :     const Scalar<DataVector>& lapse,
     167              :     const tnsr::I<DataVector, Dim, Frame>& shift,
     168              :     const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&
     169              :         inverse_jacobian,
     170              :     const tnsr::II<DataVector, Dim, Frame>& inverse_spatial_metric,
     171              :     const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity);
     172              : /// @}
     173              : 
     174            1 : namespace Tags {
     175              : /*!
     176              :  * \brief Computes the spacetimemetric characteristic speed in `SourceFrame`.
     177              :  *
     178              :  * \see vspacetimemetric_speed()
     179              :  */
     180              : template <size_t Dim, typename Frame, typename SourceFrame>
     181            1 : struct VSpacetimeMetricSpeedCompute
     182              :     : VSpacetimeMetricSpeed<DataVector, Dim, SourceFrame>,
     183              :       db::ComputeTag {
     184            0 :   using argument_tags =
     185              :       tmpl::list<::gh::Tags::ConstraintGamma1,
     186              :                  gr::Tags::Shift<DataVector, Dim, Frame>,
     187              :                  domain::Tags::InverseJacobian<Dim, SourceFrame, Frame>,
     188              :                  gr::Tags::InverseSpatialMetric<DataVector, Dim, Frame>,
     189              :                  domain::Tags::MeshVelocity<Dim, Frame>>;
     190              : 
     191            0 :   using return_type = tnsr::I<DataVector, Dim, SourceFrame>;
     192              : 
     193            0 :   static constexpr auto function = static_cast<void (*)(
     194              :       gsl::not_null<tnsr::I<DataVector, Dim, SourceFrame>*>,
     195              :       const Scalar<DataVector>&, const tnsr::I<DataVector, Dim, Frame>&,
     196              :       const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&,
     197              :       const tnsr::II<DataVector, Dim, Frame>&,
     198              :       const std::optional<tnsr::I<DataVector, Dim, Frame>>&)>(
     199              :       &vspacetimemetric_speed<Dim, Frame, SourceFrame>);
     200              : 
     201            0 :   using base = VSpacetimeMetricSpeed<DataVector, Dim, SourceFrame>;
     202              : };
     203              : 
     204              : /*!
     205              :  * \brief Computes the zero characteristic speed in `SourceFrame`.
     206              :  *
     207              :  * \see vzero_speed()
     208              :  */
     209              : template <size_t Dim, typename Frame, typename SourceFrame>
     210            1 : struct VZeroSpeedCompute : VZeroSpeed<DataVector, Dim, SourceFrame>,
     211              :                            db::ComputeTag {
     212            0 :   using argument_tags =
     213              :       tmpl::list<gr::Tags::Lapse<DataVector>,
     214              :                  gr::Tags::Shift<DataVector, Dim, Frame>,
     215              :                  domain::Tags::InverseJacobian<Dim, SourceFrame, Frame>,
     216              :                  gr::Tags::InverseSpatialMetric<DataVector, Dim, Frame>,
     217              :                  domain::Tags::MeshVelocity<Dim, Frame>>;
     218              : 
     219            0 :   using return_type = tnsr::I<DataVector, Dim, SourceFrame>;
     220              : 
     221            0 :   static constexpr auto function = static_cast<void (*)(
     222              :       gsl::not_null<tnsr::I<DataVector, Dim, SourceFrame>*>,
     223              :       const Scalar<DataVector>&, const tnsr::I<DataVector, Dim, Frame>&,
     224              :       const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&,
     225              :       const tnsr::II<DataVector, Dim, Frame>&,
     226              :       const std::optional<tnsr::I<DataVector, Dim, Frame>>&)>(
     227              :       &vzero_speed<Dim, Frame, SourceFrame>);
     228              : 
     229            0 :   using base = VZeroSpeed<DataVector, Dim, SourceFrame>;
     230              : };
     231              : 
     232              : /*!
     233              :  * \brief Computes the plus characteristic speed in `SourceFrame`.
     234              :  *
     235              :  * \see vplus_speed()
     236              :  */
     237              : template <size_t Dim, typename Frame, typename SourceFrame>
     238            1 : struct VPlusSpeedCompute : VPlusSpeed<DataVector, Dim, SourceFrame>,
     239              :                            db::ComputeTag {
     240            0 :   using argument_tags =
     241              :       tmpl::list<gr::Tags::Lapse<DataVector>,
     242              :                  gr::Tags::Shift<DataVector, Dim, Frame>,
     243              :                  domain::Tags::InverseJacobian<Dim, SourceFrame, Frame>,
     244              :                  gr::Tags::InverseSpatialMetric<DataVector, Dim, Frame>,
     245              :                  domain::Tags::MeshVelocity<Dim, Frame>>;
     246              : 
     247            0 :   using return_type = tnsr::I<DataVector, Dim, SourceFrame>;
     248              : 
     249            0 :   static constexpr auto function = static_cast<void (*)(
     250              :       gsl::not_null<tnsr::I<DataVector, Dim, SourceFrame>*>,
     251              :       const Scalar<DataVector>&, const tnsr::I<DataVector, Dim, Frame>&,
     252              :       const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&,
     253              :       const tnsr::II<DataVector, Dim, Frame>&,
     254              :       const std::optional<tnsr::I<DataVector, Dim, Frame>>&)>(
     255              :       &vplus_speed<Dim, Frame, SourceFrame>);
     256              : 
     257            0 :   using base = VPlusSpeed<DataVector, Dim, SourceFrame>;
     258              : };
     259              : 
     260              : /*!
     261              :  * \brief Computes the minus characteristic speed in `SourceFrame`.
     262              :  *
     263              :  * \see vminus_speed()
     264              :  */
     265              : template <size_t Dim, typename Frame, typename SourceFrame>
     266            1 : struct VMinusSpeedCompute : VMinusSpeed<DataVector, Dim, SourceFrame>,
     267              :                             db::ComputeTag {
     268            0 :   using argument_tags =
     269              :       tmpl::list<gr::Tags::Lapse<DataVector>,
     270              :                  gr::Tags::Shift<DataVector, Dim, Frame>,
     271              :                  domain::Tags::InverseJacobian<Dim, SourceFrame, Frame>,
     272              :                  gr::Tags::InverseSpatialMetric<DataVector, Dim, Frame>,
     273              :                  domain::Tags::MeshVelocity<Dim, Frame>>;
     274              : 
     275            0 :   using return_type = tnsr::I<DataVector, Dim, SourceFrame>;
     276              : 
     277            0 :   static constexpr auto function = static_cast<void (*)(
     278              :       gsl::not_null<tnsr::I<DataVector, Dim, SourceFrame>*>,
     279              :       const Scalar<DataVector>&, const tnsr::I<DataVector, Dim, Frame>&,
     280              :       const InverseJacobian<DataVector, Dim, SourceFrame, Frame>&,
     281              :       const tnsr::II<DataVector, Dim, Frame>&,
     282              :       const std::optional<tnsr::I<DataVector, Dim, Frame>>&)>(
     283              :       &vminus_speed<Dim, Frame, SourceFrame>);
     284              : 
     285            0 :   using base = VMinusSpeed<DataVector, Dim, SourceFrame>;
     286              : };
     287              : }  // namespace Tags
     288              : 
     289              : /// @{
     290              : /*!
     291              :  * \brief Compute the characteristic speeds for the generalized harmonic system.
     292              :  *
     293              :  * Computes the speeds as described in "A New Generalized Harmonic
     294              :  * Evolution System" by Lindblom et. al \cite Lindblom2005qh
     295              :  * [see text following Eq.(34)]. The characteristic fields' names used here
     296              :  * differ from this paper:
     297              :  *
     298              :  * \f{align*}
     299              :  * \mathrm{SpECTRE} && \mathrm{Lindblom} \\
     300              :  * u^{g}_{ab} && u^\hat{0}_{ab} \\
     301              :  * u^0_{iab} && u^\hat{2}_{iab} \\
     302              :  * u^{\pm}_{ab} && u^{\hat{1}\pm}_{ab}
     303              :  * \f}
     304              :  *
     305              :  * The corresponding characteristic speeds \f$v\f$ are given in the text between
     306              :  * Eq.(34) and Eq.(35) of \cite Lindblom2005qh, except for a constraint damping
     307              :  * term used in SpEC and SpECTRE but not published anywhere:
     308              :  *
     309              :  * \f{align*}
     310              :  * v_{g} =& -(1 + \gamma_1) n_k \beta^k - (1 + \gamma_1) n_k v^k_g \\
     311              :  * v_{0} =& -n_k \beta^k - n_k v^k_g\\
     312              :  * v_{\pm} =& -n_k \beta^k \pm \alpha - n_k v^k_g
     313              :  * \f}
     314              :  *
     315              :  * where \f$\alpha, \beta^k\f$ are the lapse and shift respectively,
     316              :  * \f$\gamma_1\f$ is a constraint damping parameter, \f$n_k\f$ is the unit
     317              :  * normal to the surface, and $v^k_g$ is the (optional) mesh velocity.
     318              :  *
     319              :  * \note The results of this function depend on the mesh velocity, but
     320              :  * do not include the system-independent grid advection terms.  The
     321              :  * included terms arise from explicit dependence on the mesh velocity
     322              :  * in the GH time derivative.
     323              :  */
     324              : template <size_t Dim, typename Frame>
     325            1 : std::array<DataVector, 4> characteristic_speeds(
     326              :     const Scalar<DataVector>& gamma_1, const Scalar<DataVector>& lapse,
     327              :     const tnsr::I<DataVector, Dim, Frame>& shift,
     328              :     const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form,
     329              :     const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity);
     330              : 
     331              : template <size_t Dim, typename Frame>
     332            1 : void characteristic_speeds(
     333              :     gsl::not_null<std::array<DataVector, 4>*> char_speeds,
     334              :     const Scalar<DataVector>& gamma_1, const Scalar<DataVector>& lapse,
     335              :     const tnsr::I<DataVector, Dim, Frame>& shift,
     336              :     const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form,
     337              :     const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity);
     338              : 
     339              : template <size_t Dim, typename Frame>
     340            0 : struct CharacteristicSpeedsCompute
     341              :     : Tags::CharacteristicSpeeds<DataVector, Dim, Frame>,
     342              :       db::ComputeTag {
     343            0 :   using base = Tags::CharacteristicSpeeds<DataVector, Dim, Frame>;
     344            0 :   using type = typename base::type;
     345            0 :   using argument_tags = tmpl::list<
     346              :       ::gh::Tags::ConstraintGamma1, gr::Tags::Lapse<DataVector>,
     347              :       gr::Tags::Shift<DataVector, Dim, Frame>,
     348              :       ::Tags::Normalized<domain::Tags::UnnormalizedFaceNormal<Dim, Frame>>,
     349              :       domain::Tags::MeshVelocity<Dim, Frame>>;
     350              : 
     351            0 :   using return_type = typename base::type;
     352              : 
     353            0 :   static void function(
     354              :       const gsl::not_null<return_type*> result,
     355              :       const Scalar<DataVector>& gamma_1, const Scalar<DataVector>& lapse,
     356              :       const tnsr::I<DataVector, Dim, Frame>& shift,
     357              :       const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form,
     358              :       const std::optional<tnsr::I<DataVector, Dim, Frame>>& mesh_velocity) {
     359              :     characteristic_speeds(result, gamma_1, lapse, shift, unit_normal_one_form,
     360              :                           mesh_velocity);
     361              :   };
     362              : };
     363              : 
     364              : // Simple tag used when observing the characteristic speeds on a Strahlkorper
     365              : template <typename Frame>
     366            0 : struct CharacteristicSpeedsOnStrahlkorper : db::SimpleTag {
     367            0 :   using type = tnsr::a<DataVector, 3, Frame>;
     368              : };
     369              : 
     370              : // Compute tag used when computing the characteristic speeds on a Strahlkorper
     371              : // from gamma1, the lapse, shift, and the unit normal one form.
     372              : template <size_t Dim, typename Frame>
     373            0 : struct CharacteristicSpeedsOnStrahlkorperCompute
     374              :     : CharacteristicSpeedsOnStrahlkorper<Frame>,
     375              :       db::ComputeTag {
     376            0 :   using base = CharacteristicSpeedsOnStrahlkorper<Frame>;
     377            0 :   using type = typename base::type;
     378            0 :   using argument_tags =
     379              :       tmpl::list<::gh::Tags::ConstraintGamma1, gr::Tags::Lapse<DataVector>,
     380              :                  gr::Tags::Shift<DataVector, Dim, Frame>,
     381              :                  ::ylm::Tags::UnitNormalOneForm<Frame>>;
     382              : 
     383            0 :   using return_type = typename base::type;
     384              : 
     385            0 :   static void function(
     386              :       const gsl::not_null<return_type*> result,
     387              :       const Scalar<DataVector>& gamma_1, const Scalar<DataVector>& lapse,
     388              :       const tnsr::I<DataVector, Dim, Frame>& shift,
     389              :       const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form) {
     390              :     auto array_char_speeds = make_array<4>(DataVector(get(lapse).size(), 0.0));
     391              :     characteristic_speeds(make_not_null(&array_char_speeds), gamma_1, lapse,
     392              :                           shift, unit_normal_one_form, {});
     393              :     for (size_t i = 0; i < 4; ++i) {
     394              :       (*result)[i] = array_char_speeds[i];
     395              :     }
     396              :   }
     397              : };
     398              : 
     399              : /// @}
     400              : 
     401              : /// @{
     402              : /*!
     403              :  * \brief Computes characteristic fields from evolved fields
     404              :  *
     405              :  * \ref CharacteristicFieldsCompute and
     406              :  * \ref EvolvedFieldsFromCharacteristicFieldsCompute convert between
     407              :  * characteristic and evolved fields for the generalized harmonic system.
     408              :  *
     409              :  * \ref CharacteristicFieldsCompute computes
     410              :  * characteristic fields as described in "A New Generalized Harmonic
     411              :  * Evolution System" by Lindblom et. al \cite Lindblom2005qh .
     412              :  * Their names used here differ from this paper:
     413              :  *
     414              :  * \f{align*}
     415              :  * \mathrm{SpECTRE} && \mathrm{Lindblom} \\
     416              :  * u^{g}_{ab} && u^\hat{0}_{ab} \\
     417              :  * u^0_{iab} && u^\hat{2}_{iab} \\
     418              :  * u^{\pm}_{ab} && u^{\hat{1}\pm}_{ab}
     419              :  * \f}
     420              :  *
     421              :  * The characteristic fields \f$u\f$ are given in terms of the evolved fields by
     422              :  * Eq.(32) - (34) of \cite Lindblom2005qh, respectively:
     423              :  * \f{align*}
     424              :  * u^{g}_{ab} =& g_{ab} \\
     425              :  * u^0_{iab} =& (\delta^k_i - n_i n^k) \Phi_{kab} := P^k_i \Phi_{kab} \\
     426              :  * u^{\pm}_{ab} =& \Pi_{ab} \pm n^i \Phi_{iab} - \gamma_2 g_{ab}
     427              :  * \f}
     428              :  *
     429              :  * where \f$g_{ab}\f$ is the spacetime metric, \f$\Pi_{ab}\f$ and
     430              :  * \f$\Phi_{iab}\f$ are evolved generalized harmonic fields introduced by first
     431              :  * derivatives of \f$g_{ab}\f$, \f$\gamma_2\f$ is a constraint damping
     432              :  * parameter, and \f$n_k\f$ is the unit normal to the surface.
     433              :  *
     434              :  * \ref EvolvedFieldsFromCharacteristicFieldsCompute computes evolved fields
     435              :  * \f$w\f$ in terms of the characteristic fields. This uses the inverse of
     436              :  * above relations:
     437              :  *
     438              :  * \f{align*}
     439              :  * g_{ab} =& u^{g}_{ab}, \\
     440              :  * \Pi_{ab} =& \frac{1}{2}(u^{+}_{ab} + u^{-}_{ab}) + \gamma_2 u^{g}_{ab}, \\
     441              :  * \Phi_{iab} =& \frac{1}{2}(u^{+}_{ab} - u^{-}_{ab}) n_i + u^0_{iab}.
     442              :  * \f}
     443              :  *
     444              :  * The corresponding characteristic speeds \f$v\f$ are computed by
     445              :  * \ref CharacteristicSpeedsCompute .
     446              :  */
     447              : template <size_t Dim, typename Frame>
     448              : typename Tags::CharacteristicFields<DataVector, Dim, Frame>::type
     449            1 : characteristic_fields(
     450              :     const Scalar<DataVector>& gamma_2,
     451              :     const tnsr::II<DataVector, Dim, Frame>& inverse_spatial_metric,
     452              :     const tnsr::aa<DataVector, Dim, Frame>& spacetime_metric,
     453              :     const tnsr::aa<DataVector, Dim, Frame>& pi,
     454              :     const tnsr::iaa<DataVector, Dim, Frame>& phi,
     455              :     const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form);
     456              : 
     457              : template <size_t Dim, typename Frame>
     458            1 : void characteristic_fields(
     459              :     gsl::not_null<
     460              :         typename Tags::CharacteristicFields<DataVector, Dim, Frame>::type*>
     461              :         char_fields,
     462              :     const Scalar<DataVector>& gamma_2,
     463              :     const tnsr::II<DataVector, Dim, Frame>& inverse_spatial_metric,
     464              :     const tnsr::aa<DataVector, Dim, Frame>& spacetime_metric,
     465              :     const tnsr::aa<DataVector, Dim, Frame>& pi,
     466              :     const tnsr::iaa<DataVector, Dim, Frame>& phi,
     467              :     const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form);
     468              : 
     469              : template <size_t Dim, typename Frame>
     470            0 : struct CharacteristicFieldsCompute
     471              :     : Tags::CharacteristicFields<DataVector, Dim, Frame>,
     472              :       db::ComputeTag {
     473            0 :   using base = Tags::CharacteristicFields<DataVector, Dim, Frame>;
     474            0 :   using return_type = typename base::type;
     475            0 :   using argument_tags = tmpl::list<
     476              :       ::gh::Tags::ConstraintGamma2,
     477              :       gr::Tags::InverseSpatialMetric<DataVector, Dim, Frame>,
     478              :       gr::Tags::SpacetimeMetric<DataVector, Dim, Frame>,
     479              :       Tags::Pi<DataVector, Dim, Frame>, Tags::Phi<DataVector, Dim, Frame>,
     480              :       ::Tags::Normalized<domain::Tags::UnnormalizedFaceNormal<Dim, Frame>>>;
     481              : 
     482            0 :   static constexpr auto function = static_cast<void (*)(
     483              :       const gsl::not_null<return_type*>, const Scalar<DataVector>&,
     484              :       const tnsr::II<DataVector, Dim, Frame>&,
     485              :       const tnsr::aa<DataVector, Dim, Frame>&,
     486              :       const tnsr::aa<DataVector, Dim, Frame>&,
     487              :       const tnsr::iaa<DataVector, Dim, Frame>&,
     488              :       const tnsr::i<DataVector, Dim, Frame>&)>(&characteristic_fields);
     489              : };
     490              : /// @}
     491              : 
     492              : /// @{
     493              : /*!
     494              :  * \brief For expressions used here to compute evolved fields from
     495              :  * characteristic ones, see \ref CharacteristicFieldsCompute.
     496              :  */
     497              : template <size_t Dim, typename Frame>
     498              : typename Tags::EvolvedFieldsFromCharacteristicFields<DataVector, Dim,
     499              :                                                      Frame>::type
     500            1 : evolved_fields_from_characteristic_fields(
     501              :     const Scalar<DataVector>& gamma_2,
     502              :     const tnsr::aa<DataVector, Dim, Frame>& u_psi,
     503              :     const tnsr::iaa<DataVector, Dim, Frame>& u_zero,
     504              :     const tnsr::aa<DataVector, Dim, Frame>& u_plus,
     505              :     const tnsr::aa<DataVector, Dim, Frame>& u_minus,
     506              :     const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form);
     507              : 
     508              : template <size_t Dim, typename Frame>
     509            1 : void evolved_fields_from_characteristic_fields(
     510              :     gsl::not_null<typename Tags::EvolvedFieldsFromCharacteristicFields<
     511              :         DataVector, Dim, Frame>::type*>
     512              :         evolved_fields,
     513              :     const Scalar<DataVector>& gamma_2,
     514              :     const tnsr::aa<DataVector, Dim, Frame>& u_psi,
     515              :     const tnsr::iaa<DataVector, Dim, Frame>& u_zero,
     516              :     const tnsr::aa<DataVector, Dim, Frame>& u_plus,
     517              :     const tnsr::aa<DataVector, Dim, Frame>& u_minus,
     518              :     const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form);
     519              : 
     520              : template <size_t Dim, typename Frame>
     521            0 : struct EvolvedFieldsFromCharacteristicFieldsCompute
     522              :     : Tags::EvolvedFieldsFromCharacteristicFields<DataVector, Dim, Frame>,
     523              :       db::ComputeTag {
     524            0 :   using base =
     525              :       Tags::EvolvedFieldsFromCharacteristicFields<DataVector, Dim, Frame>;
     526            0 :   using return_type = typename base::type;
     527            0 :   using argument_tags = tmpl::list<
     528              :       gh::Tags::ConstraintGamma2,
     529              :       Tags::VSpacetimeMetric<DataVector, Dim, Frame>,
     530              :       Tags::VZero<DataVector, Dim, Frame>, Tags::VPlus<DataVector, Dim, Frame>,
     531              :       Tags::VMinus<DataVector, Dim, Frame>,
     532              :       ::Tags::Normalized<domain::Tags::UnnormalizedFaceNormal<Dim, Frame>>>;
     533              : 
     534            0 :   static constexpr auto function = static_cast<void (*)(
     535              :       const gsl::not_null<return_type*>, const Scalar<DataVector>& gamma_2,
     536              :       const tnsr::aa<DataVector, Dim, Frame>& u_psi,
     537              :       const tnsr::iaa<DataVector, Dim, Frame>& u_zero,
     538              :       const tnsr::aa<DataVector, Dim, Frame>& u_plus,
     539              :       const tnsr::aa<DataVector, Dim, Frame>& u_minus,
     540              :       const tnsr::i<DataVector, Dim, Frame>& unit_normal_one_form)>(
     541              :       &evolved_fields_from_characteristic_fields);
     542              : };
     543              : /// @}
     544              : 
     545              : namespace Tags{
     546            0 : struct LargestCharacteristicSpeed : db::SimpleTag {
     547            0 :   using type = double;
     548              : };
     549              : /*!
     550              :  * \brief Computes the largest magnitude of the characteristic speeds.
     551              :  */
     552              : template <size_t Dim, typename Frame>
     553            1 : struct ComputeLargestCharacteristicSpeed : db::ComputeTag,
     554              :                                            LargestCharacteristicSpeed {
     555            0 :   using argument_tags =
     556              :       tmpl::list<::gh::Tags::ConstraintGamma1, gr::Tags::Lapse<DataVector>,
     557              :                  gr::Tags::Shift<DataVector, Dim, Frame>,
     558              :                  gr::Tags::SpatialMetric<DataVector, Dim, Frame>>;
     559            0 :   using return_type = double;
     560            0 :   using base = LargestCharacteristicSpeed;
     561            0 :   static void function(const gsl::not_null<double*> speed,
     562              :                        const Scalar<DataVector>& gamma_1,
     563              :                        const Scalar<DataVector>& lapse,
     564              :                        const tnsr::I<DataVector, Dim, Frame>& shift,
     565              :                        const tnsr::ii<DataVector, Dim, Frame>& spatial_metric);
     566              : };
     567              : }  // namespace Tags
     568              : }  // namespace gh
        

Generated by: LCOV version 2.0-1