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