EvolveNewtonianEuler.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <vector>
8 
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/Limiter.hpp"
25 #include "Evolution/Systems/NewtonianEuler/SoundSpeedSquared.hpp"
26 #include "Evolution/Systems/NewtonianEuler/Sources/NoSource.hpp"
27 #include "Evolution/Systems/NewtonianEuler/System.hpp"
28 #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
29 #include "IO/Observer/Actions.hpp"
30 #include "IO/Observer/Helpers.hpp"
31 #include "IO/Observer/ObserverComponent.hpp"
32 #include "IO/Observer/RegisterObservers.hpp"
33 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyBoundaryFluxesLocalTimeStepping.hpp"
34 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyFluxes.hpp"
36 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp"
37 #include "NumericalAlgorithms/DiscontinuousGalerkin/NumericalFluxes/Hll.hpp"
38 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
39 #include "Options/Options.hpp"
40 #include "Parallel/Actions/TerminatePhase.hpp"
41 #include "Parallel/InitializationFunctions.hpp"
42 #include "Parallel/PhaseDependentActionList.hpp"
44 #include "ParallelAlgorithms/Actions/MutateApply.hpp"
45 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeDomain.hpp"
46 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeInterfaces.hpp"
47 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeMortars.hpp"
48 #include "ParallelAlgorithms/Events/ObserveErrorNorms.hpp"
49 #include "ParallelAlgorithms/Events/ObserveFields.hpp"
50 #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp"
51 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
52 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
54 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
55 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
56 #include "PointwiseFunctions/AnalyticSolutions/NewtonianEuler/IsentropicVortex.hpp"
57 #include "PointwiseFunctions/AnalyticSolutions/NewtonianEuler/RiemannProblem.hpp"
58 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
59 #include "PointwiseFunctions/Hydro/Tags.hpp"
61 #include "Time/Actions/ChangeStepSize.hpp"
62 #include "Time/Actions/RecordTimeStepperData.hpp"
63 #include "Time/Actions/SelfStartActions.hpp"
64 #include "Time/Actions/UpdateU.hpp"
65 #include "Time/StepChoosers/Cfl.hpp"
66 #include "Time/StepChoosers/Constant.hpp"
67 #include "Time/StepChoosers/Increase.hpp"
68 #include "Time/StepChoosers/StepChooser.hpp"
70 #include "Time/Tags.hpp"
71 #include "Time/TimeSteppers/TimeStepper.hpp"
72 #include "Time/Triggers/TimeTriggers.hpp"
73 #include "Utilities/Functional.hpp"
74 #include "Utilities/TMPL.hpp"
75 
76 /// \cond
77 namespace Frame {
78 struct Inertial;
79 } // namespace Frame
80 namespace Parallel {
81 template <typename Metavariables>
82 class CProxy_ConstGlobalCache;
83 } // namespace Parallel
84 /// \endcond
85 
86 template <size_t Dim, typename InitialData>
87 struct EvolutionMetavars {
88  static constexpr size_t volume_dim = Dim;
89  using initial_data = InitialData;
90  static_assert(
91  evolution::is_analytic_data_v<initial_data> xor
92  evolution::is_analytic_solution_v<initial_data>,
93  "initial_data must be either an analytic_data or an analytic_solution");
94 
95  using equation_of_state_type = typename initial_data::equation_of_state_type;
96 
97  using source_term_type = typename initial_data::source_term_type;
98 
99  using system =
101 
102  using temporal_id = Tags::TimeStepId;
103  static constexpr bool local_time_stepping = false;
104 
105  using initial_data_tag =
106  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
109 
110  using boundary_condition_tag = initial_data_tag;
111  using analytic_variables_tags =
112  typename system::primitive_variables_tag::tags_list;
113 
114  using equation_of_state_tag =
116 
117  using source_term_tag = NewtonianEuler::Tags::SourceTerm<initial_data>;
118  static constexpr bool has_source_terms =
119  not cpp17::is_same_v<source_term_type, NewtonianEuler::Sources::NoSource>;
120 
121  using normal_dot_numerical_flux =
123 
124  using limiter = Tags::Limiter<Limiters::Minmod<
125  Dim, tmpl::list<NewtonianEuler::Tags::MassDensityCons<DataVector>,
129 
130  using events = tmpl::flatten<tmpl::list<
131  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
133  Tags::Time, analytic_variables_tags>,
134  tmpl::list<>>,
136  Dim, Tags::Time,
137  tmpl::append<
138  db::get_variables_tags_list<typename system::variables_tag>,
139  db::get_variables_tags_list<
140  typename system::primitive_variables_tag>>,
141  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
142  analytic_variables_tags, tmpl::list<>>>>>;
143  using triggers = Triggers::time_triggers;
144 
145  using step_choosers =
146  tmpl::list<StepChoosers::Registrars::Cfl<Dim, Frame::Inertial>,
149 
150  struct ObservationType {};
151  using element_observation_type = ObservationType;
152 
153  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
154  typename Event<events>::creatable_classes>;
155 
156  using step_actions = tmpl::flatten<tmpl::list<
159  tmpl::conditional_t<has_source_terms, Actions::ComputeVolumeSources,
160  tmpl::list<>>,
162  tmpl::conditional_t<
163  evolution::is_analytic_solution_v<initial_data>,
165  tmpl::list<>>,
167  tmpl::conditional_t<local_time_stepping, tmpl::list<>,
170  tmpl::conditional_t<local_time_stepping,
172  tmpl::list<>>,
175  // Conservative `UpdatePrimitives` expects system to possess
176  // list of recovery schemes so we use `MutateApply` instead.
178 
179  enum class Phase {
181  InitializeTimeStepperHistory,
182  RegisterWithObserver,
183  Evolve,
184  Exit
185  };
186 
187  using initialization_actions = tmpl::list<
191  tmpl::list<NewtonianEuler::Tags::SoundSpeedSquaredCompute<DataVector>,
195  system,
197  typename system::variables_tag,
198  typename system::primitive_variables_tag,
201  typename system::primitive_variables_tag,
202  NewtonianEuler::Tags::SoundSpeed<DataVector>>>,
204  tmpl::conditional_t<
205  evolution::is_analytic_solution_v<initial_data>,
208  Dim, initial_data_tag, analytic_variables_tags>>>,
209  tmpl::list<>>,
214 
215  using component_list = tmpl::list<
220  tmpl::list<
221  Parallel::PhaseActions<Phase, Phase::Initialization,
222  initialization_actions>,
223 
225  Phase, Phase::InitializeTimeStepperHistory,
226  tmpl::flatten<tmpl::list<
228 
230  Phase, Phase::RegisterWithObserver,
233  Tags::Time, element_observation_type>>,
235 
237  Phase, Phase::Evolve,
238  tmpl::flatten<tmpl::list<
239  Actions::UpdateConservatives,
241  tmpl::conditional_t<
242  local_time_stepping,
244  step_actions, Actions::AdvanceTime>>>>>>;
245 
246  using const_global_cache_tags = tmpl::list<
247  initial_data_tag,
248  tmpl::conditional_t<has_source_terms, source_term_tag, tmpl::list<>>,
249  Tags::TimeStepper<tmpl::conditional_t<local_time_stepping, LtsTimeStepper,
250  TimeStepper>>,
252 
253  static constexpr OptionString help{
254  "Evolve the Newtonian Euler system in conservative form.\n\n"};
255 
256  static Phase determine_next_phase(
257  const Phase& current_phase,
258  const Parallel::CProxy_ConstGlobalCache<
259  EvolutionMetavars>& /*cache_proxy*/) noexcept {
260  switch (current_phase) {
261  case Phase::Initialization:
262  return Phase::InitializeTimeStepperHistory;
263  case Phase::InitializeTimeStepperHistory:
264  return Phase::RegisterWithObserver;
265  case Phase::RegisterWithObserver:
266  return Phase::Evolve;
267  case Phase::Evolve:
268  return Phase::Exit;
269  case Phase::Exit:
270  ERROR(
271  "Should never call determine_next_phase with the current phase "
272  "being 'Exit'");
273  default:
274  ERROR(
275  "Unknown type of phase. Did you static_cast<Phase> to an integral "
276  "value?");
277  }
278  }
279 };
280 
281 static const std::vector<void (*)()> charm_init_node_funcs{
282  &setup_error_handling,
283  &domain::creators::register_derived_with_charm,
284  &Parallel::register_derived_classes_with_charm<
286  &Parallel::register_derived_classes_with_charm<
288  &Parallel::register_derived_classes_with_charm<StepController>,
289  &Parallel::register_derived_classes_with_charm<TimeStepper>,
290  &Parallel::register_derived_classes_with_charm<
292 
293 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
Functions for serializing factory-created classes.
The momentum density of the fluid.
Definition: Tags.hpp:43
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:45
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
Definition: System.hpp:32
Definition: ConservativeSystem.hpp:34
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:52
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:44
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:59
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.
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
The source term in the evolution equations.
Definition: Tags.hpp:99
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:106
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
The sound speed.
Definition: Tags.hpp:82
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:45
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 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:78
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
The energy density of the fluid.
Definition: Tags.hpp:52
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:49
Run the events and triggers.
Definition: RunEventsAndTriggers.hpp:27
Terminate the algorithm to proceed to the next phase.
Definition: TerminatePhase.hpp:26
Stores a collection of function values.
Definition: DataVector.hpp:42
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:49
Initialize the list of compute tags in ComputeTagsList
Definition: AddComputeTags.hpp:38
Definition: IndexType.hpp:44
Compute the volume sources of the evolved variables.
Definition: ComputeVolumeSources.hpp:35
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:38
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 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.
The equation of state.
Definition: Tags.hpp:61
Compute item for the sound speed .
Definition: SoundSpeedSquared.hpp:56