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 : #include <limits>
8 : #include <memory>
9 : #include <pup.h>
10 :
11 : #include "DataStructures/Tensor/TypeAliases.hpp"
12 : #include "Evolution/Systems/RadiationTransport/M1Grey/Tags.hpp"
13 : #include "Options/String.hpp"
14 : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
15 : #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/Minkowski.hpp"
16 : #include "PointwiseFunctions/Hydro/TagsDeclarations.hpp"
17 : #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
18 : #include "Utilities/TMPL.hpp"
19 : #include "Utilities/TaggedTuple.hpp"
20 :
21 : /// \cond
22 : class DataVector;
23 : /// \endcond
24 :
25 1 : namespace RadiationTransport::M1Grey::Solutions {
26 :
27 : /*!
28 : * \brief Constant solution to M1 equations in Minkowski spacetime.
29 : *
30 : * An analytic solution to the 3-D M1 system. The user specifies the mean
31 : * flow velocity of the fluid and the radiation energy density in the
32 : * fluid frame J.
33 : * The radiation is taken to be in equilibrium with the fluid
34 : * (i.e. comoving, with an isotropic pressure P=J/3)
35 : *
36 : */
37 :
38 1 : class ConstantM1 : public virtual evolution::initial_data::InitialData,
39 : public MarkAsAnalyticSolution {
40 : public:
41 : /// The mean flow velocity.
42 1 : struct MeanVelocity {
43 0 : using type = std::array<double, 3>;
44 0 : static constexpr Options::String help = {"The mean flow velocity."};
45 : };
46 :
47 : /// The radiation comoving energy density
48 1 : struct ComovingEnergyDensity {
49 0 : using type = double;
50 0 : static constexpr Options::String help = {
51 : "Comoving energy density of radiation."};
52 : };
53 :
54 0 : using options = tmpl::list<MeanVelocity, ComovingEnergyDensity>;
55 0 : static constexpr Options::String help = {
56 : "Constant radiation field in equilibrium with fluid, in Minkowski "
57 : "spacetime."};
58 :
59 0 : ConstantM1() = default;
60 0 : ConstantM1(const ConstantM1& /*rhs*/) = default;
61 0 : ConstantM1& operator=(const ConstantM1& /*rhs*/) = default;
62 0 : ConstantM1(ConstantM1&& /*rhs*/) = default;
63 0 : ConstantM1& operator=(ConstantM1&& /*rhs*/) = default;
64 0 : ~ConstantM1() = default;
65 :
66 0 : ConstantM1(const std::array<double, 3>& mean_velocity,
67 : double comoving_energy_density);
68 :
69 0 : auto get_clone() const
70 : -> std::unique_ptr<evolution::initial_data::InitialData> override;
71 :
72 0 : explicit ConstantM1(CkMigrateMessage* msg);
73 : using PUP::able::register_constructor;
74 0 : WRAPPED_PUPable_decl_template(ConstantM1);
75 :
76 : /// @{
77 : /// Retrieve fluid and neutrino variables at `(x, t)`
78 : template <typename NeutrinoSpecies>
79 1 : auto variables(const tnsr::I<DataVector, 3>& x, double t,
80 : tmpl::list<RadiationTransport::M1Grey::Tags::TildeE<
81 : Frame::Inertial, NeutrinoSpecies>> /*meta*/) const
82 : -> tuples::TaggedTuple<RadiationTransport::M1Grey::Tags::TildeE<
83 : Frame::Inertial, NeutrinoSpecies>>;
84 :
85 : template <typename NeutrinoSpecies>
86 1 : auto variables(const tnsr::I<DataVector, 3>& x, double t,
87 : tmpl::list<RadiationTransport::M1Grey::Tags::TildeS<
88 : Frame::Inertial, NeutrinoSpecies>> /*meta*/) const
89 : -> tuples::TaggedTuple<RadiationTransport::M1Grey::Tags::TildeS<
90 : Frame::Inertial, NeutrinoSpecies>>;
91 :
92 : template <typename NeutrinoSpecies>
93 1 : auto variables(const tnsr::I<DataVector, 3>& x, double t,
94 : tmpl::list<RadiationTransport::M1Grey::Tags::GreyEmissivity<
95 : NeutrinoSpecies>> /*meta*/) const
96 : -> tuples::TaggedTuple<
97 : RadiationTransport::M1Grey::Tags::GreyEmissivity<NeutrinoSpecies>>;
98 :
99 : template <typename NeutrinoSpecies>
100 1 : auto variables(
101 : const tnsr::I<DataVector, 3>& x, double t,
102 : tmpl::list<RadiationTransport::M1Grey::Tags::GreyAbsorptionOpacity<
103 : NeutrinoSpecies>> /*meta*/) const
104 : -> tuples::TaggedTuple<RadiationTransport::M1Grey::Tags::
105 : GreyAbsorptionOpacity<NeutrinoSpecies>>;
106 :
107 : template <typename NeutrinoSpecies>
108 1 : auto variables(
109 : const tnsr::I<DataVector, 3>& x, double t,
110 : tmpl::list<RadiationTransport::M1Grey::Tags::GreyScatteringOpacity<
111 : NeutrinoSpecies>> /*meta*/) const
112 : -> tuples::TaggedTuple<RadiationTransport::M1Grey::Tags::
113 : GreyScatteringOpacity<NeutrinoSpecies>>;
114 :
115 1 : auto variables(const tnsr::I<DataVector, 3>& x, double t,
116 : tmpl::list<hydro::Tags::LorentzFactor<DataVector>> /*meta*/)
117 : const -> tuples::TaggedTuple<hydro::Tags::LorentzFactor<DataVector>>;
118 :
119 1 : auto variables(
120 : const tnsr::I<DataVector, 3>& x, double t,
121 : tmpl::list<hydro::Tags::SpatialVelocity<DataVector, 3>> /*meta*/) const
122 : -> tuples::TaggedTuple<hydro::Tags::SpatialVelocity<DataVector, 3>>;
123 : /// @}
124 :
125 : /// Retrieve a collection of fluid and neutrino variables at `(x, t)`
126 : template <typename... Tags>
127 1 : tuples::TaggedTuple<Tags...> variables(const tnsr::I<DataVector, 3>& x,
128 : double t,
129 : tmpl::list<Tags...> /*meta*/) const {
130 : static_assert(sizeof...(Tags) > 1,
131 : "The generic template will recurse infinitely if only one "
132 : "tag is being retrieved.");
133 : return {get<Tags>(variables(x, t, tmpl::list<Tags>{}))...};
134 : }
135 :
136 : /// Retrieve the metric variables
137 : template <typename Tag>
138 1 : tuples::TaggedTuple<Tag> variables(const tnsr::I<DataVector, 3>& x, double t,
139 : tmpl::list<Tag> /*meta*/) const {
140 : return background_spacetime_.variables(x, t, tmpl::list<Tag>{});
141 : }
142 :
143 : // clang-tidy: no runtime references
144 0 : void pup(PUP::er& /*p*/) override; // NOLINT
145 :
146 : private:
147 0 : friend bool operator==(const ConstantM1& lhs, const ConstantM1& rhs);
148 :
149 0 : std::array<double, 3> mean_velocity_{
150 : {std::numeric_limits<double>::signaling_NaN(),
151 : std::numeric_limits<double>::signaling_NaN(),
152 : std::numeric_limits<double>::signaling_NaN()}};
153 0 : double comoving_energy_density_ =
154 : std::numeric_limits<double>::signaling_NaN();
155 0 : gr::Solutions::Minkowski<3> background_spacetime_{};
156 : };
157 :
158 0 : bool operator!=(const ConstantM1& lhs, const ConstantM1& rhs);
159 : } // namespace RadiationTransport::M1Grey::Solutions
|