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 :
8 : #include "DataStructures/DataBox/Prefixes.hpp" // IWYU pragma: keep
9 : #include "DataStructures/DataVector.hpp"
10 : #include "DataStructures/Tensor/Tensor.hpp"
11 : #include "DataStructures/Tensor/TypeAliases.hpp" // IWYU pragma: keep
12 : #include "Evolution/Systems/RadiationTransport/M1Grey/Tags.hpp" // IWYU pragma: keep
13 : #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp" // IWYU pragma: keep
14 : #include "Utilities/Gsl.hpp" // for not_null
15 : #include "Utilities/TMPL.hpp" // for EXPAND_PACK_LEFT_TO...
16 :
17 : // IWYU pragma: no_include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
18 :
19 : // IWYU pragma: no_forward_declare Tags::Flux
20 : // IWYU pragma: no_forward_declare Tensor
21 :
22 : namespace RadiationTransport {
23 : namespace M1Grey {
24 :
25 : // Implementation of the M1 fluxes for individual neutrino species
26 : namespace detail {
27 : void compute_fluxes_impl(
28 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_e_flux,
29 : gsl::not_null<tnsr::Ij<DataVector, 3, Frame::Inertial>*> tilde_s_flux,
30 : gsl::not_null<tnsr::I<DataVector, 3, Frame::Inertial>*> tilde_s_M,
31 : const Scalar<DataVector>& tilde_e,
32 : const tnsr::i<DataVector, 3, Frame::Inertial>& tilde_s,
33 : const tnsr::II<DataVector, 3, Frame::Inertial>& tilde_p,
34 : const Scalar<DataVector>& lapse,
35 : const tnsr::I<DataVector, 3, Frame::Inertial>& shift,
36 : const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
37 : const tnsr::II<DataVector, 3, Frame::Inertial>& inv_spatial_metric);
38 : } // namespace detail
39 :
40 : /*!
41 : * \brief The fluxes of the conservative variables in the M1 scheme
42 : *
43 : * \f{align*}
44 : * F^i({\tilde E}) = &~ \alpha \gamma^{ij} {\tilde S}_j - \beta^j {\tilde E} \\
45 : * F^i({\tilde S}_j) = &~ \alpha {\tilde P}^{ik} \gamma_{kj} - \beta^i {\tilde
46 : * S}_j \f}
47 : *
48 : * where the conserved variables \f${\tilde E}\f$, \f${\tilde S}_i\f$,
49 : * are a generalized mass-energy density and momentum density.
50 : * Furthermore, \f${\tilde P^{ij}}\f$ is the pressure tensor density of the
51 : * radiation field, \f$\alpha\f$ is the lapse, \f$\beta^i\f$ is the shift,
52 : * \f$\gamma_{ij}\f$ the 3-metric, and \f$\gamma^{ij}\f$ its inverse.
53 : *
54 : * In the main function, we loop over all neutrino species, and then call
55 : * the actual implementation of the fluxes.
56 : */
57 : template <typename... NeutrinoSpecies>
58 1 : struct ComputeFluxes {
59 0 : using return_tags =
60 : tmpl::list<::Tags::Flux<Tags::TildeE<Frame::Inertial, NeutrinoSpecies>,
61 : tmpl::size_t<3>, Frame::Inertial>...,
62 : ::Tags::Flux<Tags::TildeS<Frame::Inertial, NeutrinoSpecies>,
63 : tmpl::size_t<3>, Frame::Inertial>...>;
64 :
65 0 : using argument_tags =
66 : tmpl::list<Tags::TildeE<Frame::Inertial, NeutrinoSpecies>...,
67 : Tags::TildeS<Frame::Inertial, NeutrinoSpecies>...,
68 : Tags::TildeP<Frame::Inertial, NeutrinoSpecies>...,
69 : gr::Tags::Lapse<DataVector>, gr::Tags::Shift<DataVector, 3>,
70 : gr::Tags::SpatialMetric<DataVector, 3>,
71 : gr::Tags::InverseSpatialMetric<DataVector, 3>>;
72 :
73 0 : static void apply(
74 : const gsl::not_null<typename ::Tags::Flux<
75 : Tags::TildeE<Frame::Inertial, NeutrinoSpecies>, tmpl::size_t<3>,
76 : Frame::Inertial>::type*>... tilde_e_flux,
77 : const gsl::not_null<typename ::Tags::Flux<
78 : Tags::TildeS<Frame::Inertial, NeutrinoSpecies>, tmpl::size_t<3>,
79 : Frame::Inertial>::type*>... tilde_s_flux,
80 : const typename Tags::TildeE<Frame::Inertial,
81 : NeutrinoSpecies>::type&... tilde_e,
82 : const typename Tags::TildeS<Frame::Inertial,
83 : NeutrinoSpecies>::type&... tilde_s,
84 : const typename Tags::TildeP<Frame::Inertial,
85 : NeutrinoSpecies>::type&... tilde_p,
86 : const Scalar<DataVector>& lapse,
87 : const tnsr::I<DataVector, 3, Frame::Inertial>& shift,
88 : const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
89 : const tnsr::II<DataVector, 3, Frame::Inertial>& inv_spatial_metric) {
90 : // Allocate memory for tildeS^i
91 : tnsr::I<DataVector, 3, Frame::Inertial> tilde_s_M(get(lapse).size());
92 : EXPAND_PACK_LEFT_TO_RIGHT(detail::compute_fluxes_impl(
93 : tilde_e_flux, tilde_s_flux, &tilde_s_M, tilde_e, tilde_s, tilde_p,
94 : lapse, shift, spatial_metric, inv_spatial_metric));
95 : }
96 : };
97 : } // namespace M1Grey
98 : } // namespace RadiationTransport
|