1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
4 #pragma once
6 #include <cstddef>
7 #include <vector>
9 #include "DataStructures/DataBox/PrefixHelpers.hpp"
10 #include "Domain/Creators/RegisterDerivedWithCharm.hpp"
11 #include "Domain/Creators/TimeDependence/RegisterDerivedWithCharm.hpp"
12 #include "Domain/FunctionsOfTime/RegisterDerivedWithCharm.hpp"
13 #include "Domain/Tags.hpp"
15 #include "Evolution/Actions/AddMeshVelocitySourceTerms.hpp"
16 #include "Evolution/Actions/ComputeTimeDerivative.hpp"
17 #include "Evolution/Actions/ComputeVolumeFluxes.hpp"
18 #include "Evolution/Actions/ComputeVolumeSources.hpp"
19 #include "Evolution/ComputeTags.hpp"
20 #include "Evolution/Conservative/ConservativeDuDt.hpp"
21 #include "Evolution/Conservative/UpdateConservatives.hpp"
22 #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
24 #include "Evolution/DiscontinuousGalerkin/Limiters/Minmod.tpp"
25 #include "Evolution/DiscontinuousGalerkin/Limiters/Tags.hpp"
26 #include "Evolution/Initialization/ConservativeSystem.hpp"
27 #include "Evolution/Initialization/DgDomain.hpp"
28 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
29 #include "Evolution/Initialization/Evolution.hpp"
30 #include "Evolution/Initialization/GrTagsForHydro.hpp"
31 #include "Evolution/Initialization/Limiter.hpp"
32 #include "Evolution/Systems/RelativisticEuler/Valencia/FixConservatives.hpp"
33 #include "Evolution/Systems/RelativisticEuler/Valencia/System.hpp"
34 #include "Evolution/Systems/RelativisticEuler/Valencia/Tags.hpp"
35 #include "Evolution/VariableFixing/Actions.hpp"
36 #include "Evolution/VariableFixing/FixToAtmosphere.hpp"
37 #include "Evolution/VariableFixing/Tags.hpp"
38 #include "IO/Observer/Actions.hpp"
39 #include "IO/Observer/Helpers.hpp"
40 #include "IO/Observer/ObserverComponent.hpp"
41 #include "IO/Observer/RegisterObservers.hpp"
42 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyBoundaryFluxesLocalTimeStepping.hpp"
43 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyFluxes.hpp"
45 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp"
46 #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
47 #include "NumericalAlgorithms/DiscontinuousGalerkin/NumericalFluxes/LocalLaxFriedrichs.hpp"
48 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
49 #include "Options/Options.hpp"
50 #include "Parallel/Actions/TerminatePhase.hpp"
51 #include "Parallel/InitializationFunctions.hpp"
52 #include "Parallel/PhaseDependentActionList.hpp"
54 #include "ParallelAlgorithms/Actions/MutateApply.hpp"
55 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeDomain.hpp"
56 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeInterfaces.hpp"
57 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeMortars.hpp"
58 #include "ParallelAlgorithms/Events/ObserveErrorNorms.hpp"
59 #include "ParallelAlgorithms/Events/ObserveFields.hpp"
60 #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp"
61 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
62 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
64 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
65 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
66 #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/SmoothFlow.hpp"
67 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
68 #include "PointwiseFunctions/Hydro/SoundSpeedSquared.hpp"
69 #include "PointwiseFunctions/Hydro/Tags.hpp"
71 #include "Time/Actions/ChangeSlabSize.hpp"
72 #include "Time/Actions/ChangeStepSize.hpp"
73 #include "Time/Actions/RecordTimeStepperData.hpp"
74 #include "Time/Actions/SelfStartActions.hpp"
75 #include "Time/Actions/UpdateU.hpp"
76 #include "Time/StepChoosers/Cfl.hpp"
77 #include "Time/StepChoosers/Constant.hpp"
78 #include "Time/StepChoosers/Increase.hpp"
79 #include "Time/StepChoosers/PreventRapidIncrease.hpp"
80 #include "Time/StepChoosers/StepChooser.hpp"
81 #include "Time/StepChoosers/StepToTimes.hpp"
83 #include "Time/Tags.hpp"
84 #include "Time/TimeSteppers/TimeStepper.hpp"
85 #include "Time/Triggers/TimeTriggers.hpp"
86 #include "Utilities/Functional.hpp"
87 #include "Utilities/TMPL.hpp"
89 /// \cond
90 namespace Frame {
91 struct Inertial;
92 } // namespace Frame
93 namespace Parallel {
94 template <typename Metavariables>
95 class CProxy_ConstGlobalCache;
96 } // namespace Parallel
97 /// \endcond
99 template <size_t Dim, typename InitialData>
100 struct EvolutionMetavars {
101  static constexpr size_t volume_dim = Dim;
102  static constexpr dg::Formulation dg_formulation =
103  dg::Formulation::StrongInertial;
105  using initial_data = InitialData;
106  static_assert(
107  evolution::is_analytic_data_v<initial_data> xor
108  evolution::is_analytic_solution_v<initial_data>,
109  "initial_data must be either an analytic_data or an analytic_solution");
111  using equation_of_state_type = typename initial_data::equation_of_state_type;
113  using system =
116  static constexpr size_t thermodynamic_dim = system::thermodynamic_dim;
118  using temporal_id = Tags::TimeStepId;
119  static constexpr bool local_time_stepping = false;
121  using initial_data_tag =
122  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
126  using boundary_condition_tag = initial_data_tag;
127  using analytic_variables_tags =
128  typename system::primitive_variables_tag::tags_list;
130  using equation_of_state_tag =
133  using normal_dot_numerical_flux =
136  using limiter = Tags::Limiter<Limiters::Minmod<
141  using step_choosers_common =
142  tmpl::list<//StepChoosers::Registrars::Cfl<volume_dim, Frame::Inertial>,
145  using step_choosers_for_step_only =
146  tmpl::list<StepChoosers::Registrars::PreventRapidIncrease>;
147  using step_choosers_for_slab_only =
148  tmpl::list<StepChoosers::Registrars::StepToTimes>;
149  using step_choosers = tmpl::conditional_t<
150  local_time_stepping,
151  tmpl::append<step_choosers_common, step_choosers_for_step_only>,
152  tmpl::list<>>;
153  using slab_choosers = tmpl::conditional_t<
154  local_time_stepping,
155  tmpl::append<step_choosers_common, step_choosers_for_slab_only>,
156  tmpl::append<step_choosers_common, step_choosers_for_step_only,
157  step_choosers_for_slab_only>>;
159  using events = tmpl::list<
160  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
162  Tags::Time, analytic_variables_tags>,
163  tmpl::list<>>,
165  Dim, Tags::Time,
166  tmpl::append<
167  db::get_variables_tags_list<typename system::variables_tag>,
168  db::get_variables_tags_list<
169  typename system::primitive_variables_tag>>,
170  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
171  analytic_variables_tags, tmpl::list<>>>,
173  using triggers = Triggers::time_triggers;
175  struct ObservationType {};
176  using element_observation_type = ObservationType;
178  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
179  typename Event<events>::creatable_classes>;
181  using step_actions = tmpl::flatten<tmpl::list<
188  tmpl::conditional_t<
189  evolution::is_analytic_solution_v<initial_data>,
191  tmpl::list<>>,
193  tmpl::conditional_t<local_time_stepping, tmpl::list<>,
196  tmpl::conditional_t<local_time_stepping,
198  tmpl::list<>>,
203  // Conservative `UpdatePrimitives` expects system to possess
204  // list of recovery schemes so we use `MutateApply` instead.
207  enum class Phase {
209  InitializeTimeStepperHistory,
210  RegisterWithObserver,
211  Evolve,
212  Exit
213  };
215  using initialization_actions = tmpl::list<
224  tmpl::list<hydro::Tags::SoundSpeedSquaredCompute<DataVector>>>,
227  system,
229  typename system::variables_tag,
230  typename system::spacetime_variables_tag,
231  typename system::primitive_variables_tag,
234  typename system::spacetime_variables_tag,
235  typename system::primitive_variables_tag,
236  hydro::Tags::SoundSpeedSquared<DataVector>>,
239  tmpl::conditional_t<
240  evolution::is_analytic_solution_v<initial_data>,
243  Dim, initial_data_tag, analytic_variables_tags>>>,
244  tmpl::list<>>,
250  using component_list = tmpl::list<
255  tmpl::list<
256  Parallel::PhaseActions<Phase, Phase::Initialization,
257  initialization_actions>,
260  Phase, Phase::InitializeTimeStepperHistory,
264  Phase, Phase::RegisterWithObserver,
267  Tags::Time, element_observation_type>>,
271  Phase, Phase::Evolve,
272  tmpl::list<
275  thermodynamic_dim>>,
276  Actions::UpdateConservatives,
279  tmpl::conditional_t<
280  local_time_stepping,
282  step_actions, Actions::AdvanceTime>>>>>;
284  using const_global_cache_tags =
285  tmpl::list<initial_data_tag,
286  Tags::TimeStepper<tmpl::conditional_t<
287  local_time_stepping, LtsTimeStepper, TimeStepper>>,
290  static constexpr OptionString help{
291  "Evolve the Valencia formulation of RelativisticEuler system.\n\n"};
293  static Phase determine_next_phase(
294  const Phase& current_phase,
295  const Parallel::CProxy_ConstGlobalCache<
296  EvolutionMetavars>& /*cache_proxy*/) noexcept {
297  switch (current_phase) {
298  case Phase::Initialization:
299  return Phase::InitializeTimeStepperHistory;
300  case Phase::InitializeTimeStepperHistory:
301  return Phase::RegisterWithObserver;
302  case Phase::RegisterWithObserver:
303  return Phase::Evolve;
304  case Phase::Evolve:
305  return Phase::Exit;
306  case Phase::Exit:
307  ERROR(
308  "Should never call determine_next_phase with the current phase "
309  "being 'Exit'");
310  default:
311  ERROR(
312  "Unknown type of phase. Did you static_cast<Phase> to an integral "
313  "value?");
314  }
315  }
316 };
318 static const std::vector<void (*)()> charm_init_node_funcs{
319  &setup_error_handling,
320  &domain::creators::register_derived_with_charm,
321  &domain::creators::time_dependence::register_derived_with_charm,
322  &domain::FunctionsOfTime::register_derived_with_charm,
329  &Parallel::register_derived_classes_with_charm<StepController>,
330  &Parallel::register_derived_classes_with_charm<TimeStepper>,
334 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:476
The global cache tag for the numerical flux.
Definition: Tags.hpp:88
The densitized momentum density .
Definition: Tags.hpp:39
Functions for serializing factory-created classes.
The parallel component responsible for managing the DG elements that compose the computational domain...
Definition: DgElementArray.hpp:33
Adjust the step size for local time stepping.
Definition: ChangeStepSize.hpp:48
#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:50
Perform variable updates for one substep.
Definition: UpdateU.hpp:50
T system(T... args)
Receive limiter data from neighbors, then apply limiter.
Definition: LimiterActions.hpp:70
Contains the events and triggers.
Definition: Tags.hpp:57
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:68
Defines action AdvanceTime.
Initialize mortars between elements for exchanging fluxes.
Definition: InitializeMortars.hpp:79
tmpl::list< Tags... > exterior_compute_tags
Compute tags on the exterior side of the faces of the element.
Definition: InitializeInterfaces.hpp:47
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
Initialize time-stepper items.
Definition: Evolution.hpp:186
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:60
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
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:34
Defines tags related to Events and Triggers.
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:30
The densitized rest-mass density .
Definition: Tags.hpp:28
Allocate and set general relativity quantities needed for evolution of some hydro systems...
Definition: GrTagsForHydro.hpp:60
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:57
Compute and add the source term modification for moving meshes.
Definition: AddMeshVelocitySourceTerms.hpp:55
void register_derived_classes_with_charm() noexcept
Register derived classes of the Base class.
Definition: RegisterDerivedClassesWithCharm.hpp:31
The DG formulation to use.
Definition: Formulation.hpp:26
Definition: EvolveBurgers.hpp:88
Compute the time derivative of the system variables.
Definition: ComputeTimeDerivative.hpp:55
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
Tag for a TimeStepper of type StepperType.
Definition: Tags.hpp:179
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:206
Send local data needed for limiting.
Definition: LimiterActions.hpp:157
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:50
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:50
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
Calculate for a conservative system.
Definition: ConservativeDuDt.hpp:34
Initialize items related to time, such as the time step.
Definition: Evolution.hpp:76
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:24
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:51
Initialize items related to the basic structure of the element.
Definition: DgDomain.hpp:79
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:131
tmpl::list< Registrars::EveryNSlabs, Registrars::NearTimes, Registrars::PastTime, Registrars::SpecifiedSlabs, Registrars::SpecifiedTimes > time_triggers
Typelist of Time triggers.
Definition: TimeTriggers.hpp:19
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:41
Compute element boundary contributions to the temporal step of the variables.
Definition: ApplyFluxes.hpp:70
tmpl::list< Tags... > face_compute_tags
Compute tags on the faces of the element.
Definition: InitializeInterfaces.hpp:42
Definition: ObserveFields.hpp:63
Initialize items related to the discontinuous Galerkin method.
Definition: DiscontinuousGalerkin.hpp:67
Base class for checking whether to run an Event.
Definition: Trigger.hpp:34
The densitized energy density .
Definition: Tags.hpp:33
The global cache tag for the limiter.
Definition: Tags.hpp:40
Initialize items related to the interfaces between Elements and on external boundaries.
Definition: InitializeInterfaces.hpp:141
Definition: System.hpp:29
The equation of state.
Definition: Tags.hpp:57
Adjust the slab size based on previous executions of Events::ChangeSlabSize.
Definition: ChangeSlabSize.hpp:107