Fluxes.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 
8 #include "DataStructures/DataBox/DataBoxTag.hpp" // for item_type
9 #include "DataStructures/DataBox/Prefixes.hpp" // IWYU pragma: keep
10 #include "DataStructures/DataVector.hpp"
12 #include "DataStructures/Tensor/TypeAliases.hpp" // IWYU pragma: keep
13 #include "Evolution/Systems/GrMhd/ValenciaDivClean/TagsDeclarations.hpp" // IWYU pragma: keep
14 #include "Evolution/Systems/RadiationTransport/M1Grey/Tags.hpp" // IWYU pragma: keep
15 #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp" // IWYU pragma: keep
16 #include "Utilities/Gsl.hpp" // for not_null
17 #include "Utilities/TMPL.hpp" // for EXPAND_PACK_LEFT_TO...
18 
19 // IWYU pragma: no_include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
20 
21 // IWYU pragma: no_forward_declare Tags::Flux
22 // IWYU pragma: no_forward_declare Tensor
23 
24 namespace RadiationTransport {
25 namespace M1Grey {
26 
27 // Implementation of the M1 fluxes for individual neutrino species
28 namespace detail {
29 void compute_fluxes_impl(
30  gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_e_flux,
31  gsl::not_null<tnsr::Ij<DataVector, 3, Frame::Inertial>*> tilde_s_flux,
32  gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_s_M,
33  const Scalar<DataVector>& tilde_e,
34  const tnsr::i<DataVector, 3, Frame::Inertial>& tilde_s,
35  const tnsr::II<DataVector, 3, Frame::Inertial>& tilde_p,
37  const tnsr::I<DataVector, 3, Frame::Inertial>& shift,
38  const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
39  const tnsr::II<DataVector, 3, Frame::Inertial>&
40  inv_spatial_metric) noexcept;
41 } // namespace detail
42 
43 /*!
44  * \brief The fluxes of the conservative variables in the M1 scheme
45  *
46  * \f{align*}
47  * F^i({\tilde E}) = &~ \alpha \gamma^{ij} {\tilde S}_j - \beta^j {\tilde E} \\
48  * F^i({\tilde S}_j) = &~ \alpha {\tilde P}^{ik} \gamma_{kj} - \beta^i {\tilde
49  * S}_j \f}
50  *
51  * where the conserved variables \f${\tilde E}\f$, \f${\tilde S}_i\f$,
52  * are a generalized mass-energy density and momentum density.
53  * Furthermore, \f${\tilde P^{ij}}\f$ is the pressure tensor density of the
54  * radiation field, \f$\alpha\f$ is the lapse, \f$\beta^i\f$ is the shift,
55  * \f$\gamma_{ij}\f$ the 3-metric, and \f$\gamma^{ij}\f$ its inverse.
56  *
57  * In the main function, we loop over all neutrino species, and then call
58  * the actual implementation of the fluxes.
59  */
60 template <typename... NeutrinoSpecies>
61 struct ComputeFluxes {
62  using return_tags =
63  tmpl::list<::Tags::Flux<Tags::TildeE<Frame::Inertial, NeutrinoSpecies>,
64  tmpl::size_t<3>, Frame::Inertial>...,
66  tmpl::size_t<3>, Frame::Inertial>...>;
67 
68  using argument_tags =
69  tmpl::list<Tags::TildeE<Frame::Inertial, NeutrinoSpecies>...,
74 
75  static void apply(
78  tmpl::size_t<3>, Frame::Inertial>>*>... tilde_e_flux,
81  tmpl::size_t<3>, Frame::Inertial>>*>... tilde_s_flux,
82  const db::item_type<
84  const db::item_type<
86  const db::item_type<
89  const tnsr::I<DataVector, 3, Frame::Inertial>& shift,
90  const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
91  const tnsr::II<DataVector, 3, Frame::Inertial>&
92  inv_spatial_metric) noexcept {
93  // Allocate memory for tildeS^i
94  tnsr::I<DataVector, 3, Frame::Inertial> tilde_s_M(get(lapse).size());
95  EXPAND_PACK_LEFT_TO_RIGHT(detail::compute_fluxes_impl(
96  tilde_e_flux, tilde_s_flux, &tilde_s_M, tilde_e, tilde_s, tilde_p,
97  lapse, shift, spatial_metric, inv_spatial_metric));
98  }
99 };
100 } // namespace M1Grey
101 } // namespace RadiationTransport
#define EXPAND_PACK_LEFT_TO_RIGHT(...)
Expand a parameter pack evaluating the terms from left to right.
Definition: TMPL.hpp:561
Namespace for all radiation transport algorithms.
Definition: Fluxes.cpp:16
Define prefixes for DataBox tags.
Definition: Tags.hpp:57
The densitized pressure tensor of neutrinos of a given species computed from , using the M1 closure...
Definition: Tags.hpp:47
Inverse of the spatial metric.
Definition: Tags.hpp:34
tnsr::ii< DataType, SpatialDim, Frame > spatial_metric(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric) noexcept
Compute spatial metric from spacetime metric.
Definition: ComputeSpacetimeQuantities.cpp:62
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
The densitized energy density of neutrinos of a given species .
Definition: Tags.hpp:26
Definition: Determinant.hpp:11
The densitized momentum density of neutrinos of a given species .
Definition: Tags.hpp:36
Definition: Tags.hpp:26
Prefix indicating a flux.
Definition: Prefixes.hpp:38
Definition: Tags.hpp:52
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 classes for Tensor.
Defines a list of useful type aliases for tensors.
tnsr::I< DataType, SpatialDim, Frame > shift(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric, const tnsr::II< DataType, SpatialDim, Frame > &inverse_spatial_metric) noexcept
Compute shift from spacetime metric and inverse spatial metric.
Definition: ComputeSpacetimeQuantities.cpp:101
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
The fluxes of the conservative variables in the M1 scheme.
Definition: Fluxes.hpp:61
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12