M1HydroCoupling.hpp
Go to the documentation of this file.
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 
13 #include "DataStructures/DataBox/DataBoxTag.hpp" // for item_type
14 #include "DataStructures/Tensor/TypeAliases.hpp" // IWYU pragma: keep
15 #include "Evolution/Systems/RadiationTransport/M1Grey/Tags.hpp" // IWYU pragma: keep
16 #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
17 #include "PointwiseFunctions/Hydro/Tags.hpp"
18 #include "Utilities/Requires.hpp"
19 #include "Utilities/TMPL.hpp"
20 #include "Utilities/TaggedTuple.hpp"
21 
22 // IWYU pragma: no_forward_declare Tensor
23 
24 /// \cond
25 class DataVector;
26 namespace Parallel {
27 template <typename Metavariables>
28 class ConstGlobalCache;
29 } // namespace Parallel
30 // IWYU pragma: no_forward_declare db::DataBox
31 /// \endcond
32 
33 namespace RadiationTransport {
34 namespace M1Grey {
35 
36 // Implementation of the coupling terms for
37 // individual species
38 namespace detail {
39 void compute_m1_hydro_coupling_impl(
41  gsl::not_null<tnsr::i<DataVector, 3>*> source_i,
42  const Scalar<DataVector>& emissivity,
43  const Scalar<DataVector>& absorption_opacity,
44  const Scalar<DataVector>& scattering_opacity,
45  const Scalar<DataVector>& comoving_energy_density,
46  const Scalar<DataVector>& comoving_momentum_density_normal,
47  const tnsr::i<DataVector, 3>& comoving_momentum_density_spatial,
48  const tnsr::I<DataVector, 3>& fluid_velocity,
49  const Scalar<DataVector>& fluid_lorentz_factor,
51  const tnsr::ii<DataVector, 3>& spatial_metric,
52  const Scalar<DataVector>& sqrt_det_spatial_metric) noexcept;
53 } // namespace detail
54 
55 template <typename NeutrinoSpeciesList>
57 /*!
58  * Compute the source terms of the M1 equation due to neutrino-matter
59  * interactions.
60  * These are:
61  *
62  * \f{align}{
63  * \partial_t \tilde E = \alpha W (\sqrt{\gamma} \eta - \kappa_a \tilde J)
64  * + \alpha (\kappa_a + \kappa_s) H_n\\
65  * \partial_t \tilde S_i = \alpha u_i (\sqrt{\gamma} \eta - \kappa_a \tilde J)
66  * - \alpha (\kappa_a + \kappa_s) H_i.
67  * \f}
68  *
69  * with \f$W\f$ the Lorentz factor, \f$u_i = W v_i\f$ the spatial components of
70  * the fluid 4-velocity, \f$\eta\f$ the emissivity, \f$\kappa_{a,s}\f$
71  * the absorption and scattering opacities, \f$J\f$ the comoving energy
72  * density, and \f$H_{n,i}\f$ the normal and spatial components of the comoving
73  * flux density.
74  *
75  * The function returns in `source_n` the energy source and in
76  * `source_i` the momentum source. We write a separate action for these
77  * sources to make it easier to switch between implicit / explicit time
78  * stepping, as well as to add the source terms to both the fluid and M1
79  * evolutions.
80  */
81 template <typename... NeutrinoSpecies>
82 struct ComputeM1HydroCoupling<tmpl::list<NeutrinoSpecies...>> {
83  using return_tags = tmpl::list<
86 
87  using argument_tags =
88  tmpl::list<Tags::GreyEmissivity<NeutrinoSpecies>...,
97 
98  static void apply(
102  Frame::Inertial, NeutrinoSpecies>>*>... source_i,
103  const db::const_item_type<
105  const db::const_item_type<
106  Tags::GreyAbsorptionOpacity<NeutrinoSpecies>>&... absorption_opacity,
107  const db::const_item_type<
108  Tags::GreyScatteringOpacity<NeutrinoSpecies>>&... scattering_opacity,
110  const db::const_item_type<
112  const db::const_item_type<
114  const db::const_item_type<
116  spatial_velocity,
117  const db::const_item_type<hydro::Tags::LorentzFactor<DataVector>>&
118  lorentz_factor,
119  const db::const_item_type<gr::Tags::Lapse<>>& lapse,
120  const tnsr::ii<DataVector, 3>& spatial_metric,
121  const db::const_item_type<gr::Tags::SqrtDetSpatialMetric<>>&
122  sqrt_det_spatial_metric) noexcept {
123  EXPAND_PACK_LEFT_TO_RIGHT(detail::compute_m1_hydro_coupling_impl(
124  source_n, source_i, emissivity, absorption_opacity, scattering_opacity,
125  tilde_j, tilde_hn, tilde_hi, spatial_velocity, lorentz_factor, lapse,
126  spatial_metric, sqrt_det_spatial_metric));
127  }
128 };
129 
130 } // namespace M1Grey
131 } // namespace RadiationTransport
132 
The spatial velocity of the fluid, where . Here is the spatial part of the 4-velocity of the fluid...
Definition: Tags.hpp:142
#define EXPAND_PACK_LEFT_TO_RIGHT(...)
Expand a parameter pack evaluating the terms from left to right.
Definition: TMPL.hpp:562
tnsr::ii< DataType, SpatialDim, Frame > spatial_metric(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute spatial metric from spacetime metric.
Definition: Digraph.hpp:11
Definition: Tags.hpp:44
Items related to general relativistic radiation transport.
Definition: Characteristics.cpp:10
The absorption opacity of the fluid for neutrinos of a given species.
Definition: Tags.hpp:129
Definition: Tags.hpp:52
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
Defines the type alias Requires.
The spatial components of source term coupling the M1 and hydro equations.
Definition: Tags.hpp:168
Scalar< DataType > lapse(const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute lapse from shift and spacetime metric.
Definition: Determinant.hpp:11
The scattering opacity of the fluid for neutrinos of a given species.
Definition: Tags.hpp:141
The fluid-frame densitized energy density of neutrinos of a given species .
Definition: Tags.hpp:84
The normal component of the fluid-frame momentum density of neutrinos of a given species ...
Definition: Tags.hpp:94
Defines classes and functions used for manipulating DataBox&#39;s.
Definition: Tags.hpp:26
The Lorentz factor , where is the spatial velocity of the fluid.
Definition: Tags.hpp:64
Defines a list of useful type aliases for tensors.
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args) noexcept
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1633
The normal component of the source term coupling the M1 and hydro equations.
Definition: Tags.hpp:154
Stores a collection of function values.
Definition: DataVector.hpp:42
Wraps the template metaprogramming library used (brigand)
Definition: M1HydroCoupling.hpp:56
Definition: IndexType.hpp:44
The emissivity of the fluid for neutrinos of a given species.
Definition: Tags.hpp:116
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
The spatial components of the fluid-frame momentum density of neutrinos of a given species ...
Definition: Tags.hpp:104
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Require a pointer to not be a nullptr
Definition: Gsl.hpp:182