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 "Domain/Creators/Factory1D.hpp"
11 : #include "Domain/Tags.hpp"
12 : #include "Evolution/Actions/RunEventsAndDenseTriggers.hpp"
13 : #include "Evolution/Actions/RunEventsAndTriggers.hpp"
14 : #include "Evolution/BoundaryCorrection.hpp"
15 : #include "Evolution/ComputeTags.hpp"
16 : #include "Evolution/DgSubcell/Actions/Initialize.hpp"
17 : #include "Evolution/DgSubcell/Actions/Labels.hpp"
18 : #include "Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp"
19 : #include "Evolution/DgSubcell/Actions/SelectNumericalMethod.hpp"
20 : #include "Evolution/DgSubcell/Actions/TakeTimeStep.hpp"
21 : #include "Evolution/DgSubcell/Actions/TciAndRollback.hpp"
22 : #include "Evolution/DgSubcell/Actions/TciAndSwitchToDg.hpp"
23 : #include "Evolution/DgSubcell/GetTciDecision.hpp"
24 : #include "Evolution/DgSubcell/NeighborReconstructedFaceSolution.hpp"
25 : #include "Evolution/DgSubcell/NeighborTciDecision.hpp"
26 : #include "Evolution/DgSubcell/PrepareNeighborData.hpp"
27 : #include "Evolution/DgSubcell/Tags/ObserverCoordinates.hpp"
28 : #include "Evolution/DgSubcell/Tags/ObserverMesh.hpp"
29 : #include "Evolution/DgSubcell/Tags/TciStatus.hpp"
30 : #include "Evolution/DiscontinuousGalerkin/Actions/ApplyBoundaryCorrections.hpp"
31 : #include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivative.hpp"
32 : #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
33 : #include "Evolution/DiscontinuousGalerkin/Initialization/Mortars.hpp"
34 : #include "Evolution/DiscontinuousGalerkin/Initialization/QuadratureTag.hpp"
35 : #include "Evolution/DiscontinuousGalerkin/Limiters/Minmod.hpp"
36 : #include "Evolution/DiscontinuousGalerkin/Limiters/Tags.hpp"
37 : #include "Evolution/Initialization/ConservativeSystem.hpp"
38 : #include "Evolution/Initialization/DgDomain.hpp"
39 : #include "Evolution/Initialization/Evolution.hpp"
40 : #include "Evolution/Initialization/Limiter.hpp"
41 : #include "Evolution/Initialization/SetVariables.hpp"
42 : #include "Evolution/Systems/Burgers/BoundaryConditions/Factory.hpp"
43 : #include "Evolution/Systems/Burgers/BoundaryCorrections/Factory.hpp"
44 : #include "Evolution/Systems/Burgers/FiniteDifference/Factory.hpp"
45 : #include "Evolution/Systems/Burgers/FiniteDifference/Tags.hpp"
46 : #include "Evolution/Systems/Burgers/Subcell/GhostData.hpp"
47 : #include "Evolution/Systems/Burgers/Subcell/NeighborPackagedData.hpp"
48 : #include "Evolution/Systems/Burgers/Subcell/SetInitialRdmpData.hpp"
49 : #include "Evolution/Systems/Burgers/Subcell/TciOnDgGrid.hpp"
50 : #include "Evolution/Systems/Burgers/Subcell/TciOnFdGrid.hpp"
51 : #include "Evolution/Systems/Burgers/Subcell/TimeDerivative.hpp"
52 : #include "Evolution/Systems/Burgers/System.hpp"
53 : #include "IO/Observer/Actions/RegisterEvents.hpp"
54 : #include "IO/Observer/Helpers.hpp"
55 : #include "IO/Observer/ObserverComponent.hpp"
56 : #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
57 : #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
58 : #include "Options/Protocols/FactoryCreation.hpp"
59 : #include "Options/String.hpp"
60 : #include "Parallel/Local.hpp"
61 : #include "Parallel/Phase.hpp"
62 : #include "Parallel/PhaseControl/CheckpointAndExitAfterWallclock.hpp"
63 : #include "Parallel/PhaseControl/ExecutePhaseChange.hpp"
64 : #include "Parallel/PhaseControl/Factory.hpp"
65 : #include "Parallel/PhaseControl/VisitAndReturn.hpp"
66 : #include "Parallel/PhaseDependentActionList.hpp"
67 : #include "Parallel/Protocols/RegistrationMetavariables.hpp"
68 : #include "ParallelAlgorithms/Actions/AddComputeTags.hpp"
69 : #include "ParallelAlgorithms/Actions/InitializeItems.hpp"
70 : #include "ParallelAlgorithms/Actions/LimiterActions.hpp"
71 : #include "ParallelAlgorithms/Actions/MutateApply.hpp"
72 : #include "ParallelAlgorithms/Actions/TerminatePhase.hpp"
73 : #include "ParallelAlgorithms/Events/Factory.hpp"
74 : #include "ParallelAlgorithms/Events/Tags.hpp"
75 : #include "ParallelAlgorithms/EventsAndDenseTriggers/DenseTrigger.hpp"
76 : #include "ParallelAlgorithms/EventsAndDenseTriggers/DenseTriggers/Factory.hpp"
77 : #include "ParallelAlgorithms/EventsAndTriggers/Completion.hpp"
78 : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
79 : #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
80 : #include "ParallelAlgorithms/EventsAndTriggers/LogicalTriggers.hpp"
81 : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
82 : #include "PointwiseFunctions/AnalyticData/AnalyticData.hpp"
83 : #include "PointwiseFunctions/AnalyticData/Burgers/Factory.hpp"
84 : #include "PointwiseFunctions/AnalyticData/Burgers/Sinusoid.hpp"
85 : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
86 : #include "PointwiseFunctions/AnalyticSolutions/Burgers/Bump.hpp"
87 : #include "PointwiseFunctions/AnalyticSolutions/Burgers/Factory.hpp"
88 : #include "PointwiseFunctions/AnalyticSolutions/Burgers/Linear.hpp"
89 : #include "PointwiseFunctions/AnalyticSolutions/Burgers/Step.hpp"
90 : #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
91 : #include "Time/Actions/AdvanceTime.hpp"
92 : #include "Time/Actions/CleanHistory.hpp"
93 : #include "Time/Actions/SelfStartActions.hpp"
94 : #include "Time/ChangeSlabSize/Action.hpp"
95 : #include "Time/ChangeTimeStepperOrder.hpp"
96 : #include "Time/RecordTimeStepperData.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/TimeSequence.hpp"
102 : #include "Time/TimeSteppers/Factory.hpp"
103 : #include "Time/TimeSteppers/LtsTimeStepper.hpp"
104 : #include "Time/TimeSteppers/TimeStepper.hpp"
105 : #include "Time/Triggers/TimeTriggers.hpp"
106 : #include "Time/UpdateU.hpp"
107 : #include "Utilities/ProtocolHelpers.hpp"
108 : #include "Utilities/TMPL.hpp"
109 :
110 : /// \cond
111 : namespace PUP {
112 : class er;
113 : } // namespace PUP
114 : namespace Parallel {
115 : template <typename Metavariables>
116 : class CProxy_GlobalCache;
117 : } // namespace Parallel
118 : /// \endcond
119 :
120 0 : struct EvolutionMetavars {
121 0 : static constexpr size_t volume_dim = 1;
122 0 : using system = Burgers::System;
123 0 : using temporal_id = Tags::TimeStepId;
124 0 : using TimeStepperBase = TimeStepper;
125 :
126 0 : static constexpr bool local_time_stepping =
127 : TimeStepperBase::local_time_stepping;
128 0 : static constexpr bool use_dg_element_collection = false;
129 :
130 : // The use_dg_subcell flag controls whether to use "standard" limiting (false)
131 : // or a DG-FD hybrid scheme (true).
132 0 : static constexpr bool use_dg_subcell = true;
133 :
134 0 : using initial_data_list = tmpl::append<Burgers::Solutions::all_solutions,
135 : Burgers::AnalyticData::all_data>;
136 :
137 0 : using limiter =
138 : Tags::Limiter<Limiters::Minmod<1, system::variables_tag::tags_list>>;
139 :
140 0 : using analytic_variables_tags = typename system::variables_tag::tags_list;
141 0 : using analytic_compute = evolution::Tags::AnalyticSolutionsCompute<
142 : volume_dim, analytic_variables_tags, use_dg_subcell, initial_data_list>;
143 0 : using error_compute = Tags::ErrorsCompute<analytic_variables_tags>;
144 0 : using error_tags = db::wrap_tags_in<Tags::Error, analytic_variables_tags>;
145 0 : using observe_fields = tmpl::push_back<
146 : tmpl::append<
147 : typename system::variables_tag::tags_list, error_tags,
148 : tmpl::conditional_t<use_dg_subcell,
149 : tmpl::list<evolution::dg::subcell::Tags::
150 : TciStatusCompute<volume_dim>>,
151 : tmpl::list<>>>,
152 : ::Events::Tags::ObserverDetInvJacobianCompute<Frame::ElementLogical,
153 : Frame::Inertial>,
154 : tmpl::conditional_t<
155 : use_dg_subcell,
156 : evolution::dg::subcell::Tags::ObserverCoordinatesCompute<volume_dim,
157 : Frame::Grid>,
158 : domain::Tags::Coordinates<volume_dim, Frame::Grid>>,
159 : tmpl::conditional_t<
160 : use_dg_subcell,
161 : evolution::dg::subcell::Tags::ObserverCoordinatesCompute<
162 : volume_dim, Frame::Inertial>,
163 : domain::Tags::Coordinates<volume_dim, Frame::Inertial>>>;
164 0 : using non_tensor_compute_tags = tmpl::list<
165 : tmpl::conditional_t<
166 : use_dg_subcell,
167 : evolution::dg::subcell::Tags::ObserverMeshCompute<volume_dim>,
168 : ::Events::Tags::ObserverMeshCompute<volume_dim>>,
169 : analytic_compute, error_compute>;
170 :
171 0 : struct factory_creation
172 : : tt::ConformsTo<Options::protocols::FactoryCreation> {
173 0 : using factory_classes = tmpl::map<
174 : tmpl::pair<Burgers::BoundaryConditions::BoundaryCondition,
175 : Burgers::BoundaryConditions::standard_boundary_conditions>,
176 : tmpl::pair<DenseTrigger, DenseTriggers::standard_dense_triggers>,
177 : tmpl::pair<DomainCreator<volume_dim>, domain_creators<volume_dim>>,
178 : tmpl::pair<Event,
179 : tmpl::flatten<tmpl::list<
180 : Events::Completion,
181 : dg::Events::field_observations<
182 : volume_dim, observe_fields, non_tensor_compute_tags>,
183 : Events::time_events<system>>>>,
184 : tmpl::pair<evolution::BoundaryCorrection,
185 : Burgers::BoundaryCorrections::standard_boundary_corrections>,
186 : tmpl::pair<evolution::initial_data::InitialData, initial_data_list>,
187 : tmpl::pair<PhaseChange, PhaseControl::factory_creatable_classes>,
188 : tmpl::pair<StepChooser<StepChooserUse::LtsStep>,
189 : StepChoosers::standard_step_choosers<system>>,
190 : tmpl::pair<
191 : StepChooser<StepChooserUse::Slab>,
192 : StepChoosers::standard_slab_choosers<system, local_time_stepping>>,
193 : tmpl::pair<TimeSequence<double>,
194 : TimeSequences::all_time_sequences<double>>,
195 : tmpl::pair<TimeSequence<std::uint64_t>,
196 : TimeSequences::all_time_sequences<std::uint64_t>>,
197 : tmpl::pair<TimeStepper, TimeSteppers::time_steppers>,
198 : tmpl::pair<Trigger, tmpl::append<Triggers::logical_triggers,
199 : Triggers::time_triggers>>>;
200 : };
201 :
202 0 : struct SubcellOptions {
203 0 : static constexpr bool subcell_enabled = use_dg_subcell;
204 0 : static constexpr bool subcell_enabled_at_external_boundary = true;
205 :
206 : // We send `ghost_zone_size` cell-centered grid points for variable
207 : // reconstruction, of which we need `ghost_zone_size-1` for reconstruction
208 : // to the internal side of the element face, and `ghost_zone_size` for
209 : // reconstruction to the external side of the element face.
210 : template <typename DbTagsList>
211 0 : static constexpr size_t ghost_zone_size(
212 : const db::DataBox<DbTagsList>& box) {
213 : return db::get<Burgers::fd::Tags::Reconstructor>(box).ghost_zone_size();
214 : }
215 :
216 0 : using DgComputeSubcellNeighborPackagedData =
217 : Burgers::subcell::NeighborPackagedData;
218 :
219 0 : using GhostVariables = Burgers::subcell::GhostVariables;
220 : };
221 :
222 0 : using observed_reduction_data_tags =
223 : observers::collect_reduction_data_tags<tmpl::flatten<tmpl::list<
224 : tmpl::at<typename factory_creation::factory_classes, Event>>>>;
225 :
226 0 : using dg_step_actions = tmpl::flatten<tmpl::list<
227 : evolution::dg::Actions::ComputeTimeDerivative<
228 : volume_dim, system, AllStepChoosers, local_time_stepping,
229 : use_dg_element_collection>,
230 : tmpl::conditional_t<
231 : local_time_stepping,
232 : tmpl::list<Actions::MutateApply<RecordTimeStepperData<system>>,
233 : evolution::Actions::RunEventsAndDenseTriggers<
234 : tmpl::list<evolution::dg::ApplyBoundaryCorrections<
235 : local_time_stepping, EvolutionMetavars, volume_dim,
236 : true>>>,
237 : Actions::MutateApply<UpdateU<system, local_time_stepping>>,
238 : evolution::dg::Actions::ApplyLtsBoundaryCorrections<
239 : volume_dim, false, use_dg_element_collection>,
240 : Actions::MutateApply<ChangeTimeStepperOrder<system>>>,
241 : tmpl::list<
242 : evolution::dg::Actions::ApplyBoundaryCorrectionsToTimeDerivative<
243 : volume_dim, false, use_dg_element_collection>,
244 : Actions::MutateApply<RecordTimeStepperData<system>>,
245 : evolution::Actions::RunEventsAndDenseTriggers<tmpl::list<>>,
246 : Actions::MutateApply<UpdateU<system, local_time_stepping>>>>,
247 : Actions::CleanHistory<system, local_time_stepping>,
248 : Limiters::Actions::SendData<EvolutionMetavars>,
249 : Limiters::Actions::Limit<EvolutionMetavars>>>;
250 :
251 0 : using dg_subcell_step_actions = tmpl::flatten<tmpl::list<
252 : evolution::dg::subcell::Actions::SelectNumericalMethod,
253 : Actions::Label<evolution::dg::subcell::Actions::Labels::BeginDg>,
254 : evolution::dg::Actions::ComputeTimeDerivative<
255 : volume_dim, system, AllStepChoosers, local_time_stepping,
256 : use_dg_element_collection>,
257 : evolution::dg::Actions::ApplyBoundaryCorrectionsToTimeDerivative<
258 : volume_dim, false, use_dg_element_collection>,
259 : Actions::MutateApply<RecordTimeStepperData<system>>,
260 : evolution::Actions::RunEventsAndDenseTriggers<tmpl::list<>>,
261 : Actions::MutateApply<UpdateU<system, local_time_stepping>>,
262 : evolution::dg::subcell::Actions::TciAndRollback<
263 : Burgers::subcell::TciOnDgGrid>,
264 : Actions::CleanHistory<system, local_time_stepping>,
265 : Actions::Goto<evolution::dg::subcell::Actions::Labels::EndOfSolvers>,
266 : Actions::Label<evolution::dg::subcell::Actions::Labels::BeginSubcell>,
267 : evolution::dg::subcell::Actions::SendDataForReconstruction<
268 : volume_dim, Burgers::subcell::GhostVariables, local_time_stepping,
269 : use_dg_element_collection>,
270 : evolution::dg::subcell::Actions::ReceiveDataForReconstruction<volume_dim>,
271 : Actions::Label<
272 : evolution::dg::subcell::Actions::Labels::BeginSubcellAfterDgRollback>,
273 : evolution::dg::subcell::fd::Actions::TakeTimeStep<
274 : Burgers::subcell::TimeDerivative>,
275 : Actions::MutateApply<RecordTimeStepperData<system>>,
276 : evolution::Actions::RunEventsAndDenseTriggers<tmpl::list<>>,
277 : Actions::MutateApply<UpdateU<system, local_time_stepping>>,
278 : Actions::CleanHistory<system, local_time_stepping>,
279 : evolution::dg::subcell::Actions::TciAndSwitchToDg<
280 : Burgers::subcell::TciOnFdGrid>,
281 : Actions::Label<evolution::dg::subcell::Actions::Labels::EndOfSolvers>>>;
282 :
283 0 : using step_actions =
284 : tmpl::conditional_t<use_dg_subcell, dg_subcell_step_actions,
285 : dg_step_actions>;
286 :
287 0 : using const_global_cache_tags = tmpl::list<
288 : evolution::initial_data::Tags::InitialData,
289 : tmpl::conditional_t<use_dg_subcell,
290 : tmpl::list<Burgers::fd::Tags::Reconstructor>,
291 : tmpl::list<>>>;
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::ConservativeSystem<system>,
302 :
303 : tmpl::conditional_t<
304 : use_dg_subcell,
305 : tmpl::list<
306 : evolution::dg::subcell::Actions::SetSubcellGrid<volume_dim,
307 : system, false>,
308 : evolution::dg::subcell::Actions::SetAndCommunicateInitialRdmpData<
309 : volume_dim, Burgers::subcell::SetInitialRdmpData>,
310 : evolution::dg::subcell::Actions::ComputeAndSendTciOnInitialGrid<
311 : volume_dim, system, Burgers::subcell::TciOnFdGrid>,
312 : evolution::dg::subcell::Actions::SetInitialGridFromTciData<
313 : volume_dim, system>>,
314 : tmpl::list<evolution::Initialization::Actions::SetVariables<
315 : domain::Tags::Coordinates<1, Frame::ElementLogical>>>>,
316 :
317 : Initialization::Actions::AddComputeTags<
318 : StepChoosers::step_chooser_compute_tags<EvolutionMetavars,
319 : local_time_stepping>>,
320 : ::evolution::dg::Initialization::Mortars<volume_dim, system>,
321 : Initialization::Actions::Minmod<1>,
322 : evolution::Actions::InitializeRunEventsAndDenseTriggers,
323 : Parallel::Actions::TerminatePhase>;
324 :
325 0 : using dg_element_array = DgElementArray<
326 : EvolutionMetavars,
327 : tmpl::list<
328 : Parallel::PhaseActions<Parallel::Phase::Initialization,
329 : initialization_actions>,
330 :
331 : Parallel::PhaseActions<Parallel::Phase::Register,
332 : tmpl::list<dg_registration_list,
333 : Parallel::Actions::TerminatePhase>>,
334 :
335 : Parallel::PhaseActions<Parallel::Phase::Restart,
336 : tmpl::list<dg_registration_list,
337 : Parallel::Actions::TerminatePhase>>,
338 :
339 : Parallel::PhaseActions<
340 : Parallel::Phase::WriteCheckpoint,
341 : tmpl::list<evolution::Actions::RunEventsAndTriggers<
342 : Triggers::WhenToCheck::AtCheckpoints>,
343 : Parallel::Actions::TerminatePhase>>,
344 :
345 : Parallel::PhaseActions<
346 : Parallel::Phase::InitializeTimeStepperHistory,
347 : SelfStart::self_start_procedure<step_actions, system>>,
348 :
349 : Parallel::PhaseActions<
350 : Parallel::Phase::Evolve,
351 : tmpl::flatten<tmpl::list<
352 : std::conditional_t<local_time_stepping,
353 : evolution::Actions::RunEventsAndTriggers<
354 : Triggers::WhenToCheck::AtSteps>,
355 : tmpl::list<>>,
356 : evolution::Actions::RunEventsAndTriggers<
357 : Triggers::WhenToCheck::AtSlabs>,
358 : Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime,
359 : PhaseControl::Actions::ExecutePhaseChange>>>>>;
360 :
361 0 : struct registration
362 : : tt::ConformsTo<Parallel::protocols::RegistrationMetavariables> {
363 0 : using element_registrars =
364 : tmpl::map<tmpl::pair<dg_element_array, dg_registration_list>>;
365 : };
366 :
367 0 : using component_list =
368 : tmpl::list<observers::Observer<EvolutionMetavars>,
369 : observers::ObserverWriter<EvolutionMetavars>,
370 : dg_element_array>;
371 :
372 0 : static constexpr Options::String help{
373 : "Evolve the Burgers equation.\n\n"
374 : "The analytic solution is: Linear\n"
375 : "The numerical flux is: LocalLaxFriedrichs\n"};
376 :
377 0 : static constexpr std::array<Parallel::Phase, 5> default_phase_order{
378 : {Parallel::Phase::Initialization,
379 : Parallel::Phase::InitializeTimeStepperHistory, Parallel::Phase::Register,
380 : Parallel::Phase::Evolve, Parallel::Phase::Exit}};
381 :
382 : // NOLINTNEXTLINE(google-runtime-references)
383 0 : void pup(PUP::er& /*p*/) {}
384 : };
|