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