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