SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/RadiationTransport/M1Grey - M1HydroCoupling.hpp Hit Total Coverage
Commit: 3c072f0ce967e2e56649d3fa12aa2a0e4fe2a42e Lines: 2 6 33.3 %
Date: 2024-04-23 20:50:18
Legend: Lines: hit not hit

          Line data    Source code
       1           1 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : ///\file
       5             : /// Defines functions to compute the M1-hydro
       6             : /// coupling terms.
       7             : 
       8             : #pragma once
       9             : 
      10             : #include <tuple>
      11             : 
      12             : #include "DataStructures/DataBox/DataBox.hpp"
      13             : #include "DataStructures/Tensor/TypeAliases.hpp"  // IWYU pragma: keep
      14             : #include "Evolution/Systems/RadiationTransport/M1Grey/Tags.hpp"  // IWYU pragma: keep
      15             : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      16             : #include "PointwiseFunctions/Hydro/Tags.hpp"
      17             : #include "Utilities/Requires.hpp"
      18             : #include "Utilities/TMPL.hpp"
      19             : #include "Utilities/TaggedTuple.hpp"
      20             : 
      21             : // IWYU pragma: no_forward_declare Tensor
      22             : 
      23             : /// \cond
      24             : class DataVector;
      25             : namespace Parallel {
      26             : template <typename Metavariables>
      27             : class GlobalCache;
      28             : }  // namespace Parallel
      29             : // IWYU pragma: no_forward_declare db::DataBox
      30             : /// \endcond
      31             : 
      32             : namespace RadiationTransport {
      33             : namespace M1Grey {
      34             : 
      35             : // Implementation of the coupling terms for
      36             : // individual species
      37             : namespace detail {
      38             : void compute_m1_hydro_coupling_impl(
      39             :     gsl::not_null<Scalar<DataVector>*> source_n,
      40             :     gsl::not_null<tnsr::i<DataVector, 3>*> source_i,
      41             :     const Scalar<DataVector>& emissivity,
      42             :     const Scalar<DataVector>& absorption_opacity,
      43             :     const Scalar<DataVector>& scattering_opacity,
      44             :     const Scalar<DataVector>& comoving_energy_density,
      45             :     const Scalar<DataVector>& comoving_momentum_density_normal,
      46             :     const tnsr::i<DataVector, 3>& comoving_momentum_density_spatial,
      47             :     const tnsr::I<DataVector, 3>& fluid_velocity,
      48             :     const Scalar<DataVector>& fluid_lorentz_factor,
      49             :     const Scalar<DataVector>& lapse,
      50             :     const tnsr::ii<DataVector, 3>& spatial_metric,
      51             :     const Scalar<DataVector>& sqrt_det_spatial_metric);
      52             : }  // namespace detail
      53             : 
      54             : template <typename NeutrinoSpeciesList>
      55           0 : struct ComputeM1HydroCoupling;
      56             : /*!
      57             :  * Compute the source terms of the M1 equation due to neutrino-matter
      58             :  * interactions.
      59             :  * These are:
      60             :  *
      61             :  * \f{align}{
      62             :  * \partial_t \tilde E = \alpha W (\sqrt{\gamma} \eta - \kappa_a \tilde J)
      63             :  * + \alpha (\kappa_a + \kappa_s) H_n\\
      64             :  * \partial_t \tilde S_i = \alpha u_i (\sqrt{\gamma} \eta - \kappa_a \tilde J)
      65             :  * - \alpha  (\kappa_a + \kappa_s) H_i.
      66             :  * \f}
      67             :  *
      68             :  * with \f$W\f$ the Lorentz factor, \f$u_i = W v_i\f$ the spatial components of
      69             :  * the fluid 4-velocity, \f$\eta\f$ the emissivity, \f$\kappa_{a,s}\f$
      70             :  * the absorption and scattering opacities, \f$J\f$ the comoving energy
      71             :  * density, and \f$H_{n,i}\f$ the normal and spatial components of the comoving
      72             :  * flux density.
      73             :  *
      74             :  * The function returns in `source_n` the energy source and in
      75             :  * `source_i` the momentum source. We write a separate action for these
      76             :  * sources to make it easier to switch between implicit / explicit time
      77             :  * stepping, as well as to add the source terms to both the fluid and M1
      78             :  * evolutions.
      79             :  */
      80             : template <typename... NeutrinoSpecies>
      81           1 : struct ComputeM1HydroCoupling<tmpl::list<NeutrinoSpecies...>> {
      82           0 :   using return_tags = tmpl::list<
      83             :       Tags::M1HydroCouplingNormal<NeutrinoSpecies>...,
      84             :       Tags::M1HydroCouplingSpatial<Frame::Inertial, NeutrinoSpecies>...>;
      85             : 
      86           0 :   using argument_tags = tmpl::list<
      87             :       Tags::GreyEmissivity<NeutrinoSpecies>...,
      88             :       Tags::GreyAbsorptionOpacity<NeutrinoSpecies>...,
      89             :       Tags::GreyScatteringOpacity<NeutrinoSpecies>...,
      90             :       Tags::TildeJ<NeutrinoSpecies>..., Tags::TildeHNormal<NeutrinoSpecies>...,
      91             :       Tags::TildeHSpatial<Frame::Inertial, NeutrinoSpecies>...,
      92             :       hydro::Tags::SpatialVelocity<DataVector, 3>,
      93             :       hydro::Tags::LorentzFactor<DataVector>, gr::Tags::Lapse<DataVector>,
      94             :       gr::Tags::SpatialMetric<DataVector, 3>,
      95             :       gr::Tags::SqrtDetSpatialMetric<DataVector>>;
      96             : 
      97           0 :   static void apply(
      98             :       const gsl::not_null<typename Tags::M1HydroCouplingNormal<
      99             :           NeutrinoSpecies>::type*>... source_n,
     100             :       const gsl::not_null<typename Tags::M1HydroCouplingSpatial<
     101             :           Frame::Inertial, NeutrinoSpecies>::type*>... source_i,
     102             :       const typename Tags::GreyEmissivity<NeutrinoSpecies>::type&... emissivity,
     103             :       const typename Tags::GreyAbsorptionOpacity<
     104             :           NeutrinoSpecies>::type&... absorption_opacity,
     105             :       const typename Tags::GreyScatteringOpacity<
     106             :           NeutrinoSpecies>::type&... scattering_opacity,
     107             :       const typename Tags::TildeJ<NeutrinoSpecies>::type&... tilde_j,
     108             :       const typename Tags::TildeHNormal<NeutrinoSpecies>::type&... tilde_hn,
     109             :       const typename Tags::TildeHSpatial<Frame::Inertial,
     110             :                                          NeutrinoSpecies>::type&... tilde_hi,
     111             :       const tnsr::I<DataVector, 3>& spatial_velocity,
     112             :       const Scalar<DataVector>& lorentz_factor, const Scalar<DataVector>& lapse,
     113             :       const tnsr::ii<DataVector, 3>& spatial_metric,
     114             :       const Scalar<DataVector>& sqrt_det_spatial_metric) {
     115             :     EXPAND_PACK_LEFT_TO_RIGHT(detail::compute_m1_hydro_coupling_impl(
     116             :         source_n, source_i, emissivity, absorption_opacity, scattering_opacity,
     117             :         tilde_j, tilde_hn, tilde_hi, spatial_velocity, lorentz_factor, lapse,
     118             :         spatial_metric, sqrt_det_spatial_metric));
     119             :   }
     120             : };
     121             : 
     122             : }  // namespace M1Grey
     123             : }  // namespace RadiationTransport

Generated by: LCOV version 1.14