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 <cstddef>
8 : #include <memory>
9 : #include <random>
10 : #include <string>
11 : #include <unordered_map>
12 :
13 : #include "DataStructures/DataBox/DataBox.hpp"
14 : #include "DataStructures/DataVector.hpp"
15 : #include "DataStructures/Tensor/Tensor.hpp"
16 : #include "Domain/ElementMap.hpp"
17 : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
18 : #include "Domain/FunctionsOfTime/Tags.hpp"
19 : #include "Domain/Tags.hpp"
20 : #include "Domain/TagsTimeDependent.hpp"
21 : #include "Evolution/DgSubcell/ActiveGrid.hpp"
22 : #include "Evolution/DgSubcell/Tags/ActiveGrid.hpp"
23 : #include "Evolution/DgSubcell/Tags/Coordinates.hpp"
24 : #include "Evolution/DgSubcell/Tags/Mesh.hpp"
25 : #include "Evolution/Initialization/Tags.hpp"
26 : #include "Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions/Gauges.hpp"
27 : #include "Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions/SetPiAndPhiFromConstraints.hpp"
28 : #include "Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions/Tags/GaugeCondition.hpp"
29 : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
30 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/AllSolutions.hpp"
31 : #include "Parallel/AlgorithmExecution.hpp"
32 : #include "Utilities/TMPL.hpp"
33 :
34 : /// \cond
35 : namespace Tags {
36 : struct Time;
37 : } // namespace Tags
38 : /// \endcond
39 :
40 : namespace grmhd::GhValenciaDivClean {
41 : /*!
42 : * \brief Set \f$\Pi_{ab}\f$ from the gauge source function.
43 : *
44 : * This is necessary to ensure the initial data is in the desired evolution
45 : * gauge.
46 : */
47 1 : struct SetPiAndPhiFromConstraints {
48 0 : using const_global_cache_tags =
49 : typename gh::gauges::SetPiAndPhiFromConstraints<
50 : ghmhd::GhValenciaDivClean::InitialData::
51 : analytic_solutions_and_data_list,
52 : 3>::const_global_cache_tags;
53 0 : using mutable_global_cache_tags =
54 : typename gh::gauges::SetPiAndPhiFromConstraints<
55 : ghmhd::GhValenciaDivClean::InitialData::
56 : analytic_solutions_and_data_list,
57 : 3>::mutable_global_cache_tags;
58 :
59 : template <typename DbTags, typename... InboxTags, typename Metavariables,
60 : typename ArrayIndex, typename ActionList,
61 : typename ParallelComponent>
62 0 : static Parallel::iterable_action_return_t apply(
63 : db::DataBox<DbTags>& box, tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
64 : const Parallel::GlobalCache<Metavariables>& cache,
65 : const ArrayIndex& /*array_index*/, ActionList /*meta*/,
66 : const ParallelComponent* const /*meta*/) {
67 : db::mutate_apply<
68 : tmpl::list<gh::Tags::Pi<DataVector, 3>, gh::Tags::Phi<DataVector, 3>>,
69 : tmpl::list<
70 : ::Tags::Time, domain::Tags::Mesh<3>,
71 : domain::Tags::ElementMap<3, Frame::Grid>,
72 : domain::CoordinateMaps::Tags::CoordinateMap<3, Frame::Grid,
73 : Frame::Inertial>,
74 : domain::Tags::FunctionsOfTime,
75 : domain::Tags::Coordinates<3, Frame::ElementLogical>,
76 : gr::Tags::SpacetimeMetric<DataVector, 3>,
77 : gh::gauges::Tags::GaugeCondition,
78 : evolution::dg::subcell::Tags::Mesh<3>,
79 : evolution::dg::subcell::Tags::Coordinates<3, Frame::ElementLogical>,
80 : evolution::dg::subcell::Tags::ActiveGrid>>(
81 : [](const gsl::not_null<tnsr::aa<DataVector, 3, Frame::Inertial>*> pi,
82 : const gsl::not_null<tnsr::iaa<DataVector, 3, Frame::Inertial>*> phi,
83 : const double initial_time, const Mesh<3>& dg_mesh,
84 : const ElementMap<3, Frame::Grid>& logical_to_grid_map,
85 : const domain::CoordinateMapBase<Frame::Grid, Frame::Inertial, 3>&
86 : grid_to_inertial_map,
87 : const std::unordered_map<
88 : std::string,
89 : std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>>&
90 : functions_of_time,
91 : const tnsr::I<DataVector, 3, Frame::ElementLogical>&
92 : dg_logical_coordinates,
93 : const tnsr::aa<DataVector, 3, Frame::Inertial>& spacetime_metric,
94 : const gh::gauges::GaugeCondition& gauge_condition,
95 : const Mesh<3>& subcell_mesh,
96 : const tnsr::I<DataVector, 3, Frame::ElementLogical>&
97 : subcell_logical_coordinates,
98 : const evolution::dg::subcell::ActiveGrid active_grid,
99 : const bool set_pi_and_phi_from_constraints) {
100 : if (active_grid == evolution::dg::subcell::ActiveGrid::Dg) {
101 : gh::gauges::SetPiAndPhiFromConstraints<
102 : ghmhd::GhValenciaDivClean::InitialData::
103 : analytic_solutions_and_data_list,
104 : 3>::impl(pi, phi, initial_time, dg_mesh, logical_to_grid_map,
105 : grid_to_inertial_map, functions_of_time,
106 : dg_logical_coordinates, spacetime_metric,
107 : gauge_condition, set_pi_and_phi_from_constraints);
108 : } else {
109 : gh::gauges::SetPiAndPhiFromConstraints<
110 : ghmhd::GhValenciaDivClean::InitialData::
111 : analytic_solutions_and_data_list,
112 : 3>::impl(pi, phi, initial_time, subcell_mesh,
113 : logical_to_grid_map, grid_to_inertial_map,
114 : functions_of_time, subcell_logical_coordinates,
115 : spacetime_metric, gauge_condition,
116 : set_pi_and_phi_from_constraints);
117 : }
118 : },
119 : make_not_null(&box),
120 : Parallel::get<gh::Tags::SetPiAndPhiFromConstraints>(cache));
121 : return {Parallel::AlgorithmExecution::Continue, std::nullopt};
122 : }
123 : };
124 : } // namespace grmhd::GhValenciaDivClean
|