SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/ScalarWave - Characteristics.hpp Hit Total Coverage
Commit: b1342d46f40e2d46bbd11d0cef68fd973031a24b Lines: 1 20 5.0 %
Date: 2020-09-24 20:24: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 <array>
       7             : #include <cstddef>
       8             : 
       9             : #include "DataStructures/DataBox/Tag.hpp"
      10             : #include "DataStructures/DataVector.hpp"
      11             : #include "DataStructures/Tensor/Tensor.hpp"
      12             : #include "Domain/FaceNormal.hpp"
      13             : #include "Evolution/Systems/ScalarWave/Tags.hpp"
      14             : #include "Utilities/Gsl.hpp"
      15             : #include "Utilities/MakeWithValue.hpp"
      16             : #include "Utilities/TMPL.hpp"
      17             : 
      18             : /// \cond
      19             : template <typename>
      20             : class Variables;
      21             : 
      22             : namespace Tags {
      23             : template <typename Tag>
      24             : struct Normalized;
      25             : }  // namespace Tags
      26             : /// \endcond
      27             : 
      28             : namespace ScalarWave {
      29             : // @{
      30             : /*!
      31             :  * \brief Compute the characteristic speeds for the scalar wave system.
      32             :  *
      33             :  * Computes the speeds as described in "Optimal constraint projection for
      34             :  * hyperbolic evolution systems" by Holst et al. \cite Holst2004wt
      35             :  * [see text following Eq.(32)]. The characteristic fields' names used here
      36             :  * differ from this paper:
      37             :  *
      38             :  * \f{align*}
      39             :  * \mathrm{SpECTRE} && \mathrm{Holst} \\
      40             :  * v^{\hat \psi} && Z^1 \\
      41             :  * v^{\hat 0}_{i} && Z^{2}_{i} \\
      42             :  * v^{\hat \pm} && u^{1\pm}
      43             :  * \f}
      44             :  *
      45             :  * The corresponding characteristic speeds \f$\lambda_{\hat \alpha}\f$ are given
      46             :  * in the text following Eq.(38) of \cite Holst2004wt :
      47             :  *
      48             :  * \f{align*}
      49             :  * \lambda_{\hat \psi} =& 0 \\
      50             :  * \lambda_{\hat 0} =& 0 \\
      51             :  * \lambda_{\hat \pm} =& \pm 1.
      52             :  * \f}
      53             :  */
      54             : template <size_t Dim>
      55             : std::array<DataVector, 4> characteristic_speeds(
      56             :     const tnsr::i<DataVector, Dim, Frame::Inertial>&
      57             :         unit_normal_one_form) noexcept;
      58             : 
      59             : template <size_t Dim>
      60           0 : void characteristic_speeds(
      61             :     gsl::not_null<std::array<DataVector, 4>*> char_speeds,
      62             :     const tnsr::i<DataVector, Dim, Frame::Inertial>&
      63             :         unit_normal_one_form) noexcept;
      64             : 
      65           1 : namespace Tags {
      66             : template <size_t Dim>
      67             : struct CharacteristicSpeedsCompute : Tags::CharacteristicSpeeds<Dim>,
      68           0 :                                      db::ComputeTag {
      69           0 :   using base = Tags::CharacteristicSpeeds<Dim>;
      70           0 :   using return_type = typename base::type;
      71           0 :   using argument_tags =
      72             :       tmpl::list<::Tags::Normalized<domain::Tags::UnnormalizedFaceNormal<Dim>>>;
      73             : 
      74           0 :   static void function(gsl::not_null<return_type*> char_speeds,
      75             :                        const tnsr::i<DataVector, Dim, Frame::Inertial>&
      76             :                            unit_normal_one_form) noexcept {
      77             :     characteristic_speeds(char_speeds, unit_normal_one_form);
      78             :   }
      79             : };
      80             : }  // namespace Tags
      81             : // @}
      82             : 
      83             : // @{
      84             : /*!
      85             :  * \brief Computes characteristic fields from evolved fields
      86             :  *
      87             :  * \ref Tags::CharacteristicFieldsCompute and
      88             :  * \ref Tags::EvolvedFieldsFromCharacteristicFieldsCompute convert between
      89             :  * characteristic and evolved fields for the scalar-wave system.
      90             :  *
      91             :  * \ref Tags::CharacteristicFieldsCompute computes
      92             :  * characteristic fields as described in "Optimal constraint projection for
      93             :  * hyperbolic evolution systems" by Holst et al. \cite Holst2004wt .
      94             :  * Their names used here differ from this paper:
      95             :  *
      96             :  * \f{align*}
      97             :  * \mathrm{SpECTRE} && \mathrm{Holst} \\
      98             :  * v^{\hat \psi} && Z^1 \\
      99             :  * v^{\hat 0}_{i} && Z^{2}_{i} \\
     100             :  * v^{\hat \pm} && u^{1\pm}
     101             :  * \f}
     102             :  *
     103             :  * The characteristic fields \f${v}^{\hat \alpha}\f$ are given in terms of
     104             :  * the evolved fields by Eq.(33) - (35) of \cite Holst2004wt, respectively:
     105             :  *
     106             :  * \f{align*}
     107             :  * v^{\hat \psi} =& \psi \\
     108             :  * v^{\hat 0}_{i} =& (\delta^k_i - n_i n^k) \Phi_{k} := P^k_i \Phi_{k} \\
     109             :  * v^{\hat \pm} =& \Pi \pm n^i \Phi_{i} - \gamma_2\psi
     110             :  * \f}
     111             :  *
     112             :  * where \f$\psi\f$ is the scalar field, \f$\Phi_{i}=\partial_i \psi\f$ is an
     113             :  * auxiliary variable, \f$\Pi\f$ is a conjugate momentum, \f$\gamma_2\f$
     114             :  * is a constraint damping parameter, and \f$n_k\f$ is the unit normal to the
     115             :  * surface along which the characteristic fields are defined.
     116             :  *
     117             :  * \ref Tags::EvolvedFieldsFromCharacteristicFieldsCompute computes evolved
     118             :  * fields \f$u_\alpha\f$ in terms of the characteristic fields. This uses the
     119             :  * inverse of above relations:
     120             :  *
     121             :  * \f{align*}
     122             :  * \psi =& v^{\hat \psi}, \\
     123             :  * \Pi =& \frac{1}{2}(v^{\hat +} + v^{\hat -}) + \gamma_2 v^{\hat \psi}, \\
     124             :  * \Phi_{i} =& \frac{1}{2}(v^{\hat +} - v^{\hat -}) n_i + v^{\hat 0}_{i}.
     125             :  * \f}
     126             :  *
     127             :  * The corresponding characteristic speeds \f$\lambda_{\hat \alpha}\f$
     128             :  * are computed by \ref Tags::CharacteristicSpeedsCompute .
     129             :  */
     130             : template <size_t Dim>
     131             : Variables<tmpl::list<Tags::VPsi, Tags::VZero<Dim>, Tags::VPlus, Tags::VMinus>>
     132             : characteristic_fields(const Scalar<DataVector>& gamma_2,
     133             :                       const Scalar<DataVector>& psi,
     134             :                       const Scalar<DataVector>& pi,
     135             :                       const tnsr::i<DataVector, Dim, Frame::Inertial>& phi,
     136             :                       const tnsr::i<DataVector, Dim, Frame::Inertial>&
     137             :                           unit_normal_one_form) noexcept;
     138             : 
     139             : template <size_t Dim>
     140           0 : void characteristic_fields(
     141             :     gsl::not_null<Variables<
     142             :         tmpl::list<Tags::VPsi, Tags::VZero<Dim>, Tags::VPlus, Tags::VMinus>>*>
     143             :         char_fields,
     144             :     const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& psi,
     145             :     const Scalar<DataVector>& pi,
     146             :     const tnsr::i<DataVector, Dim, Frame::Inertial>& phi,
     147             :     const tnsr::i<DataVector, Dim, Frame::Inertial>&
     148             :         unit_normal_one_form) noexcept;
     149             : 
     150             : namespace Tags {
     151             : template <size_t Dim>
     152             : struct CharacteristicFieldsCompute : Tags::CharacteristicFields<Dim>,
     153           0 :                                      db::ComputeTag {
     154           0 :   using base = Tags::CharacteristicFields<Dim>;
     155           0 :   using return_type = typename base::type;
     156           0 :   using argument_tags =
     157             :       tmpl::list<Tags::ConstraintGamma2, Psi, Pi, Phi<Dim>,
     158             :                  ::Tags::Normalized<domain::Tags::UnnormalizedFaceNormal<Dim>>>;
     159             : 
     160           0 :   static void function(const gsl::not_null<return_type*> char_fields,
     161             :                        const Scalar<DataVector>& gamma_2,
     162             :                        const Scalar<DataVector>& psi,
     163             :                        const Scalar<DataVector>& pi,
     164             :                        const tnsr::i<DataVector, Dim, Frame::Inertial>& phi,
     165             :                        const tnsr::i<DataVector, Dim, Frame::Inertial>&
     166             :                            unit_normal_one_form) noexcept {
     167             :     characteristic_fields(char_fields, gamma_2, psi, pi, phi,
     168             :                           unit_normal_one_form);
     169             :   };
     170             : };
     171             : }  // namespace Tags
     172             : // @}
     173             : 
     174             : // @{
     175             : /*!
     176             :  * \brief Compute evolved fields from characteristic fields.
     177             :  *
     178             :  * For expressions used here to compute evolved fields from characteristic ones,
     179             :  * see \ref Tags::CharacteristicFieldsCompute.
     180             :  */
     181             : template <size_t Dim>
     182             : Variables<tmpl::list<Psi, Pi, Phi<Dim>>>
     183             : evolved_fields_from_characteristic_fields(
     184             :     const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
     185             :     const tnsr::i<DataVector, Dim, Frame::Inertial>& v_zero,
     186             :     const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
     187             :     const tnsr::i<DataVector, Dim, Frame::Inertial>&
     188             :         unit_normal_one_form) noexcept;
     189             : 
     190             : template <size_t Dim>
     191           0 : void evolved_fields_from_characteristic_fields(
     192             :     gsl::not_null<Variables<tmpl::list<Psi, Pi, Phi<Dim>>>*> evolved_fields,
     193             :     const Scalar<DataVector>& gamma_2, const Scalar<DataVector>& v_psi,
     194             :     const tnsr::i<DataVector, Dim, Frame::Inertial>& v_zero,
     195             :     const Scalar<DataVector>& v_plus, const Scalar<DataVector>& v_minus,
     196             :     const tnsr::i<DataVector, Dim, Frame::Inertial>&
     197             :         unit_normal_one_form) noexcept;
     198             : 
     199             : namespace Tags {
     200             : template <size_t Dim>
     201             : struct EvolvedFieldsFromCharacteristicFieldsCompute
     202             :     : Tags::EvolvedFieldsFromCharacteristicFields<Dim>,
     203           0 :       db::ComputeTag {
     204           0 :   using base = Tags::EvolvedFieldsFromCharacteristicFields<Dim>;
     205           0 :   using return_type = typename base::type;
     206           0 :   using argument_tags =
     207             :       tmpl::list<Tags::ConstraintGamma2, Tags::VPsi, Tags::VZero<Dim>,
     208             :                  Tags::VPlus, Tags::VMinus,
     209             :                  ::Tags::Normalized<domain::Tags::UnnormalizedFaceNormal<Dim>>>;
     210             : 
     211           0 :   static void function(const gsl::not_null<return_type*> evolved_fields,
     212             :                        const Scalar<DataVector>& gamma_2,
     213             :                        const Scalar<DataVector>& v_psi,
     214             :                        const tnsr::i<DataVector, Dim, Frame::Inertial>& v_zero,
     215             :                        const Scalar<DataVector>& v_plus,
     216             :                        const Scalar<DataVector>& v_minus,
     217             :                        const tnsr::i<DataVector, Dim, Frame::Inertial>&
     218             :                            unit_normal_one_form) noexcept {
     219             :     evolved_fields_from_characteristic_fields(evolved_fields, gamma_2, v_psi,
     220             :                                               v_zero, v_plus, v_minus,
     221             :                                               unit_normal_one_form);
     222             :   };
     223             : };
     224             : }  // namespace Tags
     225             : // @}
     226             : }  // namespace ScalarWave

Generated by: LCOV version 1.14