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