SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/RelativisticEuler/Valencia - Characteristics.hpp Hit Total Coverage
Commit: aabde07399ba7837e5db64eedfd0a21f31f96922 Lines: 5 15 33.3 %
Date: 2024-04-26 02:38:13
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 <array>
       7             : #include <cstddef>
       8             : 
       9             : #include "DataStructures/DataBox/Tag.hpp"
      10             : #include "DataStructures/Matrix.hpp"
      11             : #include "DataStructures/Tensor/TypeAliases.hpp"
      12             : #include "Domain/FaceNormal.hpp"
      13             : #include "Evolution/Systems/RelativisticEuler/Valencia/Tags.hpp"
      14             : #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp"
      15             : #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp"
      16             : #include "Utilities/Gsl.hpp"
      17             : #include "Utilities/TMPL.hpp"
      18             : 
      19             : /// \cond
      20             : class DataVector;
      21             : namespace Tags {
      22             : template <typename Tag>
      23             : struct Normalized;
      24             : }  // namespace Tags
      25             : /// \endcond
      26             : 
      27             : // IWYU pragma: no_forward_declare Tensor
      28             : 
      29             : namespace RelativisticEuler {
      30             : namespace Valencia {
      31             : 
      32             : /// @{
      33             : /*!
      34             :  * \brief Compute the characteristic speeds for the Valencia formulation
      35             :  * of the relativistic Euler system.
      36             :  *
      37             :  * The principal symbol of the system is diagonalized so that the elements of
      38             :  * the diagonal matrix are the \f$(\text{Dim} + 2)\f$ characteristic speeds
      39             :  *
      40             :  * \f{align*}
      41             :  * \lambda_1 &= \alpha \Lambda^- - \beta_n,\\
      42             :  * \lambda_{i + 1} &= \alpha v_n - \beta_n,\quad i = 1,...,\text{Dim}\\
      43             :  * \lambda_{\text{Dim} + 2} &= \alpha \Lambda^+ - \beta_n,
      44             :  * \f}
      45             :  *
      46             :  * where \f$\alpha\f$ is the lapse, \f$\beta_n = n_i \beta^i\f$ and
      47             :  * \f$v_n = n_i v^i\f$ are the projections of the shift \f$\beta^i\f$ and the
      48             :  * spatial velocity \f$v^i\f$ onto the normal one-form \f$n_i\f$, respectively,
      49             :  * and
      50             :  *
      51             :  * \f{align*}
      52             :  * \Lambda^{\pm} &= \dfrac{1}{1 - v^2 c_s^2}\left[ v_n (1- c_s^2) \pm
      53             :  * c_s\sqrt{\left(1 - v^2\right)\left[1 - v^2 c_s^2 - v_n^2(1 - c_s^2)\right]}
      54             :  * \right],
      55             :  * \f}
      56             :  *
      57             :  * where \f$v^2 = \gamma_{ij}v^iv^j\f$ is the magnitude squared of the spatial
      58             :  * velocity, and \f$c_s\f$ is the sound speed.
      59             :  */
      60             : template <size_t Dim>
      61           1 : void characteristic_speeds(
      62             :     gsl::not_null<std::array<DataVector, Dim + 2>*> char_speeds,
      63             :     const Scalar<DataVector>& lapse, const tnsr::I<DataVector, Dim>& shift,
      64             :     const tnsr::I<DataVector, Dim>& spatial_velocity,
      65             :     const Scalar<DataVector>& spatial_velocity_squared,
      66             :     const Scalar<DataVector>& sound_speed_squared,
      67             :     const tnsr::i<DataVector, Dim>& normal);
      68             : 
      69             : template <size_t Dim>
      70           1 : std::array<DataVector, Dim + 2> characteristic_speeds(
      71             :     const Scalar<DataVector>& lapse, const tnsr::I<DataVector, Dim>& shift,
      72             :     const tnsr::I<DataVector, Dim>& spatial_velocity,
      73             :     const Scalar<DataVector>& spatial_velocity_squared,
      74             :     const Scalar<DataVector>& sound_speed_squared,
      75             :     const tnsr::i<DataVector, Dim>& normal);
      76             : /// @}
      77             : 
      78             : /*!
      79             :  * \brief Right eigenvectors of the Valencia formulation
      80             :  *
      81             :  * The principal symbol of the Valencia formulation, \f$A\f$, is diagonalizable,
      82             :  * allowing the introduction of characteristic variables \f$U_\text{char}\f$.
      83             :  * In terms of the conservative variables \f$U\f$, \f$U = RU_\text{char}\f$ and
      84             :  * \f$U_\text{char} = LU\f$, where \f$R\f$ is the matrix whose columns are the
      85             :  * right eigenvectors of \f$A\f$, and \f$L = R^{-1}\f$ contains the left
      86             :  * eigenvectors as rows. Here we take the ordering
      87             :  * \f$U = [\tilde D, \tilde \tau, \tilde S_i]^T\f$. Explicitly,
      88             :  * \f$R = [R_-\, R_1\, R_2\, R_3\, R_+]\f$, where [Teukolsky, to be published]
      89             :  *
      90             :  * \f{align*}
      91             :  * R_\pm = \left[\begin{array}{c}
      92             :  * 1 \\
      93             :  * (hW - 1) \pm \dfrac{hW c_s v_n}{d} \\
      94             :  * hW\left(v_i \pm \dfrac{c_s}{d}n_i\right)
      95             :  * \end{array}\right],\qquad
      96             :  * R_{1,2} = \left[\begin{array}{c}
      97             :  * Wv_{(1,2)} \\
      98             :  * W\left(2hW - 1\right)v_{(1,2)} \\
      99             :  * h\left(t_{(1,2)i} + 2W^2v_{(1,2)}v_i \right)
     100             :  * \end{array}\right],\qquad
     101             :  * R_3 = \left[\begin{array}{c}
     102             :  * K \\
     103             :  * K(hW - 1) - hWc_s^2 \\
     104             :  * hW(K - c_s^2)v_i
     105             :  * \end{array}\right].
     106             :  * \f}
     107             :  *
     108             :  * (One disregards \f$R_2\f$ if working in 2-d, and also \f$R_1\f$ if
     109             :  * working in 1-d, so that the number of eigenvectors is
     110             :  * always \f$\text{Dim} + 2\f$.) In the above expressions, \f$n_i\f$ is the unit
     111             :  * spatial normal along which the characteristic decomposition is carried
     112             :  * out, and \f$t_{(1,2)}^i\f$ are unit spatial vectors forming an orthonormal
     113             :  * basis with the normal. In addition, \f$h\f$ is the
     114             :  * specific enthalpy, \f$W\f$ is the Lorentz factor, \f$v^i\f$ is the spatial
     115             :  * velocity, \f$v_n = n_i v^i\f$, \f$v_{(1,2)} = v_i t^i_{(1,2)}\f$,
     116             :  * \f$c_s\f$ is the sound speed,
     117             :  * \f$d = W\sqrt{1 - v^2c_s^2 - v_n^2(1 - c_s^2)}\f$,
     118             :  * \f$K = (1/\rho)(\partial p/\partial\epsilon)_\rho\f$, where \f$\rho\f$ is the
     119             :  * rest mass density, \f$p\f$ is the pressure, and \f$\epsilon\f$ is the
     120             :  * specific internal energy. Finally, and for numerical purposes, the quantity
     121             :  * \f$(hW - 1)\f$ is computed independently using the expression
     122             :  *
     123             :  * \f{align*}
     124             :  * hW - 1 = W\left(\epsilon + \frac{p}{\rho} + \frac{Wv^2}{W + 1}\right),
     125             :  * \f}
     126             :  *
     127             :  * which has a well-behaved Newtonian limit.
     128             :  *
     129             :  * Following the notation in Valencia::characteristic_speeds, \f$R_\pm\f$
     130             :  * are the eigenvectors of the nondegenerate eigenvalues
     131             :  * \f$(\alpha\Lambda^\pm - \beta_n)\f$, while \f$ R_{1,2,3}\f$ are the
     132             :  * eigenvectors of the Dim-fold degenerate eigenvalue
     133             :  * \f$(\alpha v_n - \beta_n)\f$.
     134             :  */
     135             : template <size_t Dim>
     136           1 : Matrix right_eigenvectors(const Scalar<double>& rest_mass_density,
     137             :                           const tnsr::I<double, Dim>& spatial_velocity,
     138             :                           const Scalar<double>& specific_internal_energy,
     139             :                           const Scalar<double>& pressure,
     140             :                           const Scalar<double>& specific_enthalpy,
     141             :                           const Scalar<double>& kappa_over_density,
     142             :                           const Scalar<double>& sound_speed_squared,
     143             :                           const Scalar<double>& lorentz_factor,
     144             :                           const tnsr::ii<double, Dim>& spatial_metric,
     145             :                           const tnsr::II<double, Dim>& inv_spatial_metric,
     146             :                           const Scalar<double>& det_spatial_metric,
     147             :                           const tnsr::i<double, Dim>& unit_normal);
     148             : 
     149             : /*!
     150             :  * \brief Left eigenvectors of the Valencia formulation
     151             :  *
     152             :  * The principal symbol of the Valencia formulation, \f$A\f$, is diagonalizable,
     153             :  * allowing the introduction of characteristic variables \f$U_\text{char}\f$.
     154             :  * In terms of the conservative variables \f$U\f$, \f$U = RU_\text{char}\f$ and
     155             :  * \f$U_\text{char} = LU\f$, where \f$R\f$ is the matrix whose columns are the
     156             :  * right eigenvectors of \f$A\f$, and \f$L = R^{-1}\f$ contains the left
     157             :  * eigenvectors as rows. Here we take the ordering
     158             :  * \f$U = [\tilde D, \tilde \tau, \tilde S_i]^T\f$. Explicitly,
     159             :  * \f$L = [L_-\, L_1\, L_2\, L_3\, L_+]^T\f$, where [Teukolsky, to be published]
     160             :  *
     161             :  * \f{align*}
     162             :  * L_\pm &= \dfrac{1}{2h W c_s^2(1 - v_n^2)}\left[\begin{array}{ccc}
     163             :  * W(1-v_n^2)\left[c_s^2(h + W) - K(h - W)\right] - c_\pm, &
     164             :  * b_\pm, &
     165             :  * -a v^i + c_s\left(c_s v_n \pm d\right)n^i
     166             :  * \end{array}\right],\\
     167             :  * L_{1,2} &= \dfrac{1}{h\left(1 - v_n^2\right)}\left[\begin{array}{ccc}
     168             :  * -v_{(1,2)}, & -v_{(1,2)}, & v_{(1,2)}v_n n^i + (1 - v_n^2)t_{(1,2)}^i
     169             :  * \end{array}\right],\\
     170             :  * L_3 &= \dfrac{1}{hc_s^2}\left[\begin{array}{ccc}
     171             :  * h - W, & -W, & Wv^i
     172             :  * \end{array}\right],
     173             :  * \f}
     174             :  *
     175             :  * with the definitions
     176             :  *
     177             :  * \f{align*}
     178             :  * d &= W\sqrt{1 - v^2c_s^2 - v_n^2(1 - c_s^2)}, \\
     179             :  * a &= W^2\left(1- v_n^2\right)\left(K + c_s^2\right), \\
     180             :  * c_\pm &= c_s\left(c_s \pm v_nd\right), \\
     181             :  * b_\pm &= a - c_\pm.
     182             :  * \f}
     183             :  *
     184             :  * The rest of the variables are the same as those in
     185             :  * Valencia::right_eigenvectors. For numerical purposes, here
     186             :  * the quantity \f$(h - W)\f$ is computed independently using the expression
     187             :  *
     188             :  * \f{align*}
     189             :  * h - W =\epsilon + \frac{p}{\rho} - \frac{W^2v^2}{W + 1},
     190             :  * \f}
     191             :  *
     192             :  * which has a well-behaved Newtonian limit.
     193             :  *
     194             :  * Following the notation in Valencia::characteristic_speeds, \f$L_\pm\f$
     195             :  * are the eigenvectors of the nondegenerate eigenvalues
     196             :  * \f$(\alpha\Lambda^\pm - \beta_n)\f$, while \f$ L_{1,2,3}\f$ are the
     197             :  * eigenvectors of the Dim-fold degenerate eigenvalue
     198             :  * \f$(\alpha v_n - \beta_n)\f$.
     199             :  */
     200             : template <size_t Dim>
     201           1 : Matrix left_eigenvectors(const Scalar<double>& rest_mass_density,
     202             :                          const tnsr::I<double, Dim>& spatial_velocity,
     203             :                          const Scalar<double>& specific_internal_energy,
     204             :                          const Scalar<double>& pressure,
     205             :                          const Scalar<double>& specific_enthalpy,
     206             :                          const Scalar<double>& kappa_over_density,
     207             :                          const Scalar<double>& sound_speed_squared,
     208             :                          const Scalar<double>& lorentz_factor,
     209             :                          const tnsr::ii<double, Dim>& spatial_metric,
     210             :                          const tnsr::II<double, Dim>& inv_spatial_metric,
     211             :                          const Scalar<double>& det_spatial_metric,
     212             :                          const tnsr::i<double, Dim>& unit_normal);
     213             : 
     214           1 : namespace Tags {
     215             : template <size_t Dim>
     216           0 : struct CharacteristicSpeedsCompute : Tags::CharacteristicSpeeds<Dim>,
     217             :                                      db::ComputeTag {
     218           0 :   using base = Tags::CharacteristicSpeeds<Dim>;
     219           0 :   using argument_tags =
     220             :       tmpl::list<gr::Tags::Lapse<DataVector>, gr::Tags::Shift<DataVector, Dim>,
     221             :                  gr::Tags::SpatialMetric<DataVector, Dim>,
     222             :                  hydro::Tags::SpatialVelocity<DataVector, Dim>,
     223             :                  hydro::Tags::SoundSpeedSquared<DataVector>,
     224             :                  ::Tags::Normalized<domain::Tags::UnnormalizedFaceNormal<Dim>>>;
     225             : 
     226           0 :   using volume_tags = tmpl::list<>;
     227             : 
     228           0 :   using return_type = std::array<DataVector, Dim + 2>;
     229             : 
     230           0 :   static constexpr void function(
     231             :       const gsl::not_null<return_type*> result, const Scalar<DataVector>& lapse,
     232             :       const tnsr::I<DataVector, Dim>& shift,
     233             :       const tnsr::ii<DataVector, Dim>& spatial_metric,
     234             :       const tnsr::I<DataVector, Dim>& spatial_velocity,
     235             :       const Scalar<DataVector>& sound_speed_squared,
     236             :       const tnsr::i<DataVector, Dim>& unit_normal) {
     237             :     characteristic_speeds(
     238             :         result, lapse, shift, spatial_velocity,
     239             :         dot_product(spatial_velocity, spatial_velocity, spatial_metric),
     240             :         sound_speed_squared, unit_normal);
     241             :   }
     242             : };
     243             : 
     244             : }  // namespace Tags
     245             : 
     246           0 : struct ComputeLargestCharacteristicSpeed {
     247           0 :   using argument_tags = tmpl::list<>;
     248           0 :   static double apply() { return 1.0; }
     249             : };
     250             : 
     251             : }  // namespace Valencia
     252             : }  // namespace RelativisticEuler

Generated by: LCOV version 1.14