EvolveGeneralizedHarmonic.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"
11 #include "ErrorHandling/Error.hpp"
13 #include "Evolution/Actions/ComputeTimeDerivative.hpp"
14 #include "Evolution/ComputeTags.hpp"
15 #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
16 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
17 #include "Evolution/Initialization/Evolution.hpp"
18 #include "Evolution/Initialization/NonconservativeSystem.hpp"
20 #include "Evolution/Systems/GeneralizedHarmonic/Initialize.hpp"
21 #include "Evolution/Systems/GeneralizedHarmonic/System.hpp"
22 #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
23 #include "IO/Observer/Actions.hpp"
24 #include "IO/Observer/Helpers.hpp"
25 #include "IO/Observer/ObserverComponent.hpp"
26 #include "IO/Observer/RegisterObservers.hpp"
27 #include "IO/Observer/Tags.hpp"
28 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyBoundaryFluxesLocalTimeStepping.hpp"
29 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyFluxes.hpp"
30 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ComputeNonconservativeBoundaryFluxes.hpp"
32 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp"
33 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
34 #include "Options/Options.hpp"
35 #include "Parallel/Actions/TerminatePhase.hpp"
36 #include "Parallel/InitializationFunctions.hpp"
37 #include "Parallel/PhaseDependentActionList.hpp"
38 #include "Parallel/Reduction.hpp"
40 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeDomain.hpp"
41 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeInterfaces.hpp"
42 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeMortars.hpp"
43 #include "ParallelAlgorithms/Events/ObserveErrorNorms.hpp"
44 #include "ParallelAlgorithms/Events/ObserveFields.hpp"
45 #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp"
46 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
47 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
49 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
50 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
51 #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/KerrSchild.hpp"
52 #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/WrappedGr.hpp"
53 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
57 #include "PointwiseFunctions/GeneralRelativity/IndexManipulation.hpp"
59 #include "PointwiseFunctions/GeneralRelativity/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 // IWYU pragma: no_forward_declare MathFunction
79 struct Inertial;
80 } // namespace Frame
81 namespace Parallel {
82 template <typename Metavariables>
83 class CProxy_ConstGlobalCache;
84 } // namespace Parallel
85 /// \endcond
86 
87 struct EvolutionMetavars {
88  static constexpr int volume_dim = 3;
89  using frame = Frame::Inertial;
91  using temporal_id = Tags::TimeStepId;
92  static constexpr bool local_time_stepping = false;
93  using initial_data_tag = Tags::AnalyticSolution<
95  using boundary_condition_tag = initial_data_tag;
96  using normal_dot_numerical_flux =
98  using analytic_solution_fields =
99  db::get_variables_tags_list<typename system::variables_tag>;
100  using observe_fields = tmpl::append<
101  analytic_solution_fields,
102  tmpl::list<
105  ::Tags::PointwiseL2Norm<GeneralizedHarmonic::Tags::
106  ThreeIndexConstraint<volume_dim, frame>>,
107  ::Tags::PointwiseL2Norm<GeneralizedHarmonic::Tags::
108  FourIndexConstraint<volume_dim, frame>>>>;
109  using events = tmpl::list<
111  analytic_solution_fields>,
113  volume_dim, Tags::Time, observe_fields, analytic_solution_fields>>;
114  using triggers = Triggers::time_triggers;
115 
116  // A tmpl::list of tags to be added to the ConstGlobalCache by the
117  // metavariables
118  using const_global_cache_tags = tmpl::list<
119  initial_data_tag, Tags::TimeStepper<TimeStepper>,
124 
125  using step_choosers =
126  tmpl::list<StepChoosers::Registrars::Cfl<volume_dim, frame>,
129 
130  struct ObservationType {};
131  using element_observation_type = ObservationType;
132 
133  using observed_reduction_data_tags =
134  observers::collect_reduction_data_tags<Event<events>::creatable_classes>;
135 
136  using step_actions = tmpl::flatten<tmpl::list<
147 
148  enum class Phase {
150  InitializeTimeStepperHistory,
151  RegisterWithObserver,
152  Evolve,
153  Exit
154  };
155 
156  using initialization_actions = tmpl::list<
161  system,
163  typename system::variables_tag,
166  DataVector>,
170  gr::Tags::SpatialMetric<volume_dim, frame, DataVector>,
172  DataVector>,
173  gr::Tags::Shift<volume_dim, frame, DataVector>,
174  gr::Tags::Lapse<DataVector>>,
178  frame>,
180  frame>,
182  frame>,
184  frame>,
186  frame>>,
189  frame>,
191  frame>,
193  frame>,
195  frame>,
197  frame>>>,
201  volume_dim, initial_data_tag, analytic_solution_fields>>>,
207 
208  using component_list = tmpl::list<
213  tmpl::list<
214  Parallel::PhaseActions<Phase, Phase::Initialization,
215  initialization_actions>,
217  Phase, Phase::InitializeTimeStepperHistory,
218  tmpl::flatten<tmpl::list<SelfStart::self_start_procedure<
219  step_actions>>>>,
221  Phase, Phase::RegisterWithObserver,
224  Tags::Time, element_observation_type>>,
227  Phase, Phase::Evolve,
228  tmpl::flatten<
229  tmpl::list<Actions::RunEventsAndTriggers, step_actions,
230  Actions::AdvanceTime>>>>>>;
231 
232  static constexpr OptionString help{
233  "Evolve a generalized harmonic analytic solution.\n\n"
234  "The analytic solution is: KerrSchild\n"
235  "The numerical flux is: UpwindFlux\n"};
236 
237  static Phase determine_next_phase(
238  const Phase& current_phase,
239  const Parallel::CProxy_ConstGlobalCache<
240  EvolutionMetavars>& /*cache_proxy*/) noexcept {
241  switch (current_phase) {
242  case Phase::Initialization:
243  return Phase::InitializeTimeStepperHistory;
244  case Phase::InitializeTimeStepperHistory:
245  return Phase::RegisterWithObserver;
246  case Phase::RegisterWithObserver:
247  return Phase::Evolve;
248  case Phase::Evolve:
249  return Phase::Exit;
250  case Phase::Exit:
251  ERROR(
252  "Should never call determine_next_phase with the current phase "
253  "being 'Exit'");
254  default:
255  ERROR(
256  "Unknown type of phase. Did you static_cast<Phase> an integral "
257  "value?");
258  }
259  }
260 };
261 
262 static const std::vector<void (*)()> charm_init_node_funcs{
263  &setup_error_handling,
264  &domain::creators::register_derived_with_charm,
265  &Parallel::register_derived_classes_with_charm<
267  &Parallel::register_derived_classes_with_charm<
269  &Parallel::register_derived_classes_with_charm<StepController>,
270  &Parallel::register_derived_classes_with_charm<TimeStepper>,
271  &Parallel::register_derived_classes_with_charm<
273 
274 static const std::vector<void (*)()> charm_init_proc_funcs{
Compute item for spatial metric determinant and inverse in terms of the spatial metric ...
Definition: ComputeSpacetimeQuantities.hpp:299
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
A wrapper for general-relativity analytic solutions that loads the analytic solution and then adds a ...
Definition: WrappedGr.hpp:40
Definition: Characteristics.hpp:76
Functions for serializing factory-created classes.
The set of directions to neighboring Elements.
Definition: Tags.hpp:189
The parallel component responsible for managing the DG elements that compose the computational domain...
Definition: DgElementArray.hpp:31
#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)
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
Defines action AdvanceTime.
Compute items to compute constraint-damping parameters for a single-BH evolution. ...
Definition: ComputeGhQuantities.hpp:736
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
Defines base class StepController.
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:59
Computes the coordinates in the frame Frame on the faces defined by Direction. Intended to be prefixe...
Definition: InterfaceComputeTags.hpp:222
Defines classes and functions for making classes creatable from input files.
Tag for the current time as a double.
Definition: Tags.hpp:72
The set of directions which correspond to external boundaries. Used for representing data on the inte...
Definition: Tags.hpp:208
Defines actions SendDataForFluxes and ReceiveDataForFluxes.
Definition: Tags.hpp:59
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
Gauge control parameter determining how long the transition to the evolution gauge should take at the...
Definition: Tags.hpp:85
tmpl::list< Registrars::EveryNSlabs, Registrars::PastTime, Registrars::SpecifiedSlabs > time_triggers
Typelist of Time triggers.
Definition: TimeTriggers.hpp:15
Defines Functions for calculating spacetime tensors from 3+1 quantities.
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
Definition: Initialize.hpp:128
The group parallel component that is responsible for reducing data to be observed.
Definition: ObserverComponent.hpp:27
Compute items to compute constraint-damping parameters for a single-BH evolution. ...
Definition: ComputeGhQuantities.hpp:759
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
Definition: Characteristics.hpp:162
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: Tags.hpp:28
Definition: Norms.hpp:100
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
Definition: Tags.hpp:54
Definition: System.hpp:26
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
Tags corresponding to various constraints of the generalized harmonic system, and their diagnosticall...
Definition: Tags.hpp:239
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
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.
Defines class template GeneralizedHarmonicEquations.
The analytic solution, with the type of the analytic solution set as the template parameter...
Definition: Tags.hpp:49
Allocate and set variables needed for evolution of nonconservative systems.
Definition: NonconservativeSystem.hpp:44
Initialize the list of compute tags in ComputeTagsList
Definition: AddComputeTags.hpp:38
Definition: IndexType.hpp:44
Gauge control parameter determining when to start rolling-on the evolution gauge. ...
Definition: Tags.hpp:67
Compute items to compute constraint-damping parameters for a single-BH evolution. ...
Definition: ComputeGhQuantities.hpp:749
tmpl::list< Tags... > slice_tags_to_face
Tags that are to be sliced to the faces of the element
Definition: InitializeInterfaces.hpp:32
Compute element boundary contributions to the temporal step of the variables.
Definition: ApplyFluxes.hpp:67
tmpl::list< Tags... > face_compute_tags
Compute tags on the faces of the element.
Definition: InitializeInterfaces.hpp:42
Definition: ObserveFields.hpp:61
Gauge control parameter to specify the spatial weighting function that enters damped harmonic gauge s...
Definition: Tags.hpp:108
Defines Functions for calculating spacetime tensors from 3+1 quantities.
Defines macro ERROR.
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
Initialize items related to the interfaces between Elements and on external boundaries.
Definition: InitializeInterfaces.hpp:140
Defines tags related to Time quantities.
Defines functions to calculate Christoffel symbols.
Compute on the boundaries for a non-conservative system.
Definition: ComputeNonconservativeBoundaryFluxes.hpp:45
Declares function templates to calculate the Ricci tensor.