1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
4 #pragma once
6 #include <cstddef>
7 #include <vector>
9 #include "Domain/Creators/RegisterDerivedWithCharm.hpp"
10 #include "Domain/Tags.hpp"
12 #include "Evolution/Actions/ComputeTimeDerivative.hpp"
13 #include "Evolution/Actions/ComputeVolumeFluxes.hpp"
14 #include "Evolution/Actions/ComputeVolumeSources.hpp"
15 #include "Evolution/ComputeTags.hpp"
16 #include "Evolution/Conservative/UpdateConservatives.hpp"
17 #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
19 #include "Evolution/DiscontinuousGalerkin/Limiters/Minmod.tpp"
20 #include "Evolution/DiscontinuousGalerkin/Limiters/Tags.hpp"
21 #include "Evolution/Initialization/ConservativeSystem.hpp"
22 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
23 #include "Evolution/Initialization/Evolution.hpp"
24 #include "Evolution/Initialization/GrTagsForHydro.hpp"
25 #include "Evolution/Initialization/Limiter.hpp"
26 #include "Evolution/Systems/RelativisticEuler/Valencia/FixConservatives.hpp"
27 #include "Evolution/Systems/RelativisticEuler/Valencia/System.hpp"
28 #include "Evolution/Systems/RelativisticEuler/Valencia/Tags.hpp"
29 #include "Evolution/VariableFixing/Actions.hpp"
30 #include "Evolution/VariableFixing/FixToAtmosphere.hpp"
31 #include "Evolution/VariableFixing/Tags.hpp"
32 #include "IO/Observer/Actions.hpp"
33 #include "IO/Observer/Helpers.hpp"
34 #include "IO/Observer/ObserverComponent.hpp"
35 #include "IO/Observer/RegisterObservers.hpp"
36 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyBoundaryFluxesLocalTimeStepping.hpp"
37 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyFluxes.hpp"
39 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp"
40 #include "NumericalAlgorithms/DiscontinuousGalerkin/NumericalFluxes/LocalLaxFriedrichs.hpp"
41 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
42 #include "Options/Options.hpp"
43 #include "Parallel/Actions/TerminatePhase.hpp"
44 #include "Parallel/InitializationFunctions.hpp"
45 #include "Parallel/PhaseDependentActionList.hpp"
47 #include "ParallelAlgorithms/Actions/MutateApply.hpp"
48 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeDomain.hpp"
49 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeInterfaces.hpp"
50 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeMortars.hpp"
51 #include "ParallelAlgorithms/Events/ObserveErrorNorms.hpp"
52 #include "ParallelAlgorithms/Events/ObserveFields.hpp"
53 #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp"
54 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
55 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
57 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
58 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
59 #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/SmoothFlow.hpp"
60 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
61 #include "PointwiseFunctions/Hydro/SoundSpeedSquared.hpp"
62 #include "PointwiseFunctions/Hydro/Tags.hpp"
64 #include "Time/Actions/ChangeSlabSize.hpp"
65 #include "Time/Actions/ChangeStepSize.hpp"
66 #include "Time/Actions/RecordTimeStepperData.hpp"
67 #include "Time/Actions/SelfStartActions.hpp"
68 #include "Time/Actions/UpdateU.hpp"
69 #include "Time/StepChoosers/Cfl.hpp"
70 #include "Time/StepChoosers/Constant.hpp"
71 #include "Time/StepChoosers/Increase.hpp"
72 #include "Time/StepChoosers/PreventRapidIncrease.hpp"
73 #include "Time/StepChoosers/StepChooser.hpp"
75 #include "Time/Tags.hpp"
76 #include "Time/TimeSteppers/TimeStepper.hpp"
77 #include "Time/Triggers/TimeTriggers.hpp"
78 #include "Utilities/Functional.hpp"
79 #include "Utilities/TMPL.hpp"
81 /// \cond
82 namespace Frame {
83 struct Inertial;
84 } // namespace Frame
85 namespace Parallel {
86 template <typename Metavariables>
87 class CProxy_ConstGlobalCache;
88 } // namespace Parallel
89 /// \endcond
91 template <size_t Dim, typename InitialData>
92 struct EvolutionMetavars {
93  static constexpr size_t volume_dim = Dim;
94  using initial_data = InitialData;
95  static_assert(
96  evolution::is_analytic_data_v<initial_data> xor
97  evolution::is_analytic_solution_v<initial_data>,
98  "initial_data must be either an analytic_data or an analytic_solution");
100  using equation_of_state_type = typename initial_data::equation_of_state_type;
102  using system =
105  static constexpr size_t thermodynamic_dim = system::thermodynamic_dim;
107  using temporal_id = Tags::TimeStepId;
108  static constexpr bool local_time_stepping = false;
110  using initial_data_tag =
111  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
115  using boundary_condition_tag = initial_data_tag;
116  using analytic_variables_tags =
117  typename system::primitive_variables_tag::tags_list;
119  using equation_of_state_tag =
122  using normal_dot_numerical_flux =
125  using limiter = Tags::Limiter<Limiters::Minmod<
130  using step_choosers_common =
131  tmpl::list<//StepChoosers::Registrars::Cfl<volume_dim, Frame::Inertial>,
134  using step_choosers_for_step_only =
135  tmpl::list<StepChoosers::Registrars::PreventRapidIncrease>;
136  using step_choosers_for_slab_only = tmpl::list<>;
137  using step_choosers = tmpl::conditional_t<
138  local_time_stepping,
139  tmpl::append<step_choosers_common, step_choosers_for_step_only>,
140  tmpl::list<>>;
141  using slab_choosers = tmpl::conditional_t<
142  local_time_stepping,
143  tmpl::append<step_choosers_common, step_choosers_for_slab_only>,
144  tmpl::append<step_choosers_common, step_choosers_for_step_only,
145  step_choosers_for_slab_only>>;
147  using events = tmpl::list<
148  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
150  Tags::Time, analytic_variables_tags>,
151  tmpl::list<>>,
153  Dim, Tags::Time,
154  tmpl::append<
155  db::get_variables_tags_list<typename system::variables_tag>,
156  db::get_variables_tags_list<
157  typename system::primitive_variables_tag>>,
158  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
159  analytic_variables_tags, tmpl::list<>>>,
161  using triggers = Triggers::time_triggers;
163  struct ObservationType {};
164  using element_observation_type = ObservationType;
166  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
167  typename Event<events>::creatable_classes>;
169  using step_actions = tmpl::flatten<tmpl::list<
173  tmpl::conditional_t<
174  evolution::is_analytic_solution_v<initial_data>,
176  tmpl::list<>>,
178  tmpl::conditional_t<local_time_stepping, tmpl::list<>,
181  tmpl::conditional_t<local_time_stepping,
183  tmpl::list<>>,
188  // Conservative `UpdatePrimitives` expects system to possess
189  // list of recovery schemes so we use `MutateApply` instead.
192  enum class Phase {
194  InitializeTimeStepperHistory,
195  RegisterWithObserver,
196  Evolve,
197  Exit
198  };
200  using initialization_actions = tmpl::list<
207  tmpl::list<hydro::Tags::SoundSpeedSquaredCompute<DataVector>>>,
210  system,
212  typename system::variables_tag,
213  typename system::spacetime_variables_tag,
214  typename system::primitive_variables_tag,
217  typename system::spacetime_variables_tag,
218  typename system::primitive_variables_tag,
219  hydro::Tags::SoundSpeedSquared<DataVector>>>,
221  tmpl::conditional_t<
222  evolution::is_analytic_solution_v<initial_data>,
225  Dim, initial_data_tag, analytic_variables_tags>>>,
226  tmpl::list<>>,
232  using component_list = tmpl::list<
237  tmpl::list<
238  Parallel::PhaseActions<Phase, Phase::Initialization,
239  initialization_actions>,
242  Phase, Phase::InitializeTimeStepperHistory,
246  Phase, Phase::RegisterWithObserver,
249  Tags::Time, element_observation_type>>,
253  Phase, Phase::Evolve,
254  tmpl::list<
257  thermodynamic_dim>>,
258  Actions::UpdateConservatives,
261  tmpl::conditional_t<
262  local_time_stepping,
264  step_actions, Actions::AdvanceTime>>>>>;
266  using const_global_cache_tags =
267  tmpl::list<initial_data_tag,
268  Tags::TimeStepper<tmpl::conditional_t<
269  local_time_stepping, LtsTimeStepper, TimeStepper>>,
272  static constexpr OptionString help{
273  "Evolve the Valencia formulation of RelativisticEuler system.\n\n"};
275  static Phase determine_next_phase(
276  const Phase& current_phase,
277  const Parallel::CProxy_ConstGlobalCache<
278  EvolutionMetavars>& /*cache_proxy*/) noexcept {
279  switch (current_phase) {
280  case Phase::Initialization:
281  return Phase::InitializeTimeStepperHistory;
282  case Phase::InitializeTimeStepperHistory:
283  return Phase::RegisterWithObserver;
284  case Phase::RegisterWithObserver:
285  return Phase::Evolve;
286  case Phase::Evolve:
287  return Phase::Exit;
288  case Phase::Exit:
289  ERROR(
290  "Should never call determine_next_phase with the current phase "
291  "being 'Exit'");
292  default:
293  ERROR(
294  "Unknown type of phase. Did you static_cast<Phase> to an integral "
295  "value?");
296  }
297  }
298 };
300 static const std::vector<void (*)()> charm_init_node_funcs{
301  &setup_error_handling,
302  &domain::creators::register_derived_with_charm,
303  &Parallel::register_derived_classes_with_charm<
305  &Parallel::register_derived_classes_with_charm<
307  &Parallel::register_derived_classes_with_charm<
309  &Parallel::register_derived_classes_with_charm<StepController>,
310  &Parallel::register_derived_classes_with_charm<TimeStepper>,
311  &Parallel::register_derived_classes_with_charm<
314 static const std::vector<void (*)()> charm_init_proc_funcs{
typename detail::self_start_procedure_impl< StepActions >::type self_start_procedure
The list of actions required to self-start an integrator.
Definition: SelfStartActions.hpp:463
The global cache tag for the numerical flux.
Definition: Tags.hpp:85
The densitized momentum density .
Definition: Tags.hpp:42
Functions for serializing factory-created classes.
The parallel component responsible for managing the DG elements that compose the computational domain...
Definition: DgElementArray.hpp:31
Adjust the step size for local time stepping.
Definition: ChangeStepSize.hpp:47
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
Fix the primitive variables to an atmosphere in low density regions.
Definition: FixToAtmosphere.hpp:47
Definition: ConservativeSystem.hpp:41
Perform variable updates for one substep.
Definition: UpdateU.hpp:47
T system(T... args)
Receive limiter data from neighbors, then apply limiter.
Definition: LimiterActions.hpp:68
Contains the events and triggers.
Definition: Tags.hpp:49
Registers itself with the local observer parallel component so the observer knows to expect data from...
Definition: Actions.hpp:232
Allocate and set variables needed for evolution of conservative systems.
Definition: ConservativeSystem.hpp:59
Defines action AdvanceTime.
Initialize mortars between elements for exchanging fluxes.
Definition: InitializeMortars.hpp:79
Apply the function Mutator::apply to the DataBox.
Definition: MutateApply.hpp:40
Defines base class StepController.
Abstract base class for TimeSteppers.
Definition: TimeStepper.hpp:47
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:59
Fix conservative variables using the method proposed in F. Foucart&#39;s PhD thesis (Cornell) ...
Definition: FixConservatives.hpp:53
Defines classes and functions for making classes creatable from input files.
Tag for the current time as a double.
Definition: Tags.hpp:72
Defines actions SendDataForFluxes and ReceiveDataForFluxes.
Adjust variables with a variable fixer.
Definition: Actions.hpp:43
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
The nodegroup parallel component that is responsible for writing data to disk.
Definition: ObserverComponent.hpp:48
Base class for TimeSteppers with local time-stepping support, derived from TimeStepper.
Definition: TimeStepper.hpp:120
Compute the conservative variables from the primitive variables.
Definition: UpdateConservatives.hpp:33
tmpl::list< Registrars::EveryNSlabs, Registrars::PastTime, Registrars::SpecifiedSlabs > time_triggers
Typelist of Time triggers.
Definition: TimeTriggers.hpp:15
Initialize items related to the basic structure of the element.
Definition: InitializeDomain.hpp:63
StepChoosers suggest upper bounds on step sizes. Concrete StepChoosers should define operator() retur...
Definition: StepChooser.hpp:43
Tag for TimeStepId for the algorithm state.
Definition: Tags.hpp:32
Defines tags related to Events and Triggers.
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:29
The densitized rest-mass density .
Definition: Tags.hpp:29
Allocate and set general relativity quantities needed for evolution of some hydro systems...
Definition: GrTagsForHydro.hpp:52
The group parallel component that is responsible for reducing data to be observed.
Definition: ObserverComponent.hpp:27
Compute the volume fluxes of the evolved variables.
Definition: ComputeVolumeFluxes.hpp:40
Definition: EvolveBurgers.hpp:80
Compute the time derivative of the system variables.
Definition: ComputeTimeDerivative.hpp:54
void enable_floating_point_exceptions()
After a call to this function, the code will terminate with a floating point exception on overflow...
Definition: FloatingPointExceptions.cpp:27
The TimeStepper, specifying a (base) type. Can be retrieved through Tags::TimeStepper.
Definition: Tags.hpp:183
tmpl::list< Tags... > slice_tags_to_exterior
Tags that are to be sliced to the exterior side of the faces of the element
Definition: InitializeInterfaces.hpp:37
Definition: RemoveOptionsAndTerminatePhase.hpp:27
A template for defining a registrar.
Definition: Registration.hpp:42
Indicates the Frame that a TensorIndexType is in.
Definition: IndexType.hpp:36
Send local boundary data needed for fluxes to neighbors.
Definition: FluxCommunication.hpp:204
Send local data needed for limiting.
Definition: LimiterActions.hpp:155
Perform the boundary part of the update of the variables for local time stepping. ...
Definition: ApplyBoundaryFluxesLocalTimeStepping.hpp:56
Allocate items for minmod limiter.
Definition: Limiter.hpp:35
Functions to enable/disable termination on floating point exceptions.
Records the variables and their time derivatives in the time stepper history.
Definition: RecordTimeStepperData.hpp:47
decltype(auto) initial_data(const SolutionOrData &solution_or_data, Coordinates &&coordinates, const double time, const tmpl::list< Tags... > tags) noexcept
Extract initial data either from analytic data or from an analytic solution at a specified time...
Definition: InitialData.hpp:17
Run the events and triggers.
Definition: RunEventsAndTriggers.hpp:27
Terminate the algorithm to proceed to the next phase.
Definition: TerminatePhase.hpp:26
Defines action UpdateU.
Wraps the template metaprogramming library used (brigand)
Advance time one substep.
Definition: AdvanceTime.hpp:47
Base class for something that can happen during a simulation (such as an observation).
Definition: Event.hpp:30
Packages data on external boundaries for calculating numerical flux. Computes contributions on the in...
Definition: ImposeBoundaryConditions.hpp:77
Defines actions ApplyLimiter and SendDataForLimiter.
List of all the actions to be executed in the specified phase.
Definition: PhaseDependentActionList.hpp:16
Use the AnalyticSolutionTag to compute the analytic solution of the tags in AnalyticFieldsTagList.
Definition: ComputeTags.hpp:21
Passed to RegisterWithObservers action to register observer event.
Definition: RegisterObservers.hpp:15
Defines tags related to domain quantities.
The analytic solution, with the type of the analytic solution set as the template parameter...
Definition: Tags.hpp:50
Initialize the list of compute tags in ComputeTagsList
Definition: AddComputeTags.hpp:38
Compute the volume sources of the evolved variables.
Definition: ComputeVolumeSources.hpp:35
The sound speed squared .
Definition: Tags.hpp:145
tmpl::list< Tags... > slice_tags_to_face
Tags that are to be sliced to the faces of the element
Definition: InitializeInterfaces.hpp:32
The analytic data, with the type of the analytic data set as the template parameter.
Definition: Tags.hpp:40
Compute element boundary contributions to the temporal step of the variables.
Definition: ApplyFluxes.hpp:67
Definition: ObserveFields.hpp:61
Initialize items related to the discontinuous Galerkin method.
Definition: DiscontinuousGalerkin.hpp:65
Initialize items related to time-evolution of the system.
Definition: Evolution.hpp:80
Base class for checking whether to run an Event.
Definition: Trigger.hpp:34
The densitized energy density .
Definition: Tags.hpp:35
The global cache tag for the limiter.
Definition: Tags.hpp:37
Initialize items related to the interfaces between Elements and on external boundaries.
Definition: InitializeInterfaces.hpp:140
Defines tags related to Time quantities.
Definition: System.hpp:35
The equation of state.
Definition: Tags.hpp:61
Adjust the slab size based on previous executions of Events::ChangeSlabSize.
Definition: ChangeSlabSize.hpp:103