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/Measurements/SingleHorizon.hpp"
12 : #include "ControlSystem/Metafunctions.hpp"
13 : #include "ControlSystem/Systems/Shape.hpp"
14 : #include "ControlSystem/Trigger.hpp"
15 : #include "Domain/Structure/ObjectLabel.hpp"
16 : #include "Evolution/Actions/RunEventsAndTriggers.hpp"
17 : #include "Evolution/Executables/ScalarTensor/ScalarTensorBase.hpp"
18 : #include "Evolution/Systems/GeneralizedHarmonic/Actions/SetInitialData.hpp"
19 : #include "Options/FactoryHelpers.hpp"
20 : #include "Options/Protocols/FactoryCreation.hpp"
21 : #include "Options/String.hpp"
22 : #include "Parallel/MemoryMonitor/MemoryMonitor.hpp"
23 : #include "Parallel/PhaseControl/ExecutePhaseChange.hpp"
24 : #include "ParallelAlgorithms/Actions/FunctionsOfTimeAreReady.hpp"
25 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/ErrorOnFailedApparentHorizon.hpp"
26 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/FindApparentHorizon.hpp"
27 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/IgnoreFailedApparentHorizon.hpp"
28 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.hpp"
29 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.tpp"
30 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.hpp"
31 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.tpp"
32 : #include "ParallelAlgorithms/ApparentHorizonFinder/HorizonAliases.hpp"
33 : #include "ParallelAlgorithms/ApparentHorizonFinder/InterpolationTarget.hpp"
34 : #include "ParallelAlgorithms/Interpolation/Actions/CleanUpInterpolator.hpp"
35 : #include "ParallelAlgorithms/Interpolation/Actions/ElementInitInterpPoints.hpp"
36 : #include "ParallelAlgorithms/Interpolation/Actions/InitializeInterpolationTarget.hpp"
37 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolationTargetReceiveVars.hpp"
38 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorReceivePoints.hpp"
39 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorReceiveVolumeData.hpp"
40 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorRegisterElement.hpp"
41 : #include "ParallelAlgorithms/Interpolation/Actions/TryToInterpolate.hpp"
42 : #include "ParallelAlgorithms/Interpolation/Callbacks/ObserveSurfaceData.hpp"
43 : #include "ParallelAlgorithms/Interpolation/Callbacks/ObserveTimeSeriesOnSurface.hpp"
44 : #include "ParallelAlgorithms/Interpolation/Events/Interpolate.hpp"
45 : #include "ParallelAlgorithms/Interpolation/Events/InterpolateWithoutInterpComponent.hpp"
46 : #include "ParallelAlgorithms/Interpolation/InterpolationTarget.hpp"
47 : #include "ParallelAlgorithms/Interpolation/Interpolator.hpp"
48 : #include "ParallelAlgorithms/Interpolation/Protocols/InterpolationTargetTag.hpp"
49 : #include "ParallelAlgorithms/Interpolation/Tags.hpp"
50 : #include "ParallelAlgorithms/Interpolation/Targets/Sphere.hpp"
51 : #include "PointwiseFunctions/GeneralRelativity/DetAndInverseSpatialMetric.hpp"
52 : #include "PointwiseFunctions/GeneralRelativity/Surfaces/Tags.hpp"
53 : #include "Time/Actions/SelfStartActions.hpp"
54 : #include "Time/ChangeSlabSize/Action.hpp"
55 : #include "Time/StepChoosers/Factory.hpp"
56 : #include "Time/Tags/Time.hpp"
57 : #include "Utilities/ErrorHandling/Error.hpp"
58 : #include "Utilities/ProtocolHelpers.hpp"
59 :
60 : struct EvolutionMetavars : public ScalarTensorTemplateBase<EvolutionMetavars> {
61 0 : using st_base = ScalarTensorTemplateBase<EvolutionMetavars>;
62 : using typename st_base::initialize_initial_data_dependent_quantities_actions;
63 : using typename st_base::system;
64 :
65 : static constexpr size_t volume_dim = 3_st;
66 :
67 : static constexpr Options::String help{
68 : "Evolve the Einstein field equations in GH gauge coupled to a scalar "
69 : "field \n"
70 : "on a domain with a single horizon and corresponding excised region"};
71 :
72 : struct AhA : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
73 0 : using temporal_id = ::Tags::Time;
74 0 : using tags_to_observe = ::ah::tags_for_observing<Frame::Inertial>;
75 0 : using surface_tags_to_observe = ::ah::surface_tags_for_observing;
76 0 : using compute_vars_to_interpolate = ah::ComputeHorizonVolumeQuantities;
77 0 : using vars_to_interpolate_to_target =
78 : ::ah::vars_to_interpolate_to_target<volume_dim, ::Frame::Inertial>;
79 0 : using compute_items_on_target =
80 : ::ah::compute_items_on_target<volume_dim, Frame::Inertial>;
81 0 : using compute_target_points =
82 : intrp::TargetPoints::ApparentHorizon<AhA, ::Frame::Inertial>;
83 0 : using post_interpolation_callbacks = tmpl::list<
84 : intrp::callbacks::FindApparentHorizon<AhA, ::Frame::Inertial>>;
85 0 : using horizon_find_failure_callback =
86 : intrp::callbacks::IgnoreFailedApparentHorizon;
87 0 : using post_horizon_find_callbacks = tmpl::list<
88 : intrp::callbacks::ObserveTimeSeriesOnSurface<tags_to_observe, AhA>,
89 : intrp::callbacks::ObserveSurfaceData<surface_tags_to_observe, AhA,
90 : ::Frame::Inertial>>;
91 : };
92 :
93 0 : struct ExcisionBoundaryA
94 : : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
95 0 : using temporal_id = ::Tags::Time;
96 0 : using tags_to_observe =
97 : tmpl::list<gr::Tags::Lapse<DataVector>,
98 : gr::Tags::Shift<DataVector, 3, Frame::Grid>>;
99 0 : using compute_vars_to_interpolate =
100 : ah::ComputeExcisionBoundaryVolumeQuantities;
101 0 : using vars_to_interpolate_to_target = tags_to_observe;
102 0 : using compute_items_on_source = tmpl::list<>;
103 0 : using compute_items_on_target = tmpl::list<>;
104 0 : using compute_target_points =
105 : intrp::TargetPoints::Sphere<ExcisionBoundaryA, ::Frame::Grid>;
106 0 : using post_interpolation_callbacks =
107 : tmpl::list<intrp::callbacks::ObserveSurfaceData<
108 : tags_to_observe, ExcisionBoundaryA, ::Frame::Grid>>;
109 : // run_callbacks
110 : template <typename metavariables>
111 0 : using interpolating_component = typename metavariables::st_dg_element_array;
112 : };
113 :
114 : struct SphericalSurface
115 : : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
116 0 : using temporal_id = ::Tags::Time;
117 :
118 0 : using vars_to_interpolate_to_target =
119 : detail::ObserverTags::scalar_charge_vars_to_interpolate_to_target;
120 0 : using compute_items_on_target =
121 : detail::ObserverTags::scalar_charge_compute_items_on_target;
122 0 : using compute_target_points =
123 : intrp::TargetPoints::Sphere<SphericalSurface, ::Frame::Inertial>;
124 0 : using post_interpolation_callbacks =
125 : tmpl::list<intrp::callbacks::ObserveTimeSeriesOnSurface<
126 : detail::ObserverTags::scalar_charge_surface_obs_tags,
127 : SphericalSurface>>;
128 : template <typename metavariables>
129 0 : using interpolating_component = typename metavariables::st_dg_element_array;
130 : };
131 :
132 0 : using control_systems = tmpl::list<control_system::Systems::Shape<
133 : ::domain::ObjectLabel::None, 2,
134 : control_system::measurements::SingleHorizon<
135 : ::domain::ObjectLabel::None>>>;
136 :
137 : static constexpr bool use_control_systems =
138 : tmpl::size<control_systems>::value > 0;
139 :
140 0 : using interpolation_target_tags = tmpl::push_back<
141 : control_system::metafunctions::interpolation_target_tags<control_systems>,
142 : AhA, ExcisionBoundaryA, SphericalSurface>;
143 0 : using interpolator_source_vars = ::ah::source_vars<volume_dim>;
144 :
145 0 : using scalar_charge_interpolator_source_vars =
146 : detail::ObserverTags::scalar_charge_vars_to_interpolate_to_target;
147 :
148 : // The interpolator_source_vars need to be the same in both the
149 : // Interpolate event and the InterpolateWithoutInterpComponent event. The
150 : // Interpolate event interpolates to the horizon, and the
151 : // InterpolateWithoutInterpComponent event interpolates to the excision
152 : // boundary. Every Target gets the same interpolator_source_vars, so they need
153 : // to be made the same. Otherwise a static assert is triggered.
154 : struct factory_creation
155 : : tt::ConformsTo<Options::protocols::FactoryCreation> {
156 0 : using factory_classes = Options::add_factory_classes<
157 : // Restrict to monotonic time steppers in LTS to avoid control
158 : // systems deadlocking.
159 : tmpl::insert<
160 : tmpl::erase<typename st_base::factory_creation::factory_classes,
161 : LtsTimeStepper>,
162 : tmpl::pair<LtsTimeStepper,
163 : TimeSteppers::monotonic_lts_time_steppers>>,
164 : tmpl::pair<Event,
165 : tmpl::flatten<tmpl::list<
166 : intrp::Events::Interpolate<volume_dim, AhA,
167 : interpolator_source_vars>,
168 : intrp::Events::InterpolateWithoutInterpComponent<
169 : volume_dim, ExcisionBoundaryA,
170 : interpolator_source_vars>,
171 : intrp::Events::InterpolateWithoutInterpComponent<
172 : volume_dim, SphericalSurface,
173 : scalar_charge_interpolator_source_vars>>>>,
174 : tmpl::pair<DenseTrigger,
175 : control_system::control_system_triggers<control_systems>>>;
176 : };
177 :
178 : using typename st_base::const_global_cache_tags;
179 :
180 0 : using observed_reduction_data_tags =
181 : observers::collect_reduction_data_tags<tmpl::push_back<
182 : tmpl::at<typename factory_creation::factory_classes, Event>,
183 : typename AhA::post_horizon_find_callbacks>>;
184 :
185 0 : using dg_registration_list =
186 : tmpl::push_back<typename st_base::dg_registration_list,
187 : intrp::Actions::RegisterElementWithInterpolator>;
188 :
189 0 : using step_actions = typename st_base::template step_actions<control_systems>;
190 :
191 0 : using initialization_actions = tmpl::push_back<
192 : tmpl::pop_back<typename st_base::template initialization_actions<
193 : use_control_systems>>,
194 : control_system::Actions::InitializeMeasurements<control_systems>,
195 : intrp::Actions::ElementInitInterpPoints<
196 : intrp::Tags::InterpPointInfo<EvolutionMetavars>>,
197 : tmpl::back<typename st_base::template initialization_actions<
198 : use_control_systems>>>;
199 :
200 0 : using st_dg_element_array = DgElementArray<
201 : EvolutionMetavars,
202 : tmpl::flatten<tmpl::list<
203 : Parallel::PhaseActions<Parallel::Phase::Initialization,
204 : initialization_actions>,
205 : Parallel::PhaseActions<
206 : Parallel::Phase::InitializeInitialDataDependentQuantities,
207 : initialize_initial_data_dependent_quantities_actions>,
208 : Parallel::PhaseActions<
209 : Parallel::Phase::InitializeTimeStepperHistory,
210 : SelfStart::self_start_procedure<step_actions, system>>,
211 : Parallel::PhaseActions<Parallel::Phase::Register,
212 : tmpl::list<dg_registration_list,
213 : Parallel::Actions::TerminatePhase>>,
214 : Parallel::PhaseActions<
215 : Parallel::Phase::Evolve,
216 : tmpl::list<
217 : ::domain::Actions::CheckFunctionsOfTimeAreReady<volume_dim>,
218 : evolution::Actions::RunEventsAndTriggers<local_time_stepping>,
219 : Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime,
220 : PhaseControl::Actions::ExecutePhaseChange>>>>>;
221 :
222 : template <typename ParallelComponent>
223 0 : struct registration_list {
224 0 : using type = std::conditional_t<
225 : std::is_same_v<ParallelComponent, st_dg_element_array>,
226 : dg_registration_list, tmpl::list<>>;
227 : };
228 :
229 0 : using component_list = tmpl::flatten<tmpl::list<
230 : observers::Observer<EvolutionMetavars>,
231 : observers::ObserverWriter<EvolutionMetavars>,
232 : mem_monitor::MemoryMonitor<EvolutionMetavars>,
233 : st_dg_element_array, intrp::Interpolator<EvolutionMetavars>,
234 : control_system::control_components<EvolutionMetavars, control_systems>,
235 : tmpl::transform<interpolation_target_tags,
236 : tmpl::bind<intrp::InterpolationTarget,
237 : tmpl::pin<EvolutionMetavars>, tmpl::_1>>>>;
238 : };
|