Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <type_traits>
7 :
8 : #include "Evolution/Systems/Cce/Actions/InitializeKleinGordonFirstHypersurface.hpp"
9 : #include "Evolution/Systems/Cce/Actions/InitializeKleinGordonVariables.hpp"
10 : #include "Evolution/Systems/Cce/Actions/PrecomputeKleinGordonSourceVariables.hpp"
11 : #include "Evolution/Systems/Cce/Components/CharacteristicEvolution.hpp"
12 : #include "Evolution/Systems/Cce/KleinGordonSource.hpp"
13 : #include "Evolution/Systems/Cce/KleinGordonSystem.hpp"
14 : #include "Parallel/GlobalCache.hpp"
15 : #include "Parallel/Local.hpp"
16 : #include "Parallel/Phase.hpp"
17 : #include "ParallelAlgorithms/Actions/MutateApply.hpp"
18 : #include "Time/Actions/SelfStartActions.hpp"
19 : #include "Time/AdvanceTime.hpp"
20 : #include "Time/ChangeStepSize.hpp"
21 : #include "Time/ChangeTimeStepperOrder.hpp"
22 : #include "Time/CleanHistory.hpp"
23 : #include "Time/RecordTimeStepperData.hpp"
24 : #include "Time/UpdateU.hpp"
25 : #include "Utilities/TMPL.hpp"
26 :
27 : namespace Cce {
28 :
29 : /*!
30 : * \brief The component for handling the CCE evolution for the Klein-Gordon
31 : * system coupled with General Relativity.
32 : *
33 : * \details The \ref DataBoxGroup associated with
34 : * KleinGordonCharacteristicEvolution will contain all the tags of
35 : * CharacteristicEvolution, with additional tags related to the scalar field.
36 : *
37 : * Metavariables requirements:
38 : * - Phases:
39 : * - `Initialization`
40 : * - `Evolve`
41 : * - Modified type aliases in comparison to CharacteristicEvolution:
42 : * - `evolved_swsh_tags`: The spin-weighted quantities to be evolved (
43 : * `KleinGordonPsi` and `BondiJ`).
44 : * - `evolved_swsh_dt_tags`: The spin-weighed quantities associated that are to
45 : * act as the time derivative to evolve `evolved_swsh_tags` (`KleinGordonPi` and
46 : * `BondiH`).
47 : * - Additional type aliases related to the scalar field:
48 : * - `klein_gordon_boundary_communication_tags`: A typelist of tags that will
49 : * be communicated between the worldtube boundary component and the extraction
50 : * component (`Cce::Tags::klein_gordon_worldtube_boundary_tags`).
51 : * - `klein_gordon_gauge_boundary_tags`: A typelist of tags that will be
52 : * derived via `GaugeAdjustedBoundaryValue` and corresponding gauge utilities
53 : * - `klein_gordon_scri_tags`: the tags of quantities to compute at scri+
54 : */
55 : template <class Metavariables>
56 1 : struct KleinGordonCharacteristicEvolution
57 : : CharacteristicEvolution<Metavariables> {
58 0 : using metavariables = Metavariables;
59 0 : static constexpr bool evolve_ccm = Metavariables::evolve_ccm;
60 0 : using cce_system = Cce::KleinGordonSystem<evolve_ccm>;
61 :
62 0 : using cce_base = CharacteristicEvolution<Metavariables>;
63 0 : using initialize_action_list = tmpl::append<
64 : tmpl::list<Actions::InitializeKleinGordonVariables<Metavariables>>,
65 : typename cce_base::initialize_action_list>;
66 :
67 : template <typename BondiTag>
68 0 : using hypersurface_computation =
69 : typename cce_base::template hypersurface_computation<BondiTag>;
70 :
71 0 : using klein_gordon_hypersurface_computation = tmpl::list<
72 : ::Actions::MutateApply<GaugeAdjustedBoundaryValue<Tags::KleinGordonPi>>,
73 : Actions::CalculateIntegrandInputsForTag<Tags::KleinGordonPi>,
74 : tmpl::transform<
75 : integrand_terms_to_compute_for_bondi_variable<Tags::KleinGordonPi>,
76 : tmpl::bind<::Actions::MutateApply,
77 : tmpl::bind<ComputeBondiIntegrand, tmpl::_1>>>>;
78 :
79 0 : using simple_tags_from_options =
80 : Parallel::get_simple_tags_from_options<initialize_action_list>;
81 :
82 0 : using typename cce_base::compute_scri_quantities_and_observe;
83 :
84 0 : using self_start_extract_action_list = tmpl::list<
85 : Actions::RequestBoundaryData<
86 : typename Metavariables::cce_boundary_component,
87 : KleinGordonCharacteristicEvolution<Metavariables>>,
88 : Actions::ReceiveWorldtubeData<
89 : Metavariables,
90 : typename Metavariables::cce_boundary_communication_tags>,
91 : Actions::ReceiveWorldtubeData<
92 : Metavariables,
93 : typename Metavariables::klein_gordon_boundary_communication_tags>,
94 : // note that the initialization will only actually happen on the
95 : // iterations immediately following restarts
96 : Actions::InitializeFirstHypersurface<
97 : evolve_ccm, typename Metavariables::cce_boundary_component>,
98 : Actions::InitializeKleinGordonFirstHypersurface,
99 : tmpl::conditional_t<
100 : tt::is_a_v<AnalyticWorldtubeBoundary,
101 : typename Metavariables::cce_boundary_component>,
102 : Actions::UpdateGauge<false>, Actions::UpdateGauge<evolve_ccm>>,
103 : Actions::PrecomputeGlobalCceDependencies,
104 : tmpl::conditional_t<evolve_ccm,
105 : Actions::CalculatePsi0AndDerivAtInnerBoundary,
106 : tmpl::list<>>,
107 : Actions::PrecomputeKleinGordonSourceVariables,
108 : tmpl::transform<
109 : bondi_hypersurface_step_tags,
110 : tmpl::bind<::Actions::MutateApply,
111 : tmpl::bind<ComputeKleinGordonSource, tmpl::_1>>>,
112 : tmpl::transform<bondi_hypersurface_step_tags,
113 : tmpl::bind<hypersurface_computation, tmpl::_1>>,
114 : klein_gordon_hypersurface_computation,
115 : Actions::FilterSwshVolumeQuantity<Tags::BondiH>,
116 : Actions::FilterSwshVolumeQuantity<Tags::KleinGordonPi>,
117 : ::Actions::MutateApply<
118 : CalculateScriPlusValue<::Tags::dt<Tags::InertialRetardedTime>>>,
119 : Actions::CalculateScriInputs,
120 : tmpl::transform<typename metavariables::cce_scri_tags,
121 : tmpl::bind<::Actions::MutateApply,
122 : tmpl::bind<CalculateScriPlusValue, tmpl::_1>>>,
123 : ::Actions::MutateApply<RecordTimeStepperData<cce_system>>,
124 : ::Actions::MutateApply<
125 : UpdateU<cce_system, Metavariables::local_time_stepping>>>;
126 :
127 0 : using extract_action_list = tmpl::list<
128 : Actions::RequestBoundaryData<
129 : typename Metavariables::cce_boundary_component,
130 : KleinGordonCharacteristicEvolution<Metavariables>>,
131 : ::Actions::Label<CceEvolutionLabelTag>,
132 : tmpl::conditional_t<
133 : evolve_ccm, tmpl::list<>,
134 : tmpl::flatten<tmpl::list<
135 : std::conditional_t<Metavariables::local_time_stepping,
136 : evolution::Actions::RunEventsAndTriggers<
137 : Triggers::WhenToCheck::AtSteps>,
138 : tmpl::list<>>,
139 : evolution::Actions::RunEventsAndTriggers<
140 : Triggers::WhenToCheck::AtSlabs>>>>,
141 : Actions::ReceiveWorldtubeData<
142 : Metavariables,
143 : typename Metavariables::cce_boundary_communication_tags>,
144 : Actions::ReceiveWorldtubeData<
145 : Metavariables,
146 : typename Metavariables::klein_gordon_boundary_communication_tags>,
147 : Actions::InitializeFirstHypersurface<
148 : evolve_ccm, typename Metavariables::cce_boundary_component>,
149 : Actions::InitializeKleinGordonFirstHypersurface,
150 : tmpl::conditional_t<
151 : tt::is_a_v<AnalyticWorldtubeBoundary,
152 : typename Metavariables::cce_boundary_component>,
153 : Actions::UpdateGauge<false>, Actions::UpdateGauge<evolve_ccm>>,
154 : Actions::PrecomputeGlobalCceDependencies,
155 : tmpl::conditional_t<evolve_ccm,
156 : Actions::CalculatePsi0AndDerivAtInnerBoundary,
157 : tmpl::list<>>,
158 : Actions::PrecomputeKleinGordonSourceVariables,
159 : tmpl::transform<
160 : bondi_hypersurface_step_tags,
161 : tmpl::bind<::Actions::MutateApply,
162 : tmpl::bind<ComputeKleinGordonSource, tmpl::_1>>>,
163 : tmpl::transform<bondi_hypersurface_step_tags,
164 : tmpl::bind<hypersurface_computation, tmpl::_1>>,
165 : klein_gordon_hypersurface_computation,
166 : Actions::FilterSwshVolumeQuantity<Tags::BondiH>,
167 : Actions::FilterSwshVolumeQuantity<Tags::KleinGordonPi>,
168 : compute_scri_quantities_and_observe,
169 : ::Actions::MutateApply<
170 : ChangeStepSize<typename Metavariables::cce_step_choosers>>,
171 : ::Actions::MutateApply<RecordTimeStepperData<cce_system>>,
172 : ::Actions::MutateApply<
173 : UpdateU<cce_system, Metavariables::local_time_stepping>>,
174 : ::Actions::MutateApply<ChangeTimeStepperOrder<cce_system>>,
175 : ::Actions::MutateApply<CleanHistory<cce_system>>,
176 : // We cannot know our next step for certain until after we've performed
177 : // step size selection, as we may need to reject a step.
178 : Actions::RequestNextBoundaryData<
179 : typename Metavariables::cce_boundary_component,
180 : KleinGordonCharacteristicEvolution<Metavariables>>,
181 : ::Actions::MutateApply<AdvanceTime>, Actions::ExitIfEndTimeReached,
182 : ::Actions::Goto<CceEvolutionLabelTag>>;
183 :
184 0 : using phase_dependent_action_list = tmpl::list<
185 : Parallel::PhaseActions<Parallel::Phase::Initialization,
186 : initialize_action_list>,
187 : Parallel::PhaseActions<Parallel::Phase::InitializeTimeStepperHistory,
188 : SelfStart::self_start_procedure<
189 : self_start_extract_action_list, cce_system>>,
190 : Parallel::PhaseActions<Parallel::Phase::Evolve, extract_action_list>>;
191 :
192 0 : static void initialize(
193 : Parallel::CProxy_GlobalCache<Metavariables>& /*global_cache*/) {}
194 :
195 0 : static void execute_next_phase(
196 : const Parallel::Phase next_phase,
197 : const Parallel::CProxy_GlobalCache<Metavariables>& global_cache) {
198 : auto& local_cache = *Parallel::local_branch(global_cache);
199 : Parallel::get_parallel_component<
200 : KleinGordonCharacteristicEvolution<Metavariables>>(local_cache)
201 : .start_phase(next_phase);
202 : }
203 : };
204 : } // namespace Cce
|