1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
4 #pragma once
6 #include <vector>
8 #include "Domain/Creators/RegisterDerivedWithCharm.hpp"
9 #include "Domain/Tags.hpp"
11 #include "Evolution/Actions/ComputeTimeDerivative.hpp" // IWYU pragma: keep
12 #include "Evolution/Actions/ComputeVolumeFluxes.hpp"
13 #include "Evolution/Actions/ComputeVolumeSources.hpp"
14 #include "Evolution/ComputeTags.hpp"
15 #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
17 #include "Evolution/DiscontinuousGalerkin/Limiters/Minmod.tpp"
18 #include "Evolution/DiscontinuousGalerkin/Limiters/Tags.hpp"
19 #include "Evolution/Initialization/ConservativeSystem.hpp"
20 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
21 #include "Evolution/Initialization/Evolution.hpp"
22 #include "Evolution/Initialization/GrTagsForHydro.hpp"
23 #include "Evolution/Initialization/Limiter.hpp"
24 #include "Evolution/Systems/RadiationTransport/M1Grey/Initialize.hpp"
25 #include "Evolution/Systems/RadiationTransport/M1Grey/System.hpp"
26 #include "Evolution/Systems/RadiationTransport/M1Grey/Tags.hpp"
27 #include "Evolution/Systems/RadiationTransport/M1Grey/UpdateM1Closure.hpp"
28 #include "Evolution/Systems/RadiationTransport/Tags.hpp"
29 #include "Evolution/TypeTraits.hpp"
30 #include "IO/Observer/Actions.hpp"
31 #include "IO/Observer/Helpers.hpp"
32 #include "IO/Observer/ObserverComponent.hpp"
33 #include "IO/Observer/RegisterObservers.hpp"
34 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyBoundaryFluxesLocalTimeStepping.hpp"
35 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyFluxes.hpp"
37 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp" // IWYU pragma: keep
38 #include "NumericalAlgorithms/DiscontinuousGalerkin/NumericalFluxes/LocalLaxFriedrichs.hpp"
39 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
40 #include "Options/Options.hpp"
41 #include "Parallel/Actions/TerminatePhase.hpp"
42 #include "Parallel/InitializationFunctions.hpp"
43 #include "Parallel/PhaseDependentActionList.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" // IWYU pragma: keep
51 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
52 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp" // IWYU pragma: keep
54 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
55 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
56 #include "PointwiseFunctions/AnalyticData/Tags.hpp"
57 #include "PointwiseFunctions/AnalyticSolutions/RadiationTransport/M1Grey/ConstantM1.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" // IWYU pragma: keep
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"
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
86 struct EvolutionMetavars {
87  static constexpr size_t volume_dim = 3;
88  // To switch which initial data is evolved you only need to change the
89  // line `using initial_data = ...;` and include the header file for the
90  // solution.
92  static_assert(
93  evolution::is_analytic_data_v<initial_data> xor
94  evolution::is_analytic_solution_v<initial_data>,
95  "initial_data must be either an analytic_data or an analytic_solution");
97  // Set list of neutrino species to be used by M1 code
98  using neutrino_species = tmpl::list<neutrinos::ElectronNeutrinos<1>>;
101  using temporal_id = Tags::TimeStepId;
102  static constexpr bool local_time_stepping = false;
103  using initial_data_tag =
104  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
107  using boundary_condition_tag = initial_data_tag;
108  using analytic_variables_tags = typename system::variables_tag::tags_list;
109  using normal_dot_numerical_flux =
111  using limiter = Tags::Limiter<
112  Limiters::Minmod<3, typename system::variables_tag::tags_list>>;
114  // public for use by the Charm++ registration code
115  using events = tmpl::flatten<tmpl::list<
116  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
118  Tags::Time, analytic_variables_tags>,
119  tmpl::list<>>,
121  3, Tags::Time,
122  tmpl::append<
123  db::get_variables_tags_list<typename system::variables_tag>,
124  db::get_variables_tags_list<
125  typename system::primitive_variables_tag>>,
126  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
127  analytic_variables_tags, tmpl::list<>>>>>;
128  using triggers = Triggers::time_triggers;
130  using step_choosers =
131  tmpl::list<StepChoosers::Registrars::Cfl<3, Frame::Inertial>,
135  struct ObservationType {};
136  using element_observation_type = ObservationType;
138  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
139  typename Event<events>::creatable_classes>;
141  using step_actions = tmpl::flatten<tmpl::list<
145  tmpl::conditional_t<
146  evolution::is_analytic_solution_v<initial_data>,
148  tmpl::list<>>,
150  tmpl::conditional_t<local_time_stepping, tmpl::list<>,
153  tmpl::conditional_t<local_time_stepping,
155  tmpl::list<>>,
159  enum class Phase {
161  InitializeTimeStepperHistory,
162  RegisterWithObserver,
163  Evolve,
164  Exit
165  };
167  using initialization_actions = tmpl::list<
171  Actions::UpdateM1Closure,
173  system,
175  typename system::variables_tag,
176  typename system::spacetime_variables_tag,
177  typename system::primitive_variables_tag>,
179  typename system::spacetime_variables_tag,
180  typename system::primitive_variables_tag>>,
182  tmpl::conditional_t<
183  evolution::is_analytic_solution_v<initial_data>,
186  3, initial_data_tag, analytic_variables_tags>>>,
187  tmpl::list<>>,
193  using component_list = tmpl::list<
198  tmpl::list<
199  Parallel::PhaseActions<Phase, Phase::Initialization,
200  initialization_actions>,
203  Phase, Phase::InitializeTimeStepperHistory,
207  Phase, Phase::RegisterWithObserver,
210  Tags::Time, element_observation_type>>,
214  Phase, Phase::Evolve,
215  tmpl::flatten<tmpl::list<
217  tmpl::conditional_t<
218  local_time_stepping,
220  step_actions, Actions::AdvanceTime>>>>>>;
222  using const_global_cache_tags =
223  tmpl::list<initial_data_tag,
224  Tags::TimeStepper<tmpl::conditional_t<
225  local_time_stepping, LtsTimeStepper, TimeStepper>>,
228  static constexpr OptionString help{
229  "Evolve the M1 system (without coupling to hydro).\n\n"};
231  static Phase determine_next_phase(
232  const Phase& current_phase,
233  const Parallel::CProxy_ConstGlobalCache<
234  EvolutionMetavars>& /*cache_proxy*/) noexcept {
235  switch (current_phase) {
236  case Phase::Initialization:
237  return Phase::InitializeTimeStepperHistory;
238  case Phase::InitializeTimeStepperHistory:
239  return Phase::RegisterWithObserver;
240  case Phase::RegisterWithObserver:
241  return Phase::Evolve;
242  case Phase::Evolve:
243  return Phase::Exit;
244  case Phase::Exit:
245  ERROR(
246  "Should never call determine_next_phase with the current phase "
247  "being 'Exit'");
248  default:
249  ERROR(
250  "Unknown type of phase. Did you static_cast<Phase> an integral "
251  "value?");
252  }
253  }
254 };
256 static const std::vector<void (*)()> charm_init_node_funcs{
257  &setup_error_handling,
258  &domain::creators::register_derived_with_charm,
259  &Parallel::register_derived_classes_with_charm<
261  &Parallel::register_derived_classes_with_charm<
263  &Parallel::register_derived_classes_with_charm<StepController>,
264  &Parallel::register_derived_classes_with_charm<TimeStepper>,
265  &Parallel::register_derived_classes_with_charm<
268 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 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: 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
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 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
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
Constant solution to M1 equations in Minkowski spacetime.
Definition: ConstantM1.hpp:40
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
Compute the M1 closure and derived neutrino moments.
Definition: UpdateM1Closure.hpp:38
Defines tags related to Events and Triggers.
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:29
Allocate and set general relativity quantities needed for evolution of some hydro systems...
Definition: GrTagsForHydro.hpp:44
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
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
Defines action UpdateU.
Definition: System.hpp:35
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
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.