Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <cstdint>
8 : #include <vector>
9 :
10 : #include "DataStructures/Tensor/EagerMath/Norms.hpp"
11 : #include "Domain/Creators/Factory1D.hpp"
12 : #include "Domain/Creators/Factory2D.hpp"
13 : #include "Domain/Creators/Factory3D.hpp"
14 : #include "Domain/Tags.hpp"
15 : #include "Evolution/Actions/RunEventsAndDenseTriggers.hpp"
16 : #include "Evolution/Actions/RunEventsAndTriggers.hpp"
17 : #include "Evolution/BoundaryCorrection.hpp"
18 : #include "Evolution/ComputeTags.hpp"
19 : #include "Evolution/DiscontinuousGalerkin/Actions/ApplyBoundaryCorrections.hpp"
20 : #include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivative.hpp"
21 : #include "Evolution/DiscontinuousGalerkin/CleanMortarHistory.hpp"
22 : #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
23 : #include "Evolution/DiscontinuousGalerkin/Initialization/Mortars.hpp"
24 : #include "Evolution/DiscontinuousGalerkin/Initialization/QuadratureTag.hpp"
25 : #include "Evolution/Initialization/DgDomain.hpp"
26 : #include "Evolution/Initialization/Evolution.hpp"
27 : #include "Evolution/Initialization/NonconservativeSystem.hpp"
28 : #include "Evolution/Initialization/SetVariables.hpp"
29 : #include "Evolution/Systems/CurvedScalarWave/Actions/SetInitialData.hpp"
30 : #include "Evolution/Systems/CurvedScalarWave/BackgroundSpacetime.hpp"
31 : #include "Evolution/Systems/CurvedScalarWave/BoundaryConditions/Factory.hpp"
32 : #include "Evolution/Systems/CurvedScalarWave/BoundaryCorrections/Factory.hpp"
33 : #include "Evolution/Systems/CurvedScalarWave/CalculateGrVars.hpp"
34 : #include "Evolution/Systems/CurvedScalarWave/Constraints.hpp"
35 : #include "Evolution/Systems/CurvedScalarWave/Initialize.hpp"
36 : #include "Evolution/Systems/CurvedScalarWave/PsiSquared.hpp"
37 : #include "Evolution/Systems/CurvedScalarWave/System.hpp"
38 : #include "Evolution/Systems/CurvedScalarWave/Tags.hpp"
39 : #include "Evolution/Tags/Filter.hpp"
40 : #include "IO/Importers/Actions/RegisterWithElementDataReader.hpp"
41 : #include "IO/Importers/ElementDataReader.hpp"
42 : #include "IO/Observer/Actions/RegisterEvents.hpp"
43 : #include "IO/Observer/Helpers.hpp"
44 : #include "IO/Observer/ObserverComponent.hpp"
45 : #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
46 : #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
47 : #include "NumericalAlgorithms/LinearOperators/ExponentialFilter.hpp"
48 : #include "Options/Protocols/FactoryCreation.hpp"
49 : #include "Options/String.hpp"
50 : #include "Parallel/Local.hpp"
51 : #include "Parallel/Phase.hpp"
52 : #include "Parallel/PhaseControl/CheckpointAndExitAfterWallclock.hpp"
53 : #include "Parallel/PhaseControl/ExecutePhaseChange.hpp"
54 : #include "Parallel/PhaseControl/Factory.hpp"
55 : #include "Parallel/PhaseControl/VisitAndReturn.hpp"
56 : #include "Parallel/PhaseDependentActionList.hpp"
57 : #include "Parallel/Protocols/RegistrationMetavariables.hpp"
58 : #include "Parallel/Reduction.hpp"
59 : #include "ParallelAlgorithms/Actions/AddComputeTags.hpp"
60 : #include "ParallelAlgorithms/Actions/AddSimpleTags.hpp"
61 : #include "ParallelAlgorithms/Actions/FilterAction.hpp"
62 : #include "ParallelAlgorithms/Actions/InitializeItems.hpp"
63 : #include "ParallelAlgorithms/Actions/MutateApply.hpp"
64 : #include "ParallelAlgorithms/Actions/TerminatePhase.hpp"
65 : #include "ParallelAlgorithms/Events/Completion.hpp"
66 : #include "ParallelAlgorithms/Events/Factory.hpp"
67 : #include "ParallelAlgorithms/Events/ObserveNorms.hpp"
68 : #include "ParallelAlgorithms/Events/ObserveTimeStepVolume.hpp"
69 : #include "ParallelAlgorithms/EventsAndDenseTriggers/DenseTrigger.hpp"
70 : #include "ParallelAlgorithms/EventsAndDenseTriggers/DenseTriggers/Factory.hpp"
71 : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
72 : #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
73 : #include "ParallelAlgorithms/EventsAndTriggers/LogicalTriggers.hpp"
74 : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
75 : #include "ParallelAlgorithms/Interpolation/Actions/ElementInitInterpPoints.hpp"
76 : #include "ParallelAlgorithms/Interpolation/Actions/InitializeInterpolationTarget.hpp"
77 : #include "ParallelAlgorithms/Interpolation/Callbacks/ObserveTimeSeriesOnSurface.hpp"
78 : #include "ParallelAlgorithms/Interpolation/Events/InterpolateWithoutInterpComponent.hpp"
79 : #include "ParallelAlgorithms/Interpolation/InterpolationTarget.hpp"
80 : #include "ParallelAlgorithms/Interpolation/Protocols/InterpolationTargetTag.hpp"
81 : #include "ParallelAlgorithms/Interpolation/Tags.hpp"
82 : #include "ParallelAlgorithms/Interpolation/Targets/Sphere.hpp"
83 : #include "PointwiseFunctions/AnalyticData/AnalyticData.hpp"
84 : #include "PointwiseFunctions/AnalyticData/CurvedWaveEquation/PureSphericalHarmonic.hpp"
85 : #include "PointwiseFunctions/AnalyticData/Tags.hpp"
86 : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
87 : #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/KerrSchild.hpp"
88 : #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/Minkowski.hpp"
89 : #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
90 : #include "PointwiseFunctions/AnalyticSolutions/WaveEquation/Factory.hpp"
91 : #include "PointwiseFunctions/AnalyticSolutions/WaveEquation/PlaneWave.hpp"
92 : #include "PointwiseFunctions/GeneralRelativity/Christoffel.hpp"
93 : #include "PointwiseFunctions/GeneralRelativity/GeneralizedHarmonic/ExtrinsicCurvature.hpp"
94 : #include "PointwiseFunctions/GeneralRelativity/KerrHorizon.hpp"
95 : #include "PointwiseFunctions/GeneralRelativity/Surfaces/Tags.hpp"
96 : #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
97 : #include "PointwiseFunctions/InitialDataUtilities/Tags/InitialData.hpp"
98 : #include "PointwiseFunctions/MathFunctions/Factory.hpp"
99 : #include "PointwiseFunctions/MathFunctions/MathFunction.hpp"
100 : #include "Time/Actions/SelfStartActions.hpp"
101 : #include "Time/AdvanceTime.hpp"
102 : #include "Time/ChangeSlabSize/Action.hpp"
103 : #include "Time/ChangeTimeStepperOrder.hpp"
104 : #include "Time/CleanHistory.hpp"
105 : #include "Time/RecordTimeStepperData.hpp"
106 : #include "Time/StepChoosers/ByBlock.hpp"
107 : #include "Time/StepChoosers/Factory.hpp"
108 : #include "Time/StepChoosers/StepChooser.hpp"
109 : #include "Time/Tags/Time.hpp"
110 : #include "Time/Tags/TimeStepId.hpp"
111 : #include "Time/TimeSteppers/Factory.hpp"
112 : #include "Time/TimeSteppers/LtsTimeStepper.hpp"
113 : #include "Time/TimeSteppers/TimeStepper.hpp"
114 : #include "Time/Triggers/TimeTriggers.hpp"
115 : #include "Time/UpdateU.hpp"
116 : #include "Utilities/ErrorHandling/Error.hpp"
117 : #include "Utilities/ProtocolHelpers.hpp"
118 : #include "Utilities/TMPL.hpp"
119 :
120 : /// \cond
121 : namespace Frame {
122 : struct Inertial;
123 : } // namespace Frame
124 : namespace Parallel {
125 : template <typename Metavariables>
126 : class CProxy_GlobalCache;
127 : } // namespace Parallel
128 : namespace PUP {
129 : class er;
130 : } // namespace PUP
131 : /// \endcond
132 :
133 : template <size_t Dim, typename BackgroundSpacetime>
134 : struct EvolutionMetavars {
135 : static constexpr size_t volume_dim = Dim;
136 0 : using background_spacetime = BackgroundSpacetime;
137 :
138 0 : using system = CurvedScalarWave::System<Dim>;
139 0 : using temporal_id = Tags::TimeStepId;
140 0 : using TimeStepperBase = LtsTimeStepper;
141 :
142 : static constexpr bool local_time_stepping =
143 : TimeStepperBase::local_time_stepping;
144 : static constexpr bool use_dg_element_collection = false;
145 :
146 0 : using deriv_compute = ::Tags::DerivCompute<
147 : typename system::variables_tag, domain::Tags::Mesh<volume_dim>,
148 : domain::Tags::InverseJacobian<volume_dim, Frame::ElementLogical,
149 : Frame::Inertial>,
150 : typename system::gradient_variables>;
151 :
152 0 : using observe_fields = tmpl::push_back<
153 : tmpl::flatten<tmpl::list<
154 : tmpl::append<typename system::variables_tag::tags_list,
155 : typename deriv_compute::type::tags_list>,
156 : ::Events::Tags::ObserverDetInvJacobianCompute<Frame::ElementLogical,
157 : Frame::Inertial>,
158 : CurvedScalarWave::Tags::OneIndexConstraintCompute<volume_dim>,
159 : CurvedScalarWave::Tags::TwoIndexConstraintCompute<volume_dim>,
160 : ::Tags::PointwiseL2NormCompute<
161 : CurvedScalarWave::Tags::OneIndexConstraint<volume_dim>>,
162 : ::Tags::PointwiseL2NormCompute<
163 : CurvedScalarWave::Tags::TwoIndexConstraint<volume_dim>>>>,
164 : domain::Tags::Coordinates<volume_dim, Frame::Grid>,
165 : domain::Tags::Coordinates<volume_dim, Frame::Inertial>>;
166 0 : using non_tensor_compute_tags =
167 : tmpl::list<::Events::Tags::ObserverMeshCompute<volume_dim>,
168 : deriv_compute>;
169 :
170 0 : static constexpr bool interpolate = volume_dim == 3;
171 0 : struct SphericalSurface
172 : : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
173 0 : using temporal_id = ::Tags::Time;
174 0 : using vars_to_interpolate_to_target =
175 : tmpl::list<gr::Tags::SpatialMetric<DataVector, Dim>,
176 : CurvedScalarWave::Tags::Psi>;
177 0 : using compute_items_on_target =
178 : tmpl::list<CurvedScalarWave::Tags::PsiSquaredCompute,
179 : gr::surfaces::Tags::AreaElementCompute<::Frame::Inertial>,
180 : gr::surfaces::Tags::SurfaceIntegralCompute<
181 : CurvedScalarWave::Tags::PsiSquared, ::Frame::Inertial>>;
182 0 : using compute_target_points =
183 : intrp::TargetPoints::Sphere<SphericalSurface, ::Frame::Inertial>;
184 0 : using post_interpolation_callbacks =
185 : tmpl::list<intrp::callbacks::ObserveTimeSeriesOnSurface<
186 : tmpl::list<gr::surfaces::Tags::SurfaceIntegral<
187 : CurvedScalarWave::Tags::PsiSquared, ::Frame::Inertial>>,
188 : SphericalSurface>>;
189 : template <typename metavariables>
190 0 : using interpolating_component = typename metavariables::dg_element_array;
191 : };
192 :
193 0 : using initial_data_list = tmpl::flatten<tmpl::list<
194 : ScalarWave::Solutions::all_solutions<Dim>,
195 : tmpl::conditional_t<
196 : Dim == 3,
197 : tmpl::list<CurvedScalarWave::AnalyticData::PureSphericalHarmonic,
198 : CurvedScalarWave::NumericInitialData>,
199 : tmpl::list<>>>>;
200 0 : using interpolation_target_tags = tmpl::list<SphericalSurface>;
201 0 : using interpolator_source_vars =
202 : tmpl::list<gr::Tags::SpatialMetric<DataVector, volume_dim>,
203 : CurvedScalarWave::Tags::Psi>;
204 : struct factory_creation
205 : : tt::ConformsTo<Options::protocols::FactoryCreation> {
206 0 : using factory_classes = tmpl::map<
207 : tmpl::pair<
208 : CurvedScalarWave::BoundaryConditions::BoundaryCondition<volume_dim>,
209 : CurvedScalarWave::BoundaryConditions::standard_boundary_conditions<
210 : volume_dim>>,
211 : tmpl::pair<DenseTrigger, DenseTriggers::standard_dense_triggers>,
212 : tmpl::pair<DomainCreator<volume_dim>, domain_creators<volume_dim>>,
213 : tmpl::pair<
214 : Event,
215 : tmpl::flatten<tmpl::list<
216 : Events::Completion,
217 : dg::Events::field_observations<volume_dim, observe_fields,
218 : non_tensor_compute_tags>,
219 : tmpl::conditional_t<
220 : interpolate,
221 : intrp::Events::InterpolateWithoutInterpComponent<
222 : volume_dim, SphericalSurface, interpolator_source_vars>,
223 : tmpl::list<>>,
224 : Events::time_events<system>,
225 : dg::Events::ObserveTimeStepVolume<system>>>>,
226 : tmpl::pair<evolution::BoundaryCorrection,
227 : CurvedScalarWave::BoundaryCorrections::
228 : standard_boundary_corrections<volume_dim>>,
229 : tmpl::pair<evolution::initial_data::InitialData, initial_data_list>,
230 : tmpl::pair<LtsTimeStepper, TimeSteppers::lts_time_steppers>,
231 : tmpl::pair<MathFunction<1, Frame::Inertial>,
232 : MathFunctions::all_math_functions<1, Frame::Inertial>>,
233 : tmpl::pair<PhaseChange, PhaseControl::factory_creatable_classes>,
234 : tmpl::pair<StepChooser<StepChooserUse::LtsStep>,
235 : tmpl::push_back<StepChoosers::standard_step_choosers<system>,
236 : StepChoosers::ByBlock<volume_dim>>>,
237 : tmpl::pair<StepChooser<StepChooserUse::Slab>,
238 : tmpl::push_back<StepChoosers::standard_slab_choosers<
239 : system, local_time_stepping>,
240 : StepChoosers::ByBlock<volume_dim>>>,
241 : tmpl::pair<TimeSequence<double>,
242 : TimeSequences::all_time_sequences<double>>,
243 : tmpl::pair<TimeSequence<std::uint64_t>,
244 : TimeSequences::all_time_sequences<std::uint64_t>>,
245 : tmpl::pair<TimeStepper, TimeSteppers::time_steppers>,
246 : tmpl::pair<Trigger, tmpl::append<Triggers::logical_triggers,
247 : Triggers::time_triggers>>>;
248 : };
249 :
250 0 : using observed_reduction_data_tags = observers::collect_reduction_data_tags<
251 : tmpl::at<typename factory_creation::factory_classes, Event>>;
252 :
253 0 : static constexpr bool use_filtering = true;
254 :
255 0 : using step_actions = tmpl::flatten<tmpl::list<
256 : CurvedScalarWave::Actions::CalculateGrVars<system, true>,
257 : evolution::dg::Actions::ComputeTimeDerivative<
258 : volume_dim, system, AllStepChoosers, local_time_stepping,
259 : use_dg_element_collection>,
260 : evolution::dg::Actions::ApplyBoundaryCorrectionsToTimeDerivative<
261 : volume_dim, use_dg_element_collection>,
262 : Actions::MutateApply<RecordTimeStepperData<system>>,
263 : tmpl::conditional_t<
264 : local_time_stepping,
265 : tmpl::list<evolution::Actions::RunEventsAndDenseTriggers<
266 : tmpl::list<evolution::dg::ApplyBoundaryCorrections<
267 : local_time_stepping, EvolutionMetavars, volume_dim,
268 : true>>>,
269 : Actions::MutateApply<UpdateU<system, local_time_stepping>>,
270 : evolution::dg::Actions::ApplyLtsBoundaryCorrections<
271 : volume_dim, false, use_dg_element_collection>,
272 : Actions::MutateApply<ChangeTimeStepperOrder<system>>>,
273 : tmpl::list<
274 : evolution::Actions::RunEventsAndDenseTriggers<tmpl::list<>>,
275 : Actions::MutateApply<UpdateU<system, local_time_stepping>>>>,
276 : Actions::MutateApply<CleanHistory<system>>,
277 : tmpl::conditional_t<
278 : local_time_stepping,
279 : Actions::MutateApply<evolution::dg::CleanMortarHistory<volume_dim>>,
280 : tmpl::list<>>,
281 : tmpl::conditional_t<
282 : use_filtering,
283 : dg::Actions::Filter<Filters::Exponential<0>,
284 : tmpl::list<CurvedScalarWave::Tags::Psi,
285 : CurvedScalarWave::Tags::Pi,
286 : CurvedScalarWave::Tags::Phi<Dim>>>,
287 : tmpl::list<>>>>;
288 :
289 0 : using const_global_cache_tags = tmpl::list<
290 : CurvedScalarWave::Tags::BackgroundSpacetime<BackgroundSpacetime>,
291 : evolution::initial_data::Tags::InitialData>;
292 :
293 0 : using dg_registration_list =
294 : tmpl::list<observers::Actions::RegisterEventsWithObservers>;
295 :
296 0 : using initialization_actions = tmpl::list<
297 : Initialization::Actions::InitializeItems<
298 : Initialization::TimeStepping<EvolutionMetavars, TimeStepperBase>,
299 : evolution::dg::Initialization::Domain<EvolutionMetavars>,
300 : Initialization::TimeStepperHistory<EvolutionMetavars>>,
301 : Initialization::Actions::NonconservativeSystem<system>,
302 : CurvedScalarWave::Actions::CalculateGrVars<system, false>,
303 : Initialization::Actions::AddSimpleTags<
304 : CurvedScalarWave::Initialization::InitializeConstraintDampingGammas<
305 : volume_dim>>,
306 : Initialization::Actions::AddComputeTags<
307 : tmpl::flatten<tmpl::list<StepChoosers::step_chooser_compute_tags<
308 : EvolutionMetavars, local_time_stepping>>>>,
309 : ::evolution::dg::Initialization::Mortars<volume_dim>,
310 : intrp::Actions::ElementInitInterpPoints<volume_dim,
311 : interpolation_target_tags>,
312 : evolution::Actions::InitializeRunEventsAndDenseTriggers,
313 : Parallel::Actions::TerminatePhase>;
314 :
315 0 : using dg_element_array = DgElementArray<
316 : EvolutionMetavars,
317 : tmpl::list<
318 : Parallel::PhaseActions<Parallel::Phase::Initialization,
319 : initialization_actions>,
320 : Parallel::PhaseActions<
321 : Parallel::Phase::RegisterWithElementDataReader,
322 : tmpl::list<importers::Actions::RegisterWithElementDataReader,
323 : Parallel::Actions::TerminatePhase>>,
324 : Parallel::PhaseActions<
325 : Parallel::Phase::ImportInitialData,
326 : tmpl::list<CurvedScalarWave::Actions::SetInitialData,
327 : CurvedScalarWave::Actions::ReceiveNumericInitialData,
328 : Parallel::Actions::TerminatePhase>>,
329 : Parallel::PhaseActions<
330 : Parallel::Phase::InitializeTimeStepperHistory,
331 : SelfStart::self_start_procedure<step_actions, system>>,
332 : Parallel::PhaseActions<Parallel::Phase::Register,
333 : tmpl::list<dg_registration_list,
334 : Parallel::Actions::TerminatePhase>>,
335 : Parallel::PhaseActions<Parallel::Phase::Restart,
336 : tmpl::list<dg_registration_list,
337 : Parallel::Actions::TerminatePhase>>,
338 : Parallel::PhaseActions<
339 : Parallel::Phase::WriteCheckpoint,
340 : tmpl::list<evolution::Actions::RunEventsAndTriggers<
341 : Triggers::WhenToCheck::AtCheckpoints>,
342 : Parallel::Actions::TerminatePhase>>,
343 : Parallel::PhaseActions<
344 : Parallel::Phase::Evolve,
345 : tmpl::flatten<tmpl::list<
346 : std::conditional_t<local_time_stepping,
347 : evolution::Actions::RunEventsAndTriggers<
348 : Triggers::WhenToCheck::AtSteps>,
349 : tmpl::list<>>,
350 : evolution::Actions::RunEventsAndTriggers<
351 : Triggers::WhenToCheck::AtSlabs>,
352 : Actions::ChangeSlabSize, step_actions,
353 : Actions::MutateApply<AdvanceTime<>>,
354 : PhaseControl::Actions::ExecutePhaseChange>>>>>;
355 :
356 : struct registration
357 : : tt::ConformsTo<Parallel::protocols::RegistrationMetavariables> {
358 0 : using element_registrars =
359 : tmpl::map<tmpl::pair<dg_element_array, dg_registration_list>>;
360 : };
361 :
362 0 : using component_list = tmpl::flatten<
363 : tmpl::list<observers::Observer<EvolutionMetavars>,
364 : observers::ObserverWriter<EvolutionMetavars>,
365 : importers::ElementDataReader<EvolutionMetavars>,
366 : tmpl::conditional_t<interpolate,
367 : intrp::InterpolationTarget<
368 : EvolutionMetavars, SphericalSurface>,
369 : tmpl::list<>>,
370 : dg_element_array>>;
371 :
372 : static constexpr Options::String help{
373 : "Evolve a scalar wave in Dim spatial dimension on a curved background "
374 : "spacetime."};
375 :
376 0 : static constexpr auto default_phase_order =
377 : std::array{Parallel::Phase::Initialization,
378 : Parallel::Phase::RegisterWithElementDataReader,
379 : Parallel::Phase::ImportInitialData,
380 : Parallel::Phase::InitializeTimeStepperHistory,
381 : Parallel::Phase::Register,
382 : Parallel::Phase::Evolve,
383 : Parallel::Phase::Exit};
384 :
385 : // NOLINTNEXTLINE(google-runtime-references)
386 0 : void pup(PUP::er& /*p*/) {}
387 : };
|