Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstdint>
7 : #include <vector>
8 :
9 : #include "ControlSystem/Actions/InitializeMeasurements.hpp"
10 : #include "ControlSystem/CleanFunctionsOfTime.hpp"
11 : #include "ControlSystem/Component.hpp"
12 : #include "ControlSystem/ControlErrors/Size/Factory.hpp"
13 : #include "ControlSystem/ControlErrors/Size/State.hpp"
14 : #include "ControlSystem/Measurements/SingleHorizon.hpp"
15 : #include "ControlSystem/Metafunctions.hpp"
16 : #include "ControlSystem/Systems/Shape.hpp"
17 : #include "ControlSystem/Systems/Size.hpp"
18 : #include "ControlSystem/Systems/Translation.hpp"
19 : #include "ControlSystem/Trigger.hpp"
20 : #include "Domain/Structure/ObjectLabel.hpp"
21 : #include "Evolution/Actions/RunEventsAndTriggers.hpp"
22 : #include "Evolution/Executables/ScalarTensor/ScalarTensorBase.hpp"
23 : #include "Evolution/Systems/Cce/Callbacks/DumpBondiSachsOnWorldtube.hpp"
24 : #include "Evolution/Systems/ScalarTensor/Actions/SetInitialData.hpp"
25 : #include "Options/FactoryHelpers.hpp"
26 : #include "Options/Protocols/FactoryCreation.hpp"
27 : #include "Options/String.hpp"
28 : #include "Parallel/MemoryMonitor/MemoryMonitor.hpp"
29 : #include "Parallel/PhaseControl/ExecutePhaseChange.hpp"
30 : #include "ParallelAlgorithms/Actions/FunctionsOfTimeAreReady.hpp"
31 : #include "ParallelAlgorithms/Actions/MutateApply.hpp"
32 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/ErrorOnFailedApparentHorizon.hpp"
33 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/FailedHorizonFind.hpp"
34 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/FindApparentHorizon.hpp"
35 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/IgnoreFailedApparentHorizon.hpp"
36 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/ObserveCenters.hpp"
37 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/ObserveFieldsOnHorizon.hpp"
38 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/ObserveTimeSeriesOnHorizon.hpp"
39 : #include "ParallelAlgorithms/ApparentHorizonFinder/Component.hpp"
40 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.hpp"
41 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.tpp"
42 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.hpp"
43 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.tpp"
44 : #include "ParallelAlgorithms/ApparentHorizonFinder/Criteria/Criterion.hpp"
45 : #include "ParallelAlgorithms/ApparentHorizonFinder/Criteria/Factory.hpp"
46 : #include "ParallelAlgorithms/ApparentHorizonFinder/Events/FindApparentHorizon.hpp"
47 : #include "ParallelAlgorithms/ApparentHorizonFinder/HorizonAliases.hpp"
48 : #include "ParallelAlgorithms/ApparentHorizonFinder/InterpolationTarget.hpp"
49 : #include "ParallelAlgorithms/ApparentHorizonFinder/Protocols/HorizonMetavars.hpp"
50 : #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsOnFailure.hpp"
51 : #include "ParallelAlgorithms/Interpolation/Actions/CleanUpInterpolator.hpp"
52 : #include "ParallelAlgorithms/Interpolation/Actions/ElementInitInterpPoints.hpp"
53 : #include "ParallelAlgorithms/Interpolation/Actions/InitializeInterpolationTarget.hpp"
54 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolationTargetReceiveVars.hpp"
55 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorReceivePoints.hpp"
56 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorReceiveVolumeData.hpp"
57 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorRegisterElement.hpp"
58 : #include "ParallelAlgorithms/Interpolation/Actions/TryToInterpolate.hpp"
59 : #include "ParallelAlgorithms/Interpolation/Callbacks/ObserveSurfaceData.hpp"
60 : #include "ParallelAlgorithms/Interpolation/Callbacks/ObserveTimeSeriesOnSurface.hpp"
61 : #include "ParallelAlgorithms/Interpolation/Events/Interpolate.hpp"
62 : #include "ParallelAlgorithms/Interpolation/Events/InterpolateWithoutInterpComponent.hpp"
63 : #include "ParallelAlgorithms/Interpolation/InterpolationTarget.hpp"
64 : #include "ParallelAlgorithms/Interpolation/Interpolator.hpp"
65 : #include "ParallelAlgorithms/Interpolation/Protocols/InterpolationTargetTag.hpp"
66 : #include "ParallelAlgorithms/Interpolation/Tags.hpp"
67 : #include "ParallelAlgorithms/Interpolation/Targets/Sphere.hpp"
68 : #include "PointwiseFunctions/GeneralRelativity/DetAndInverseSpatialMetric.hpp"
69 : #include "PointwiseFunctions/GeneralRelativity/Surfaces/Tags.hpp"
70 : #include "Time/Actions/SelfStartActions.hpp"
71 : #include "Time/AdvanceTime.hpp"
72 : #include "Time/ChangeSlabSize/Action.hpp"
73 : #include "Time/ChangeSlabSize/Tags.hpp"
74 : #include "Time/StepChoosers/Factory.hpp"
75 : #include "Time/Tags/StepperErrors.hpp"
76 : #include "Time/Tags/Time.hpp"
77 : #include "Utilities/Algorithm.hpp"
78 : #include "Utilities/ErrorHandling/Error.hpp"
79 : #include "Utilities/PrettyType.hpp"
80 : #include "Utilities/ProtocolHelpers.hpp"
81 :
82 : struct EvolutionMetavars : public ScalarTensorTemplateBase<EvolutionMetavars> {
83 0 : using st_base = ScalarTensorTemplateBase<EvolutionMetavars>;
84 : using typename st_base::initialize_initial_data_dependent_quantities_actions;
85 : using typename st_base::system;
86 :
87 : static constexpr size_t volume_dim = 3_st;
88 :
89 : static constexpr Options::String help{
90 : "Evolve the Einstein field equations in GH gauge coupled to a scalar "
91 : "field \n"
92 : "on a domain with a single horizon and corresponding excised region"};
93 :
94 : struct ApparentHorizon : tt::ConformsTo<ah::protocols::HorizonMetavars> {
95 0 : using time_tag = ah::Tags::ObservationTime<0>;
96 :
97 0 : using frame = ::Frame::Distorted;
98 :
99 0 : using horizon_find_callbacks = tmpl::list<
100 : ah::callbacks::ObserveTimeSeriesOnHorizon<
101 : ::ah::tags_for_observing<Frame::Distorted>, ApparentHorizon>,
102 : ah::callbacks::ObserveFieldsOnHorizon<::ah::surface_tags_for_observing,
103 : ApparentHorizon>>;
104 0 : using horizon_find_failure_callbacks =
105 : tmpl::list<ah::callbacks::FailedHorizonFind<ApparentHorizon, false>>;
106 :
107 0 : using compute_tags_on_element =
108 : tmpl::list<ah::Tags::ObservationTimeCompute<0>>;
109 :
110 : static constexpr ah::Destination destination = ah::Destination::Observation;
111 :
112 0 : static std::string name() { return "ApparentHorizon"; }
113 : };
114 :
115 0 : struct ExcisionBoundaryA
116 : : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
117 0 : using temporal_id = ::Tags::Time;
118 0 : using tags_to_observe =
119 : tmpl::list<gr::Tags::Lapse<DataVector>,
120 : gr::Tags::Shift<DataVector, 3, Frame::Grid>>;
121 0 : using compute_vars_to_interpolate =
122 : ah::ComputeExcisionBoundaryVolumeQuantities;
123 0 : using vars_to_interpolate_to_target = tags_to_observe;
124 0 : using compute_items_on_source = tmpl::list<>;
125 0 : using compute_items_on_target = tmpl::list<>;
126 0 : using compute_target_points =
127 : intrp::TargetPoints::Sphere<ExcisionBoundaryA, ::Frame::Grid>;
128 0 : using post_interpolation_callbacks =
129 : tmpl::list<intrp::callbacks::ObserveSurfaceData<
130 : tags_to_observe, ExcisionBoundaryA, ::Frame::Grid>>;
131 : // run_callbacks
132 : template <typename metavariables>
133 0 : using interpolating_component = typename metavariables::st_dg_element_array;
134 : };
135 :
136 : struct SphericalSurface
137 : : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
138 0 : using temporal_id = ::Tags::Time;
139 :
140 0 : using vars_to_interpolate_to_target =
141 : detail::ObserverTags::scalar_charge_vars_to_interpolate_to_target;
142 0 : using compute_items_on_target =
143 : detail::ObserverTags::scalar_charge_compute_items_on_target;
144 0 : using compute_target_points =
145 : intrp::TargetPoints::Sphere<SphericalSurface, ::Frame::Inertial>;
146 0 : using post_interpolation_callbacks =
147 : tmpl::list<intrp::callbacks::ObserveTimeSeriesOnSurface<
148 : detail::ObserverTags::scalar_charge_surface_obs_tags,
149 : SphericalSurface>>;
150 : template <typename metavariables>
151 0 : using interpolating_component = typename metavariables::st_dg_element_array;
152 : };
153 :
154 0 : using control_systems =
155 : tmpl::list<control_system::Systems::Shape<
156 : ::domain::ObjectLabel::None, 2,
157 : control_system::measurements::SingleHorizon<
158 : ::domain::ObjectLabel::None>>,
159 : control_system::Systems::Translation<
160 : 2,
161 : control_system::measurements::SingleHorizon<
162 : ::domain::ObjectLabel::None>,
163 : 1>,
164 : control_system::Systems::Size<::domain::ObjectLabel::None, 2>>;
165 :
166 : static constexpr bool use_control_systems =
167 : tmpl::size<control_systems>::value > 0;
168 :
169 : struct BondiSachs;
170 :
171 0 : using interpolation_target_tags = tmpl::push_back<
172 : control_system::metafunctions::interpolation_target_tags<control_systems>,
173 : ExcisionBoundaryA, SphericalSurface, BondiSachs>;
174 :
175 0 : using scalar_charge_interpolator_source_vars =
176 : detail::ObserverTags::scalar_charge_vars_to_interpolate_to_target;
177 0 : using source_vars_no_deriv = tmpl::list<
178 : gr::Tags::SpacetimeMetric<DataVector, volume_dim>,
179 : gh::Tags::Pi<DataVector, volume_dim>,
180 : gh::Tags::Phi<DataVector, volume_dim>, CurvedScalarWave::Tags::Psi,
181 : CurvedScalarWave::Tags::Pi, CurvedScalarWave::Tags::Phi<volume_dim>,
182 : gr::Tags::Lapse<DataVector>, gr::Tags::Shift<DataVector, volume_dim>>;
183 :
184 : struct BondiSachs : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
185 0 : static std::string name() { return "BondiSachsInterpolation"; }
186 0 : using temporal_id = ::Tags::Time;
187 0 : using vars_to_interpolate_to_target = source_vars_no_deriv;
188 0 : using compute_target_points =
189 : intrp::TargetPoints::Sphere<BondiSachs, ::Frame::Inertial>;
190 0 : using post_interpolation_callbacks = tmpl::list<
191 : intrp::callbacks::DumpBondiSachsOnWorldtube<BondiSachs, true>>;
192 0 : using compute_items_on_target = tmpl::list<>;
193 : template <typename Metavariables>
194 0 : using interpolating_component = typename Metavariables::st_dg_element_array;
195 : };
196 : // The interpolator_source_vars need to be the same in both the
197 : // Interpolate event and the InterpolateWithoutInterpComponent event. The
198 : // Interpolate event interpolates to the horizon, and the
199 : // InterpolateWithoutInterpComponent event interpolates to the excision
200 : // boundary. Every Target gets the same interpolator_source_vars, so they need
201 : // to be made the same. Otherwise a static assert is triggered.
202 : struct factory_creation
203 : : tt::ConformsTo<Options::protocols::FactoryCreation> {
204 0 : using factory_classes = Options::add_factory_classes<
205 : // Restrict to monotonic time steppers in LTS to avoid control
206 : // systems deadlocking.
207 : tmpl::insert<
208 : tmpl::erase<typename st_base::factory_creation::factory_classes,
209 : LtsTimeStepper>,
210 : tmpl::pair<LtsTimeStepper,
211 : TimeSteppers::monotonic_lts_time_steppers>>,
212 : tmpl::pair<ah::Criterion, ah::Criteria::standard_criteria>,
213 : tmpl::pair<
214 : Event,
215 : tmpl::flatten<tmpl::list<
216 : ah::Events::FindApparentHorizon<ApparentHorizon>,
217 : intrp::Events::InterpolateWithoutInterpComponent<
218 : 3, BondiSachs, source_vars_no_deriv>,
219 : control_system::metafunctions::control_system_events<
220 : control_systems>,
221 : control_system::CleanFunctionsOfTime,
222 : intrp::Events::InterpolateWithoutInterpComponent<
223 : volume_dim, ExcisionBoundaryA, ah::source_vars<volume_dim>>,
224 : intrp::Events::InterpolateWithoutInterpComponent<
225 : volume_dim, SphericalSurface,
226 : scalar_charge_interpolator_source_vars>>>>,
227 : tmpl::pair<DenseTrigger,
228 : control_system::control_system_triggers<control_systems>>,
229 : tmpl::pair<control_system::size::State,
230 : control_system::size::States::factory_creatable_states>>;
231 : };
232 :
233 : using typename st_base::const_global_cache_tags;
234 :
235 0 : using observed_reduction_data_tags = observers::collect_reduction_data_tags<
236 : tmpl::at<typename factory_creation::factory_classes, Event>>;
237 :
238 0 : using dg_registration_list = typename st_base::dg_registration_list;
239 :
240 0 : using step_actions = typename st_base::template step_actions<control_systems>;
241 :
242 0 : using initialization_actions = tmpl::push_back<
243 : tmpl::pop_back<typename st_base::template initialization_actions<
244 : use_control_systems>>,
245 : control_system::Actions::InitializeMeasurements<control_systems>,
246 : intrp::Actions::ElementInitInterpPoints<volume_dim,
247 : interpolation_target_tags>,
248 : tmpl::back<typename st_base::template initialization_actions<
249 : use_control_systems>>>;
250 :
251 0 : using st_dg_element_array = DgElementArray<
252 : EvolutionMetavars,
253 : tmpl::flatten<tmpl::list<
254 : Parallel::PhaseActions<Parallel::Phase::Initialization,
255 : initialization_actions>,
256 : Parallel::PhaseActions<
257 : Parallel::Phase::RegisterWithElementDataReader,
258 : tmpl::list<importers::Actions::RegisterWithElementDataReader,
259 : Parallel::Actions::TerminatePhase>>,
260 : Parallel::PhaseActions<
261 : Parallel::Phase::ImportInitialData,
262 : tmpl::list<ScalarTensor::Actions::SetInitialData,
263 : ScalarTensor::Actions::ReceiveNumericInitialData,
264 : Parallel::Actions::TerminatePhase>>,
265 : Parallel::PhaseActions<
266 : Parallel::Phase::InitializeInitialDataDependentQuantities,
267 : initialize_initial_data_dependent_quantities_actions>,
268 : Parallel::PhaseActions<
269 : Parallel::Phase::InitializeTimeStepperHistory,
270 : SelfStart::self_start_procedure<step_actions, system>>,
271 : Parallel::PhaseActions<Parallel::Phase::Register,
272 : tmpl::list<dg_registration_list,
273 : Parallel::Actions::TerminatePhase>>,
274 : Parallel::PhaseActions<Parallel::Phase::Restart,
275 : tmpl::list<dg_registration_list,
276 : Parallel::Actions::TerminatePhase>>,
277 : Parallel::PhaseActions<
278 : Parallel::Phase::WriteCheckpoint,
279 : tmpl::list<evolution::Actions::RunEventsAndTriggers<
280 : Triggers::WhenToCheck::AtCheckpoints>,
281 : Parallel::Actions::TerminatePhase>>,
282 : Parallel::PhaseActions<
283 : Parallel::Phase::Evolve,
284 : tmpl::flatten<tmpl::list<
285 : ::domain::Actions::CheckFunctionsOfTimeAreReady<volume_dim>,
286 : std::conditional_t<local_time_stepping,
287 : evolution::Actions::RunEventsAndTriggers<
288 : Triggers::WhenToCheck::AtSteps>,
289 : tmpl::list<>>,
290 : evolution::Actions::RunEventsAndTriggers<
291 : Triggers::WhenToCheck::AtSlabs>,
292 : Actions::ChangeSlabSize, step_actions,
293 : Actions::MutateApply<AdvanceTime<>>,
294 : PhaseControl::Actions::ExecutePhaseChange>>>,
295 : Parallel::PhaseActions<
296 : Parallel::Phase::PostFailureCleanup,
297 : tmpl::list<Actions::RunEventsOnFailure<::Tags::Time>,
298 : Parallel::Actions::TerminatePhase>>>>>;
299 :
300 : // ControlSystem/Measurements/CharSpeed.hpp assumes gh_dg_element_array
301 0 : using gh_dg_element_array = st_dg_element_array;
302 :
303 : template <typename ParallelComponent>
304 0 : struct registration_list {
305 0 : using type = std::conditional_t<
306 : std::is_same_v<ParallelComponent, st_dg_element_array>,
307 : dg_registration_list, tmpl::list<>>;
308 : };
309 :
310 0 : using control_system_horizon_metavars =
311 : control_system::metafunctions::horizon_metavars<control_systems>;
312 :
313 0 : using component_list = tmpl::flatten<tmpl::list<
314 : observers::Observer<EvolutionMetavars>,
315 : observers::ObserverWriter<EvolutionMetavars>,
316 : mem_monitor::MemoryMonitor<EvolutionMetavars>,
317 : importers::ElementDataReader<EvolutionMetavars>, st_dg_element_array,
318 : ah::Component<EvolutionMetavars, ApparentHorizon>,
319 : tmpl::transform<
320 : control_system_horizon_metavars,
321 : tmpl::bind<ah::Component, tmpl::pin<EvolutionMetavars>, tmpl::_1>>,
322 : control_system::control_components<EvolutionMetavars, control_systems>,
323 : tmpl::transform<interpolation_target_tags,
324 : tmpl::bind<intrp::InterpolationTarget,
325 : tmpl::pin<EvolutionMetavars>, tmpl::_1>>>>;
326 : };
|