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/IndexType.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/EqualRateLts/ChangeFixedLtsRatio.hpp"
24 : #include "Evolution/DiscontinuousGalerkin/EqualRateLts/FixedLtsRatio.hpp"
25 : #include "Evolution/DiscontinuousGalerkin/EqualRateLts/NonconformingEqualRateRegions.hpp"
26 : #include "Evolution/DiscontinuousGalerkin/Initialization/Mortars.hpp"
27 : #include "Evolution/DiscontinuousGalerkin/Initialization/ProjectSpectralFilters.hpp"
28 : #include "Evolution/DiscontinuousGalerkin/Initialization/QuadratureTag.hpp"
29 : #include "Evolution/DiscontinuousGalerkin/Initialization/SetupEqualRateRegions.hpp"
30 : #include "Evolution/DiscontinuousGalerkin/Initialization/SpectralFilters.hpp"
31 : #include "Evolution/Initialization/DgDomain.hpp"
32 : #include "Evolution/Initialization/Evolution.hpp"
33 : #include "Evolution/Initialization/NonconservativeSystem.hpp"
34 : #include "Evolution/Initialization/SetVariables.hpp"
35 : #include "Evolution/Systems/ScalarWave/BoundaryConditions/Factory.hpp"
36 : #include "Evolution/Systems/ScalarWave/BoundaryCorrections/Factory.hpp"
37 : #include "Evolution/Systems/ScalarWave/EnergyDensity.hpp"
38 : #include "Evolution/Systems/ScalarWave/Equations.hpp"
39 : #include "Evolution/Systems/ScalarWave/Initialize.hpp"
40 : #include "Evolution/Systems/ScalarWave/MomentumDensity.hpp"
41 : #include "Evolution/Systems/ScalarWave/System.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/Filters/Factory.hpp"
48 : #include "NumericalAlgorithms/LinearOperators/Filters/FilledSphere.hpp"
49 : #include "NumericalAlgorithms/LinearOperators/Filters/SphericalShell.hpp"
50 : #include "NumericalAlgorithms/LinearOperators/Filters/Tag.hpp"
51 : #include "Options/Protocols/FactoryCreation.hpp"
52 : #include "Options/String.hpp"
53 : #include "Parallel/ArrayCollection/DgElementCollection.hpp"
54 : #include "Parallel/Local.hpp"
55 : #include "Parallel/Phase.hpp"
56 : #include "Parallel/PhaseControl/CheckpointAndExitAfterWallclock.hpp"
57 : #include "Parallel/PhaseControl/ExecutePhaseChange.hpp"
58 : #include "Parallel/PhaseControl/Factory.hpp"
59 : #include "Parallel/PhaseControl/VisitAndReturn.hpp"
60 : #include "Parallel/PhaseDependentActionList.hpp"
61 : #include "Parallel/Protocols/RegistrationMetavariables.hpp"
62 : #include "Parallel/Reduction.hpp"
63 : #include "ParallelAlgorithms/Actions/AddComputeTags.hpp"
64 : #include "ParallelAlgorithms/Actions/InitializeItems.hpp"
65 : #include "ParallelAlgorithms/Actions/MutateApply.hpp"
66 : #include "ParallelAlgorithms/Actions/SpectralFilter.hpp"
67 : #include "ParallelAlgorithms/Actions/TerminatePhase.hpp"
68 : #include "ParallelAlgorithms/Amr/Actions/CollectDataFromChildren.hpp"
69 : #include "ParallelAlgorithms/Amr/Actions/Component.hpp"
70 : #include "ParallelAlgorithms/Amr/Actions/CreateChild.hpp"
71 : #include "ParallelAlgorithms/Amr/Actions/Initialize.hpp"
72 : #include "ParallelAlgorithms/Amr/Actions/SendAmrDiagnostics.hpp"
73 : #include "ParallelAlgorithms/Amr/Criteria/Criterion.hpp"
74 : #include "ParallelAlgorithms/Amr/Criteria/Factory.hpp"
75 : #include "ParallelAlgorithms/Amr/Criteria/Tags/Criteria.hpp"
76 : #include "ParallelAlgorithms/Amr/Events/ObserveAmrCriteria.hpp"
77 : #include "ParallelAlgorithms/Amr/Events/ObserveAmrStats.hpp"
78 : #include "ParallelAlgorithms/Amr/Events/RefineMesh.hpp"
79 : #include "ParallelAlgorithms/Amr/Projectors/CopyFromCreatorOrLeaveAsIs.hpp"
80 : #include "ParallelAlgorithms/Amr/Projectors/DefaultInitialize.hpp"
81 : #include "ParallelAlgorithms/Amr/Projectors/Tensors.hpp"
82 : #include "ParallelAlgorithms/Amr/Projectors/Variables.hpp"
83 : #include "ParallelAlgorithms/Amr/Protocols/AmrMetavariables.hpp"
84 : #include "ParallelAlgorithms/Events/ChangeFixedLtsRatio.hpp"
85 : #include "ParallelAlgorithms/Events/Completion.hpp"
86 : #include "ParallelAlgorithms/Events/Factory.hpp"
87 : #include "ParallelAlgorithms/Events/Tags.hpp"
88 : #include "ParallelAlgorithms/EventsAndDenseTriggers/DenseTrigger.hpp"
89 : #include "ParallelAlgorithms/EventsAndDenseTriggers/DenseTriggers/Factory.hpp"
90 : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
91 : #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
92 : #include "ParallelAlgorithms/EventsAndTriggers/LogicalTriggers.hpp"
93 : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
94 : #include "PointwiseFunctions/AnalyticData/AnalyticData.hpp"
95 : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
96 : #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
97 : #include "PointwiseFunctions/AnalyticSolutions/WaveEquation/Factory.hpp"
98 : #include "PointwiseFunctions/AnalyticSolutions/WaveEquation/PlaneWave.hpp"
99 : #include "PointwiseFunctions/AnalyticSolutions/WaveEquation/RegularSphericalWave.hpp"
100 : #include "PointwiseFunctions/InitialDataUtilities/NumericData.hpp"
101 : #include "PointwiseFunctions/InitialDataUtilities/WithNoise.hpp"
102 : #include "PointwiseFunctions/MathFunctions/Factory.hpp"
103 : #include "PointwiseFunctions/MathFunctions/MathFunction.hpp"
104 : #include "Time/Actions/SelfStartActions.hpp"
105 : #include "Time/AdvanceTime.hpp"
106 : #include "Time/ChangeSlabSize/Action.hpp"
107 : #include "Time/ChangeSlabSize/Tags.hpp"
108 : #include "Time/ChangeTimeStepperOrder.hpp"
109 : #include "Time/CleanHistory.hpp"
110 : #include "Time/RecordTimeStepperData.hpp"
111 : #include "Time/StepChoosers/Factory.hpp"
112 : #include "Time/StepChoosers/StepChooser.hpp"
113 : #include "Time/Tags/StepperErrors.hpp"
114 : #include "Time/Tags/Time.hpp"
115 : #include "Time/Tags/TimeStepId.hpp"
116 : #include "Time/TimeSequence.hpp"
117 : #include "Time/TimeSteppers/Factory.hpp"
118 : #include "Time/TimeSteppers/TimeStepper.hpp"
119 : #include "Time/Triggers/TimeTriggers.hpp"
120 : #include "Time/UpdateU.hpp"
121 : #include "Utilities/ErrorHandling/Error.hpp"
122 : #include "Utilities/Functional.hpp"
123 : #include "Utilities/ProtocolHelpers.hpp"
124 : #include "Utilities/TMPL.hpp"
125 :
126 : /// \cond
127 : namespace Frame {
128 :
129 : struct Inertial;
130 : } // namespace Frame
131 : namespace Parallel {
132 : template <typename Metavariables>
133 : class CProxy_GlobalCache;
134 : } // namespace Parallel
135 : namespace PUP {
136 : class er;
137 : } // namespace PUP
138 : /// \endcond
139 :
140 : template <size_t Dim>
141 : struct EvolutionMetavars {
142 : static constexpr size_t volume_dim = Dim;
143 :
144 0 : using initial_data_list = ScalarWave::Solutions::all_solutions<Dim>;
145 :
146 0 : using system = ScalarWave::System<Dim>;
147 0 : using temporal_id = Tags::TimeStepId;
148 :
149 : static constexpr bool use_dg_element_collection = false;
150 :
151 0 : using analytic_solution_fields = typename system::variables_tag::tags_list;
152 0 : using deriv_compute = ::Tags::DerivCompute<
153 : typename system::variables_tag, domain::Tags::Mesh<volume_dim>,
154 : domain::Tags::InverseJacobian<volume_dim, Frame::ElementLogical,
155 : Frame::Inertial>,
156 : typename system::gradient_variables,
157 : domain::Tags::Coordinates<volume_dim, Frame::Inertial>>;
158 0 : using analytic_compute =
159 : evolution::Tags::AnalyticSolutionsCompute<Dim, analytic_solution_fields,
160 : false, initial_data_list>;
161 0 : using error_compute = Tags::ErrorsCompute<analytic_solution_fields>;
162 0 : using error_tags = db::wrap_tags_in<Tags::Error, analytic_solution_fields>;
163 :
164 0 : using observe_fields = tmpl::push_back<
165 : tmpl::append<typename system::variables_tag::tags_list,
166 : typename deriv_compute::type::tags_list, error_tags>,
167 : ScalarWave::Tags::EnergyDensityCompute<volume_dim>,
168 : ScalarWave::Tags::MomentumDensityCompute<volume_dim>,
169 : ScalarWave::Tags::OneIndexConstraintCompute<volume_dim>,
170 : ScalarWave::Tags::TwoIndexConstraintCompute<volume_dim>,
171 : ::Tags::PointwiseL2NormCompute<
172 : ScalarWave::Tags::OneIndexConstraint<volume_dim>>,
173 : ::Tags::PointwiseL2NormCompute<
174 : ScalarWave::Tags::TwoIndexConstraint<volume_dim>>,
175 : domain::Tags::Coordinates<volume_dim, Frame::Grid>,
176 : domain::Tags::Coordinates<volume_dim, Frame::Inertial>>;
177 0 : using non_tensor_compute_tags =
178 : tmpl::list<::Events::Tags::ObserverMeshCompute<volume_dim>,
179 : ::Events::Tags::ObserverDetInvJacobianCompute<
180 : Frame::ElementLogical, Frame::Inertial>,
181 : deriv_compute, analytic_compute, error_compute>;
182 :
183 : struct factory_creation
184 : : tt::ConformsTo<Options::protocols::FactoryCreation> {
185 0 : using factory_classes = tmpl::map<
186 : tmpl::pair<amr::Criterion,
187 : amr::Criteria::standard_criteria<
188 : volume_dim, typename system::variables_tag::tags_list>>,
189 : tmpl::pair<DenseTrigger, DenseTriggers::standard_dense_triggers>,
190 : tmpl::pair<DomainCreator<volume_dim>, domain_creators<volume_dim>>,
191 : tmpl::pair<Event,
192 : tmpl::flatten<tmpl::list<
193 : Events::Completion, amr::Events::RefineMesh,
194 : amr::Events::ObserveAmrStats<volume_dim>,
195 : amr::Events::ObserveAmrCriteria<EvolutionMetavars>,
196 : dg::Events::field_observations<
197 : volume_dim, observe_fields, non_tensor_compute_tags>,
198 : Events::time_events<system>,
199 : dg::Events::ChangeFixedLtsRatio<volume_dim>>>>,
200 : tmpl::pair<evolution::BoundaryCorrection,
201 : ScalarWave::BoundaryCorrections::
202 : standard_boundary_corrections<volume_dim>>,
203 : tmpl::pair<evolution::initial_data::InitialData,
204 : tmpl::push_back<initial_data_list,
205 : evolution::initial_data::NumericData,
206 : evolution::initial_data::WithNoise>>,
207 : tmpl::pair<MathFunction<1, Frame::Inertial>,
208 : MathFunctions::all_math_functions<1, Frame::Inertial>>,
209 : tmpl::pair<PhaseChange, PhaseControl::factory_creatable_classes>,
210 : tmpl::pair<
211 : ScalarWave::BoundaryConditions::BoundaryCondition<volume_dim>,
212 : ScalarWave::BoundaryConditions::standard_boundary_conditions<
213 : volume_dim>>,
214 : tmpl::pair<StepChooser<StepChooserUse::LtsStep>,
215 : StepChoosers::standard_step_choosers<system>>,
216 : tmpl::pair<StepChooser<StepChooserUse::Slab>,
217 : tmpl::push_back<
218 : StepChoosers::standard_slab_choosers<system>,
219 : evolution::dg::StepChoosers::FixedLtsRatio<volume_dim>>>,
220 : tmpl::pair<TimeSequence<double>,
221 : TimeSequences::all_time_sequences<double>>,
222 : tmpl::pair<TimeSequence<std::uint64_t>,
223 : TimeSequences::all_time_sequences<std::uint64_t>>,
224 : tmpl::pair<TimeStepper, TimeSteppers::time_steppers>,
225 : tmpl::pair<Trigger, tmpl::append<Triggers::logical_triggers,
226 : Triggers::time_triggers>>,
227 : tmpl::pair<
228 : Filters::Filter<volume_dim,
229 : typename system::variables_tag::tags_list>,
230 : tmpl::append<
231 : Filters::all_filters<volume_dim,
232 : typename system::variables_tag::tags_list>,
233 : tmpl::conditional_t<
234 : volume_dim == 3,
235 : tmpl::list<Filters::SphericalShell<
236 : typename system::variables_tag::tags_list>,
237 : Filters::FilledSphere<
238 : typename system::variables_tag::tags_list>>,
239 : tmpl::list<>>>>>;
240 : };
241 :
242 0 : using observed_reduction_data_tags =
243 : observers::collect_reduction_data_tags<tmpl::flatten<tmpl::list<
244 : tmpl::at<typename factory_creation::factory_classes, Event>>>>;
245 :
246 0 : using step_actions = tmpl::flatten<tmpl::list<
247 : evolution::dg::Actions::ComputeTimeDerivative<
248 : volume_dim, system, AllStepChoosers, use_dg_element_collection>,
249 : evolution::dg::Actions::ApplyBoundaryCorrectionsToTimeDerivative<
250 : volume_dim, use_dg_element_collection>,
251 : Actions::MutateApply<RecordTimeStepperData<system>>,
252 : evolution::Actions::RunEventsAndDenseTriggers<tmpl::list<
253 : evolution::dg::ApplyLtsDenseBoundaryCorrections<EvolutionMetavars>>>,
254 : Actions::MutateApply<UpdateU<system>>,
255 : evolution::dg::Actions::ApplyLtsBoundaryCorrections<
256 : volume_dim, use_dg_element_collection>,
257 : Actions::MutateApply<ChangeTimeStepperOrder<system>>,
258 : Actions::MutateApply<CleanHistory<system>>,
259 : Actions::MutateApply<evolution::dg::CleanMortarHistory<volume_dim>>,
260 : dg::Actions::SpectralFilter<volume_dim,
261 : typename system::variables_tag::tags_list>>>;
262 :
263 0 : using const_global_cache_tags =
264 : tmpl::list<evolution::initial_data::Tags::InitialData>;
265 :
266 0 : using dg_registration_list =
267 : tmpl::list<observers::Actions::RegisterEventsWithObservers>;
268 :
269 0 : using equal_rate_regions =
270 : tmpl::list<evolution::dg::NonconformingEqualRateRegions<volume_dim>>;
271 :
272 0 : using initialization_actions = tmpl::list<
273 : Initialization::Actions::InitializeItems<
274 : Initialization::TimeStepping<EvolutionMetavars, TimeStepper, false,
275 : true>,
276 : evolution::dg::Initialization::Domain<EvolutionMetavars>,
277 : ::amr::Initialization::Initialize<volume_dim, EvolutionMetavars>>,
278 : Initialization::Actions::NonconservativeSystem<system>,
279 : Initialization::Actions::InitializeItems<
280 : Initialization::TimeStepperHistory<system>>,
281 : evolution::Initialization::Actions::SetVariables<
282 : domain::Tags::Coordinates<Dim, Frame::ElementLogical>>,
283 : ScalarWave::Actions::InitializeConstraints<volume_dim>,
284 : Initialization::Actions::AddComputeTags<
285 : StepChoosers::step_chooser_compute_tags<EvolutionMetavars>>,
286 : ::evolution::dg::Initialization::Mortars<volume_dim>,
287 : evolution::dg::Initialization::Actions::SetupEqualRateRegions<
288 : EvolutionMetavars, volume_dim, equal_rate_regions>,
289 : evolution::Actions::InitializeRunEventsAndDenseTriggers,
290 : Initialization::Actions::InitializeItems<
291 : evolution::dg::Initialization::SpectralFilters<
292 : volume_dim, typename system::variables_tag::tags_list>>,
293 : Parallel::Actions::TerminatePhase>;
294 :
295 0 : using dg_element_array = DgElementArray<
296 : EvolutionMetavars,
297 : tmpl::list<
298 : Parallel::PhaseActions<Parallel::Phase::Initialization,
299 : initialization_actions>,
300 :
301 : Parallel::PhaseActions<
302 : Parallel::Phase::InitializeTimeStepperHistory,
303 : SelfStart::self_start_procedure<step_actions, system>>,
304 :
305 : Parallel::PhaseActions<Parallel::Phase::Register,
306 : tmpl::list<dg_registration_list,
307 : Parallel::Actions::TerminatePhase>>,
308 :
309 : Parallel::PhaseActions<Parallel::Phase::Restart,
310 : tmpl::list<dg_registration_list,
311 : Parallel::Actions::TerminatePhase>>,
312 :
313 : Parallel::PhaseActions<
314 : Parallel::Phase::WriteCheckpoint,
315 : tmpl::list<evolution::Actions::RunEventsAndTriggers<
316 : Triggers::WhenToCheck::AtCheckpoints>,
317 : Parallel::Actions::TerminatePhase>>,
318 :
319 : Parallel::PhaseActions<Parallel::Phase::CheckDomain,
320 : tmpl::list<::amr::Actions::SendAmrDiagnostics,
321 : Parallel::Actions::TerminatePhase>>,
322 :
323 : Parallel::PhaseActions<
324 : Parallel::Phase::Evolve,
325 : tmpl::flatten<
326 : tmpl::list<evolution::Actions::RunEventsAndTriggers<
327 : Triggers::WhenToCheck::AtSteps>,
328 : evolution::Actions::RunEventsAndTriggers<
329 : Triggers::WhenToCheck::AtSlabs>,
330 : Actions::ChangeSlabSize,
331 : evolution::dg::Actions::ChangeFixedLtsRatio,
332 : step_actions, Actions::MutateApply<AdvanceTime<>>,
333 : PhaseControl::Actions::ExecutePhaseChange>>>>>;
334 :
335 : struct amr : tt::ConformsTo<::amr::protocols::AmrMetavariables> {
336 0 : using element_array = dg_element_array;
337 0 : using projectors = tmpl::list<
338 : Initialization::ProjectTimeStepping<volume_dim>,
339 : evolution::dg::Initialization::ProjectDomain<volume_dim>,
340 : ::amr::projectors::ProjectVariables<volume_dim,
341 : typename system::variables_tag>,
342 : ::amr::projectors::ProjectTensors<volume_dim,
343 : ::ScalarWave::Tags::ConstraintGamma2>,
344 : evolution::dg::Initialization::ProjectMortars<volume_dim>,
345 : Initialization::ProjectTimeStepperHistory<EvolutionMetavars>,
346 : evolution::Actions::ProjectRunEventsAndDenseTriggers,
347 : evolution::dg::Initialization::ProjectSpectralFilters<
348 : volume_dim, typename system::variables_tag::tags_list>,
349 : ::amr::projectors::DefaultInitialize<
350 : Initialization::Tags::InitialTimeDelta,
351 : Initialization::Tags::InitialSlabSize,
352 : ::domain::Tags::InitialExtents<volume_dim>,
353 : ::domain::Tags::InitialRefinementLevels<volume_dim>,
354 : evolution::dg::Tags::Quadrature,
355 : Tags::StepperErrors<typename system::variables_tag>,
356 : SelfStart::Tags::InitialValue<typename system::variables_tag>,
357 : SelfStart::Tags::InitialValue<Tags::TimeStep>>,
358 : ::amr::projectors::CopyFromCreatorOrLeaveAsIs<
359 : evolution::dg::Tags::ChangeFixedLtsRatio::NumberOfExpectedMessages,
360 : evolution::dg::Tags::ChangeFixedLtsRatio::NewStepSize,
361 : Tags::FixedLtsRatio,
362 : Parallel::Tags::Section<dg_element_array,
363 : evolution::dg::Tags::EqualRateRegionId>,
364 : Tags::ChangeSlabSize::NumberOfExpectedMessages,
365 : Tags::ChangeSlabSize::NewSlabSize>>;
366 : static constexpr bool keep_coarse_grids = false;
367 : static constexpr bool p_refine_only_in_event = true;
368 : };
369 :
370 : struct registration
371 : : tt::ConformsTo<Parallel::protocols::RegistrationMetavariables> {
372 0 : using element_registrars =
373 : tmpl::map<tmpl::pair<dg_element_array, dg_registration_list>>;
374 : };
375 :
376 0 : using component_list =
377 : tmpl::list<::amr::Component<EvolutionMetavars>,
378 : observers::Observer<EvolutionMetavars>,
379 : observers::ObserverWriter<EvolutionMetavars>,
380 : dg_element_array>;
381 :
382 : static constexpr Options::String help{
383 : "Evolve a Scalar Wave in Dim spatial dimension.\n\n"
384 : "The numerical flux is: UpwindFlux\n"};
385 :
386 : static constexpr auto default_phase_order = std::array<Parallel::Phase, 6>{
387 : Parallel::Phase::Initialization,
388 : Parallel::Phase::InitializeTimeStepperHistory,
389 : Parallel::Phase::Register,
390 : Parallel::Phase::CheckDomain,
391 : Parallel::Phase::Evolve,
392 : Parallel::Phase::Exit};
393 :
394 : // NOLINTNEXTLINE(google-runtime-references)
395 0 : void pup(PUP::er& /*p*/) {}
396 : };
|