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