Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 :
8 : #include "DataStructures/Tensor/TypeAliases.hpp"
9 : #include "DataStructures/VariablesTag.hpp"
10 : #include "Domain/Tags.hpp"
11 : #include "Evolution/DgSubcell/ActiveGrid.hpp"
12 : #include "Evolution/DgSubcell/Tags/ActiveGrid.hpp"
13 : #include "Evolution/DgSubcell/Tags/Mesh.hpp"
14 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/PrimitiveFromConservativeOptions.hpp"
15 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
16 : #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp"
17 : #include "PointwiseFunctions/Hydro/Tags.hpp"
18 : #include "Utilities/TMPL.hpp"
19 :
20 : /// \cond
21 : class DataVector;
22 : namespace EquationsOfState {
23 : template <bool IsRelativistic, size_t ThermodynamicDim>
24 : class EquationOfState;
25 : } // namespace EquationsOfState
26 : template <size_t Dim>
27 : class Mesh;
28 : namespace gsl {
29 : template <typename T>
30 : class not_null;
31 : } // namespace gsl
32 : template <typename TagsList>
33 : class Variables;
34 : /// \endcond
35 :
36 : namespace grmhd::ValenciaDivClean::subcell {
37 : /*!
38 : * \brief Mutator that, if the active mesh is subcell, resizes the primitive
39 : * variables to have the size of the subcell and then computes the primitive
40 : * variables.
41 : *
42 : * In the DG-subcell `step_actions` list this will normally be called using the
43 : * `::Actions::MutateApply` action in the following way in the action list:
44 : * - `TciAndSwitchToDg<TciOnFdGrid>`
45 : * - `Actions::MutateApply<grmhd::ValenciaDivClean::subcell::SwapGrTags>`
46 : * - `Actions::MutateApply<ResizeAndComputePrims<primitive_recovery_schemes>>`
47 : * Note that the GR tags are swapped before this action is called.
48 : *
49 : * If the active grid is DG (we are switching from subcell back to DG) then this
50 : * mutator computes the primitive variables on the active grid. We reconstruct
51 : * the pressure to the DG grid to give a high-order initial guess for the
52 : * primitive recovery. A possible future optimization would be to avoid this
53 : * reconstruction when all recovery schemes don't need an initial guess.
54 : * Finally, we perform the primitive recovery on the DG grid.
55 : */
56 : template <typename OrderedListOfRecoverySchemes>
57 1 : struct ResizeAndComputePrims {
58 0 : using return_tags =
59 : tmpl::list<::Tags::Variables<hydro::grmhd_tags<DataVector>>>;
60 0 : using argument_tags = tmpl::list<
61 : evolution::dg::subcell::Tags::ActiveGrid, domain::Tags::Mesh<3>,
62 : evolution::dg::subcell::Tags::Mesh<3>,
63 : grmhd::ValenciaDivClean::Tags::TildeD,
64 : grmhd::ValenciaDivClean::Tags::TildeYe,
65 : grmhd::ValenciaDivClean::Tags::TildeTau,
66 : grmhd::ValenciaDivClean::Tags::TildeS<>,
67 : grmhd::ValenciaDivClean::Tags::TildeB<>,
68 : grmhd::ValenciaDivClean::Tags::TildePhi,
69 : gr::Tags::SpatialMetric<DataVector, 3>,
70 : gr::Tags::InverseSpatialMetric<DataVector, 3>,
71 : gr::Tags::SqrtDetSpatialMetric<DataVector>,
72 : hydro::Tags::GrmhdEquationOfState,
73 : grmhd::ValenciaDivClean::Tags::PrimitiveFromConservativeOptions>;
74 :
75 0 : static void apply(
76 : gsl::not_null<Variables<hydro::grmhd_tags<DataVector>>*> prim_vars,
77 : evolution::dg::subcell::ActiveGrid active_grid, const Mesh<3>& dg_mesh,
78 : const Mesh<3>& subcell_mesh, const Scalar<DataVector>& tilde_d,
79 : const Scalar<DataVector>& tilde_ye, const Scalar<DataVector>& tilde_tau,
80 : const tnsr::i<DataVector, 3, Frame::Inertial>& tilde_s,
81 : const tnsr::I<DataVector, 3, Frame::Inertial>& tilde_b,
82 : const Scalar<DataVector>& tilde_phi,
83 : const tnsr::ii<DataVector, 3, Frame::Inertial>& spatial_metric,
84 : const tnsr::II<DataVector, 3, Frame::Inertial>& inv_spatial_metric,
85 : const Scalar<DataVector>& sqrt_det_spatial_metric,
86 : const EquationsOfState::EquationOfState<true, 3>& eos,
87 : const grmhd::ValenciaDivClean::PrimitiveFromConservativeOptions&
88 : primitive_from_conservative_options);
89 : };
90 : } // namespace grmhd::ValenciaDivClean::subcell
|