Sources.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include "DataStructures/DataBox/DataBoxTag.hpp" // for item_type
7 #include "DataStructures/Tensor/TypeAliases.hpp" // IWYU pragma: keep
8 #include "Evolution/Systems/RadiationTransport/M1Grey/Tags.hpp" // IWYU pragma: keep
10 #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp" // IWYU pragma: keep
11 #include "Utilities/Gsl.hpp"
12 #include "Utilities/TMPL.hpp" // for EXPAND_PACK_LEFT_TO...
13 
14 // IWYU pragma: no_include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
15 
16 /// \cond
17 class DataVector;
18 /// \endcond
19 
20 // IWYU pragma: no_forward_declare Tensor
21 // IWYU pragma: no_forward_declare Tags::deriv
22 
23 namespace RadiationTransport {
24 namespace M1Grey {
25 
26 /// Implementation of the curvature source terms
27 /// for the M1 system, for an individual species.
28 namespace detail {
29 void compute_sources_impl(
30  gsl::not_null<Scalar<DataVector>*> source_tilde_e,
31  gsl::not_null<tnsr::i<DataVector, 3, Frame::Inertial>*> source_tilde_s,
32  const Scalar<DataVector>& tilde_e,
33  const tnsr::i<DataVector, 3, Frame::Inertial>& tilde_s,
34  const tnsr::II<DataVector, 3, Frame::Inertial>& tilde_p,
36  const tnsr::i<DataVector, 3, Frame::Inertial>& d_lapse,
37  const tnsr::iJ<DataVector, 3, Frame::Inertial>& d_shift,
38  const tnsr::ijj<DataVector, 3, Frame::Inertial>& d_spatial_metric,
39  const tnsr::II<DataVector, 3, Frame::Inertial>& inv_spatial_metric,
40  const tnsr::ii<DataVector, 3, Frame::Inertial>&
41  extrinsic_curvature) noexcept;
42 } // namespace detail
43 
44 /*!
45  * \brief Compute the curvature source terms for the flux-balanced
46  * grey M1 radiation transport.
47  *
48  *
49  * A flux-balanced system has the generic form:
50  * \f[
51  * \partial_t U_i + \partial_m F^m(U_i) = S(U_i)
52  * \f]
53  *
54  * where \f$F^a()\f$ denotes the flux of a conserved variable \f$U_i\f$ and
55  * \f$S()\f$ denotes the source term for the conserved variable.
56  *
57  * For the grey M1 formalism (neglecting coupling to the fluid):
58  * \f{align*}
59  * S({\tilde E}) &= \alpha \tilde P^{ij} K_{ij} - \tilde S^i \partial_i
60  * \alpha,\\ S({\tilde S_i}) &= -\tilde E \partial_i \alpha + \tilde S_k
61  * \partial_i \beta^k
62  * + \frac{1}{2} \alpha \tilde P^{jk} \partial_i \gamma_{jk},
63  * \f}
64  *
65  * where \f${\tilde E}\f$, \f${\tilde S_i}\f$, \f${\tilde P}^{ij}\f$ are the
66  * densitized energy, momentum, and pressure tensor of the neutrinos/photons,
67  * \f$K_{ij}\f$ is the extrinsic curvature, and \f$\alpha\f$, \f$\beta^i\f$,
68  * \f$\gamma_{ij}\f$ are the lapse, shift and 3-metric.
69  *
70  * In the main function, we loop over all neutrino species, and then call
71  * the actual implementation of the curvature source terms.
72  */
73 template <typename... NeutrinoSpecies>
75  using return_tags =
76  tmpl::list<Tags::TildeE<Frame::Inertial, NeutrinoSpecies>...,
78 
79  using argument_tags = tmpl::list<
83  ::Tags::deriv<gr::Tags::Lapse<DataVector>, tmpl::size_t<3>,
85  ::Tags::deriv<gr::Tags::Shift<3, Frame::Inertial, DataVector>,
86  tmpl::size_t<3>, Frame::Inertial>,
87  ::Tags::deriv<gr::Tags::SpatialMetric<3, Frame::Inertial, DataVector>,
88  tmpl::size_t<3>, Frame::Inertial>,
91 
92  static void apply(
97  const db::item_type<
99  const db::item_type<
101  const db::item_type<
103  const Scalar<DataVector>& lapse,
104  const tnsr::i<DataVector, 3, Frame::Inertial>& d_lapse,
105  const tnsr::iJ<DataVector, 3, Frame::Inertial>& d_shift,
106  const tnsr::ijj<DataVector, 3, Frame::Inertial>& d_spatial_metric,
107  const tnsr::II<DataVector, 3, Frame::Inertial>& inv_spatial_metric,
108  const tnsr::ii<DataVector, 3, Frame::Inertial>&
109  extrinsic_curvature) noexcept {
110  EXPAND_PACK_LEFT_TO_RIGHT(detail::compute_sources_impl(
111  sources_tilde_e, sources_tilde_s, tilde_e, tilde_s, tilde_p, lapse,
112  d_lapse, d_shift, d_spatial_metric, inv_spatial_metric,
113  extrinsic_curvature));
114  }
115 };
116 
117 } // namespace M1Grey
118 } // namespace RadiationTransport
#define EXPAND_PACK_LEFT_TO_RIGHT(...)
Expand a parameter pack evaluating the terms from left to right.
Definition: TMPL.hpp:561
Definition: Tags.hpp:36
Namespace for all radiation transport algorithms.
Definition: Fluxes.cpp:16
Definition: Tags.hpp:46
The densitized pressure tensor of neutrinos of a given species computed from , using the M1 closure...
Definition: Tags.hpp:47
Definition: Tags.hpp:31
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args)
Apply the function f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1609
tnsr::ii< DataVector, 3, Frame > extrinsic_curvature(const tnsr::ii< DataVector, 3, Frame > &grad_normal, const tnsr::i< DataVector, 3, Frame > &unit_normal_one_form, const tnsr::I< DataVector, 3, Frame > &unit_normal_vector) noexcept
Extrinsic curvature of a 2D Strahlkorper embedded in a 3D space.
The densitized energy density of neutrinos of a given species .
Definition: Tags.hpp:26
Definition: Determinant.hpp:11
Compute the curvature source terms for the flux-balanced grey M1 radiation transport.
Definition: Sources.hpp:74
The densitized momentum density of neutrinos of a given species .
Definition: Tags.hpp:36
Defines functions computing partial derivatives.
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: ComputeSpacetimeQuantities.cpp:117
Defines a list of useful type aliases for tensors.
Stores a collection of function values.
Definition: DataVector.hpp:42
Wraps the template metaprogramming library used (brigand)
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that is returned by the Tag. If it is a base tag then a TagList must be passed as a seco...
Definition: DataBoxTag.hpp:410
Defines functions and classes from the GSL.
Definition: IndexType.hpp:44
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Tensor< T, Symmetry<>, index_list<> > Scalar
Scalar type.
Definition: TypeAliases.hpp:21
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12
Definition: Tags.hpp:96