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