EvolveValencia.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 "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/Initialization/SetVariables.hpp"
33 #include "Evolution/Systems/RelativisticEuler/Valencia/FixConservatives.hpp"
34 #include "Evolution/Systems/RelativisticEuler/Valencia/System.hpp"
35 #include "Evolution/Systems/RelativisticEuler/Valencia/Tags.hpp"
36 #include "Evolution/VariableFixing/Actions.hpp"
37 #include "Evolution/VariableFixing/FixToAtmosphere.hpp"
38 #include "Evolution/VariableFixing/Tags.hpp"
39 #include "IO/Observer/Actions.hpp"
40 #include "IO/Observer/Helpers.hpp"
41 #include "IO/Observer/ObserverComponent.hpp"
42 #include "IO/Observer/RegisterObservers.hpp"
43 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp"
44 #include "NumericalAlgorithms/DiscontinuousGalerkin/BoundarySchemes/FirstOrder/FirstOrderScheme.hpp"
45 #include "NumericalAlgorithms/DiscontinuousGalerkin/BoundarySchemes/FirstOrder/FirstOrderSchemeLts.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/CollectDataForFluxes.hpp"
56 #include "ParallelAlgorithms/DiscontinuousGalerkin/FluxCommunication.hpp"
57 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeDomain.hpp"
58 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeInterfaces.hpp"
59 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeMortars.hpp"
60 #include "ParallelAlgorithms/Events/ObserveErrorNorms.hpp"
61 #include "ParallelAlgorithms/Events/ObserveFields.hpp"
62 #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp"
63 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
64 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
66 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
67 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
68 #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/SmoothFlow.hpp"
69 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
70 #include "PointwiseFunctions/Hydro/SoundSpeedSquared.hpp"
71 #include "PointwiseFunctions/Hydro/Tags.hpp"
73 #include "Time/Actions/ChangeSlabSize.hpp"
74 #include "Time/Actions/ChangeStepSize.hpp"
75 #include "Time/Actions/RecordTimeStepperData.hpp"
76 #include "Time/Actions/SelfStartActions.hpp"
77 #include "Time/Actions/UpdateU.hpp"
78 #include "Time/StepChoosers/Cfl.hpp"
79 #include "Time/StepChoosers/Constant.hpp"
80 #include "Time/StepChoosers/Increase.hpp"
81 #include "Time/StepChoosers/PreventRapidIncrease.hpp"
82 #include "Time/StepChoosers/StepChooser.hpp"
83 #include "Time/StepChoosers/StepToTimes.hpp"
85 #include "Time/Tags.hpp"
86 #include "Time/TimeSteppers/TimeStepper.hpp"
87 #include "Time/Triggers/TimeTriggers.hpp"
88 #include "Utilities/Functional.hpp"
89 #include "Utilities/TMPL.hpp"
90 
91 /// \cond
92 namespace Frame {
93 struct Inertial;
94 } // namespace Frame
95 namespace Parallel {
96 template <typename Metavariables>
97 class CProxy_ConstGlobalCache;
98 } // namespace Parallel
99 /// \endcond
100 
101 template <size_t Dim, typename InitialData>
102 struct EvolutionMetavars {
103  static constexpr size_t volume_dim = Dim;
104  static constexpr dg::Formulation dg_formulation =
105  dg::Formulation::StrongInertial;
106 
107  using initial_data = InitialData;
108  static_assert(
109  evolution::is_analytic_data_v<initial_data> xor
110  evolution::is_analytic_solution_v<initial_data>,
111  "initial_data must be either an analytic_data or an analytic_solution");
112 
113  using equation_of_state_type = typename initial_data::equation_of_state_type;
114 
115  using system =
117 
118  static constexpr size_t thermodynamic_dim = system::thermodynamic_dim;
119 
120  using temporal_id = Tags::TimeStepId;
121  static constexpr bool local_time_stepping = false;
122 
123  using initial_data_tag =
124  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
127 
128  using boundary_condition_tag = initial_data_tag;
129  using analytic_variables_tags =
130  typename system::primitive_variables_tag::tags_list;
131 
132  using equation_of_state_tag =
134 
135  using normal_dot_numerical_flux =
137 
138  using limiter = Tags::Limiter<Limiters::Minmod<
142 
143  using step_choosers_common =
144  tmpl::list<//StepChoosers::Registrars::Cfl<volume_dim, Frame::Inertial>,
147  using step_choosers_for_step_only =
148  tmpl::list<StepChoosers::Registrars::PreventRapidIncrease>;
149  using step_choosers_for_slab_only =
150  tmpl::list<StepChoosers::Registrars::StepToTimes>;
151  using step_choosers = tmpl::conditional_t<
152  local_time_stepping,
153  tmpl::append<step_choosers_common, step_choosers_for_step_only>,
154  tmpl::list<>>;
155  using slab_choosers = tmpl::conditional_t<
156  local_time_stepping,
157  tmpl::append<step_choosers_common, step_choosers_for_slab_only>,
158  tmpl::append<step_choosers_common, step_choosers_for_step_only,
159  step_choosers_for_slab_only>>;
160 
161  using time_stepper_tag = Tags::TimeStepper<
162  tmpl::conditional_t<local_time_stepping, LtsTimeStepper, TimeStepper>>;
163  using boundary_scheme = tmpl::conditional_t<
164  local_time_stepping,
166  Dim, typename system::variables_tag, normal_dot_numerical_flux,
167  Tags::TimeStepId, time_stepper_tag>,
169  Dim, typename system::variables_tag, normal_dot_numerical_flux,
171 
172  using events = tmpl::list<
173  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
175  Tags::Time, analytic_variables_tags>,
176  tmpl::list<>>,
178  Dim, Tags::Time,
179  tmpl::append<
180  db::get_variables_tags_list<typename system::variables_tag>,
181  db::get_variables_tags_list<
182  typename system::primitive_variables_tag>>,
183  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
184  analytic_variables_tags, tmpl::list<>>>,
186  using triggers = Triggers::time_triggers;
187 
188  struct ObservationType {};
189  using element_observation_type = ObservationType;
190 
191  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
192  typename Event<events>::creatable_classes>;
193 
194  using step_actions = tmpl::flatten<tmpl::list<
203  tmpl::conditional_t<
204  evolution::is_analytic_solution_v<initial_data>,
206  tmpl::list<>>,
208  boundary_scheme,
211  tmpl::conditional_t<local_time_stepping,
212  tmpl::list<Actions::RecordTimeStepperData<>,
214  tmpl::list<Actions::MutateApply<boundary_scheme>,
220  // Conservative `UpdatePrimitives` expects system to possess
221  // list of recovery schemes so we use `MutateApply` instead.
223 
224  enum class Phase {
225  Initialization,
226  InitializeTimeStepperHistory,
227  RegisterWithObserver,
228  Evolve,
229  Exit
230  };
231 
232  using initialization_actions = tmpl::list<
243  tmpl::list<hydro::Tags::SoundSpeedSquaredCompute<DataVector>>>,
246  system,
248  typename system::variables_tag,
249  typename system::spacetime_variables_tag,
250  typename system::primitive_variables_tag,
253  typename system::spacetime_variables_tag,
254  typename system::primitive_variables_tag,
258  tmpl::conditional_t<
259  evolution::is_analytic_solution_v<initial_data>,
262  Dim, initial_data_tag, analytic_variables_tags>>>,
263  tmpl::list<>>,
268 
269  using component_list = tmpl::list<
274  tmpl::list<
275  Parallel::PhaseActions<Phase, Phase::Initialization,
276  initialization_actions>,
277 
279  Phase, Phase::InitializeTimeStepperHistory,
281 
283  Phase, Phase::RegisterWithObserver,
286  Tags::Time, element_observation_type>>,
288 
290  Phase, Phase::Evolve,
291  tmpl::list<
294  thermodynamic_dim>>,
298  tmpl::conditional_t<
299  local_time_stepping,
301  step_actions, Actions::AdvanceTime>>>>>;
302 
303  using const_global_cache_tags =
304  tmpl::list<initial_data_tag, normal_dot_numerical_flux, time_stepper_tag,
306 
307  static constexpr OptionString help{
308  "Evolve the Valencia formulation of RelativisticEuler system.\n\n"};
309 
310  static Phase determine_next_phase(
311  const Phase& current_phase,
312  const Parallel::CProxy_ConstGlobalCache<
313  EvolutionMetavars>& /*cache_proxy*/) noexcept {
314  switch (current_phase) {
315  case Phase::Initialization:
316  return Phase::InitializeTimeStepperHistory;
317  case Phase::InitializeTimeStepperHistory:
318  return Phase::RegisterWithObserver;
319  case Phase::RegisterWithObserver:
320  return Phase::Evolve;
321  case Phase::Evolve:
322  return Phase::Exit;
323  case Phase::Exit:
324  ERROR(
325  "Should never call determine_next_phase with the current phase "
326  "being 'Exit'");
327  default:
328  ERROR(
329  "Unknown type of phase. Did you static_cast<Phase> to an integral "
330  "value?");
331  }
332  }
333 };
334 
335 static const std::vector<void (*)()> charm_init_node_funcs{
336  &setup_error_handling,
337  &domain::creators::register_derived_with_charm,
338  &domain::creators::time_dependence::register_derived_with_charm,
339  &domain::FunctionsOfTime::register_derived_with_charm,
346  &Parallel::register_derived_classes_with_charm<StepController>,
347  &Parallel::register_derived_classes_with_charm<TimeStepper>,
350 
351 static const std::vector<void (*)()> charm_init_proc_funcs{
FloatingPointExceptions.hpp
hydro::Tags::EquationOfState
The equation of state.
Definition: Tags.hpp:57
RegisterDerivedClassesWithCharm.hpp
Tags::Limiter
The global cache tag for the limiter.
Definition: Tags.hpp:40
evolution::dg::ConservativeDuDt
Calculate for a conservative system.
Definition: ConservativeDuDt.hpp:34
Tags::TimeStepId
Tag for TimeStepId for the algorithm state.
Definition: Tags.hpp:34
Limiters::Actions::SendData
Send local data needed for limiting.
Definition: LimiterActions.hpp:157
domain::Tags::Coordinates
Definition: Tags.hpp:129
Tags.hpp
LimiterActions.hpp
Options.hpp
VariableFixing::Actions::FixVariables
Adjust variables with a variable fixer.
Definition: Actions.hpp:43
Initialization::Actions::AddComputeTags
Initialize the list of compute tags in ComputeTagsList
Definition: AddComputeTags.hpp:38
Tags.hpp
vector
evolution::Tags::AnalyticCompute
Use the AnalyticSolutionTag to compute the analytic solution of the tags in AnalyticFieldsTagList.
Definition: ComputeTags.hpp:24
dg::Actions::SendDataForFluxes
Send local boundary data needed for fluxes to neighbors.
Definition: FluxCommunication.hpp:79
Initialization::Actions::RemoveOptionsAndTerminatePhase
Definition: RemoveOptionsAndTerminatePhase.hpp:27
Initialization::Actions::Minmod
Allocate items for minmod limiter.
Definition: Limiter.hpp:35
Actions::AdvanceTime
Advance time one substep.
Definition: AdvanceTime.hpp:50
dg::Initialization::face_compute_tags
tmpl::list< Tags... > face_compute_tags
Definition: InitializeInterfaces.hpp:42
Parallel::Actions::TerminatePhase
Terminate the algorithm to proceed to the next phase.
Definition: TerminatePhase.hpp:26
Tags::NumericalFlux
The global cache tag for the numerical flux.
Definition: Tags.hpp:88
dg::Initialization::slice_tags_to_face
tmpl::list< Tags... > slice_tags_to_face
Definition: InitializeInterfaces.hpp:32
domain::Tags::BoundaryDirectionsInterior
Definition: Tags.hpp:250
DgElementArray
The parallel component responsible for managing the DG elements that compose the computational domain...
Definition: DgElementArray.hpp:94
Registration::Registrar
A template for defining a registrar.
Definition: Registration.hpp:42
EvolutionMetavars
Definition: EvolveBurgers.hpp:95
Initialization::Actions::ConservativeSystem
Allocate variables needed for evolution of conservative systems.
Definition: ConservativeSystem.hpp:66
enable_floating_point_exceptions
void enable_floating_point_exceptions()
Definition: FloatingPointExceptions.cpp:27
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
Actions::UpdateConservatives
Compute the conservative variables from the primitive variables.
Definition: UpdateConservatives.hpp:33
Actions::ChangeSlabSize
Definition: ChangeSlabSize.hpp:107
evolution::Actions::AddMeshVelocitySourceTerms
Compute and add the source term modification for moving meshes.
Definition: AddMeshVelocitySourceTerms.hpp:55
dg::FirstOrderScheme::FirstOrderSchemeLts
Boundary contributions for a first-order DG scheme with local time-stepping.
Definition: FirstOrderSchemeLts.hpp:79
Parallel::PhaseActions
List of all the actions to be executed in the specified phase.
Definition: PhaseDependentActionList.hpp:16
observers::ObserverWriter
The nodegroup parallel component that is responsible for writing data to disk.
Definition: ObserverComponent.hpp:48
dg::Actions::InitializeInterfaces
Initialize items related to the interfaces between Elements and on external boundaries.
Definition: InitializeInterfaces.hpp:141
RelativisticEuler::Valencia::Tags::TildeTau
The densitized energy density .
Definition: Tags.hpp:33
Event
Definition: Event.hpp:30
Initialization::Actions::GrTagsForHydro
Allocate and set general relativity quantities needed for evolution of some hydro systems.
Definition: GrTagsForHydro.hpp:60
RelativisticEuler::Valencia::System
Definition: System.hpp:29
cstddef
Actions::RunEventsAndTriggers
Run the events and triggers.
Definition: RunEventsAndTriggers.hpp:27
Actions::MutateApply
Apply the function Mutator::apply to the DataBox.
Definition: MutateApply.hpp:40
evolution::dg::Initialization::Domain
Initialize items related to the basic structure of the element.
Definition: DgDomain.hpp:80
Initialization::Actions::TimeStepperHistory
Initialize time-stepper items.
Definition: Evolution.hpp:186
Tags::AnalyticSolution
Definition: Tags.hpp:52
observers::Observer
The group parallel component that is responsible for reducing data to be observed.
Definition: ObserverComponent.hpp:27
Limiters::Actions::Limit
Receive limiter data from neighbors, then apply limiter.
Definition: LimiterActions.hpp:70
Trigger
Definition: Trigger.hpp:34
StepController.hpp
dg::Actions::InitializeMortars
Initialize mortars between elements for exchanging fluxes.
Definition: InitializeMortars.hpp:75
Tags::Time
Tag for the current time as a double.
Definition: Tags.hpp:74
Actions::ComputeTimeDerivative
Compute the time derivative of the system variables.
Definition: ComputeTimeDerivative.hpp:55
Actions::ChangeStepSize
Adjust the step size for local time stepping.
Definition: ChangeStepSize.hpp:48
Triggers::time_triggers
tmpl::list< Registrars::EveryNSlabs, Registrars::NearTimes, Registrars::PastTime, Registrars::SpecifiedSlabs, Registrars::SpecifiedTimes > time_triggers
Definition: TimeTriggers.hpp:19
dg::Actions::CollectDataForFluxes
Collect data that is needed to compute numerical fluxes and store it on mortars, projecting it if nec...
Definition: CollectDataForFluxes.hpp:68
dg::Events::Registrars::ObserveFields
Definition: ObserveFields.hpp:61
RelativisticEuler::Valencia::Tags::TildeS
The densitized momentum density .
Definition: Tags.hpp:39
AdvanceTime.hpp
Tags::AnalyticData
The analytic data, with the type of the analytic data set as the template parameter.
Definition: Tags.hpp:41
Actions::RecordTimeStepperData
Records the variables and their time derivatives in the time stepper history.
Definition: RecordTimeStepperData.hpp:50
dg::Actions::ImposeDirichletBoundaryConditions
Packages data on external boundaries for calculating numerical flux. Computes contributions on the in...
Definition: ImposeBoundaryConditions.hpp:61
Tags::EventsAndTriggers
Definition: Tags.hpp:57
hydro::Tags::SoundSpeedSquared
The sound speed squared .
Definition: Tags.hpp:131
dg::Initialization::exterior_compute_tags
tmpl::list< Tags... > exterior_compute_tags
Definition: InitializeInterfaces.hpp:47
evolution::Initialization::Actions::SetVariables
Sets variables needed for evolution of hyperbolic systems.
Definition: SetVariables.hpp:55
Tags::TimeStepper
Tag for a TimeStepper of type StepperType.
Definition: Tags.hpp:181
observers::RegisterObservers
Passed to RegisterWithObservers action to register observer event.
Definition: RegisterObservers.hpp:15
dg::FirstOrderScheme::FirstOrderScheme
Boundary contributions for a first-order DG scheme.
Definition: FirstOrderScheme.hpp:66
Frame
Definition: IndexType.hpp:36
Actions::UpdateU
Perform variable updates for one substep.
Definition: UpdateU.hpp:50
RelativisticEuler::Valencia::Tags::TildeD
The densitized rest-mass density .
Definition: Tags.hpp:28
domain::Tags::InternalDirections
Definition: Tags.hpp:231
Initialization::Actions::TimeAndTimeStep
Initialize items related to time, such as the time step.
Definition: Evolution.hpp:76
SelfStart::self_start_procedure
typename detail::self_start_procedure_impl< StepActions >::type self_start_procedure
Definition: SelfStartActions.hpp:471
UpdateU.hpp
Parallel::register_derived_classes_with_charm
void register_derived_classes_with_charm() noexcept
Register derived classes of the Base class.
Definition: RegisterDerivedClassesWithCharm.hpp:31
dg::Actions::ReceiveDataForFluxes
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:177
Actions::ComputeVolumeFluxes
Compute the volume fluxes of the evolved variables.
Definition: ComputeVolumeFluxes.hpp:57
dg::Formulation
Formulation
The DG formulation to use.
Definition: Formulation.hpp:26
StepChooser
Definition: StepChooser.hpp:43
Actions::ComputeVolumeSources
Compute the volume sources of the evolved variables.
Definition: ComputeVolumeSources.hpp:35
OptionString
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:30
Parallel
Contains functions that forward to Charm++ parallel functions.
Definition: ElementReceiveInterpPoints.hpp:14
Initialization::Actions::DiscontinuousGalerkin
Initialize items related to the discontinuous Galerkin method.
Definition: DiscontinuousGalerkin.hpp:66
VariableFixing::FixToAtmosphere
Fix the primitive variables to an atmosphere in low density regions.
Definition: FixToAtmosphere.hpp:47
RelativisticEuler::Valencia::FixConservatives
Fix conservative variables using the method proposed in F. Foucart's PhD thesis (Cornell)
Definition: FixConservatives.hpp:53
TMPL.hpp
dg::Initialization::slice_tags_to_exterior
tmpl::list< Tags... > slice_tags_to_exterior
Definition: InitializeInterfaces.hpp:37
observers::Actions::RegisterWithObservers
Registers itself with the local observer parallel component so the observer knows to expect data from...
Definition: Actions.hpp:232