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