EvolveValencia.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <cstdint>
8 #include <vector>
9 
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/ComputeTags.hpp"
16 #include "Evolution/Conservative/UpdateConservatives.hpp"
17 #include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivative.hpp"
18 #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
20 #include "Evolution/DiscontinuousGalerkin/Limiters/Minmod.tpp"
21 #include "Evolution/DiscontinuousGalerkin/Limiters/Tags.hpp"
22 #include "Evolution/Initialization/ConservativeSystem.hpp"
23 #include "Evolution/Initialization/DgDomain.hpp"
24 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
25 #include "Evolution/Initialization/Evolution.hpp"
26 #include "Evolution/Initialization/GrTagsForHydro.hpp"
27 #include "Evolution/Initialization/Limiter.hpp"
28 #include "Evolution/Initialization/SetVariables.hpp"
29 #include "Evolution/Systems/RelativisticEuler/Valencia/FixConservatives.hpp"
30 #include "Evolution/Systems/RelativisticEuler/Valencia/System.hpp"
31 #include "Evolution/Systems/RelativisticEuler/Valencia/Tags.hpp"
32 #include "Evolution/VariableFixing/Actions.hpp"
33 #include "Evolution/VariableFixing/FixToAtmosphere.hpp"
34 #include "Evolution/VariableFixing/Tags.hpp"
35 #include "IO/Observer/Actions/RegisterEvents.hpp"
36 #include "IO/Observer/Helpers.hpp"
37 #include "IO/Observer/ObserverComponent.hpp"
38 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp"
39 #include "NumericalAlgorithms/DiscontinuousGalerkin/BoundarySchemes/FirstOrder/FirstOrderScheme.hpp"
40 #include "NumericalAlgorithms/DiscontinuousGalerkin/BoundarySchemes/FirstOrder/FirstOrderSchemeLts.hpp"
41 #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
42 #include "NumericalAlgorithms/DiscontinuousGalerkin/NumericalFluxes/LocalLaxFriedrichs.hpp"
43 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
44 #include "Options/Options.hpp"
45 #include "Parallel/Actions/TerminatePhase.hpp"
46 #include "Parallel/InitializationFunctions.hpp"
47 #include "Parallel/PhaseDependentActionList.hpp"
49 #include "ParallelAlgorithms/Actions/MutateApply.hpp"
50 #include "ParallelAlgorithms/DiscontinuousGalerkin/CollectDataForFluxes.hpp"
51 #include "ParallelAlgorithms/DiscontinuousGalerkin/FluxCommunication.hpp"
52 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeDomain.hpp"
53 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeInterfaces.hpp"
54 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeMortars.hpp"
55 #include "ParallelAlgorithms/Events/ObserveErrorNorms.hpp"
56 #include "ParallelAlgorithms/Events/ObserveFields.hpp"
57 #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp"
58 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
59 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
61 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
62 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
63 #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/SmoothFlow.hpp"
64 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
65 #include "PointwiseFunctions/Hydro/SoundSpeedSquared.hpp"
66 #include "PointwiseFunctions/Hydro/Tags.hpp"
68 #include "Time/Actions/ChangeSlabSize.hpp"
69 #include "Time/Actions/ChangeStepSize.hpp"
70 #include "Time/Actions/RecordTimeStepperData.hpp"
71 #include "Time/Actions/SelfStartActions.hpp"
72 #include "Time/Actions/UpdateU.hpp"
73 #include "Time/StepChoosers/Cfl.hpp"
74 #include "Time/StepChoosers/Constant.hpp"
75 #include "Time/StepChoosers/Increase.hpp"
76 #include "Time/StepChoosers/PreventRapidIncrease.hpp"
77 #include "Time/StepChoosers/StepChooser.hpp"
78 #include "Time/StepChoosers/StepToTimes.hpp"
80 #include "Time/Tags.hpp"
81 #include "Time/TimeSequence.hpp"
82 #include "Time/TimeSteppers/TimeStepper.hpp"
83 #include "Time/Triggers/TimeTriggers.hpp"
84 #include "Utilities/Blas.hpp"
85 #include "Utilities/Functional.hpp"
86 #include "Utilities/TMPL.hpp"
87 
88 /// \cond
89 namespace Frame {
90 struct Inertial;
91 } // namespace Frame
92 namespace Parallel {
93 template <typename Metavariables>
94 class CProxy_GlobalCache;
95 } // namespace Parallel
96 /// \endcond
97 
98 template <size_t Dim, typename InitialData>
99 struct EvolutionMetavars {
100  static constexpr size_t volume_dim = Dim;
101  static constexpr dg::Formulation dg_formulation =
102  dg::Formulation::StrongInertial;
103 
104  using initial_data = InitialData;
105  static_assert(
106  evolution::is_analytic_data_v<initial_data> xor
107  evolution::is_analytic_solution_v<initial_data>,
108  "initial_data must be either an analytic_data or an analytic_solution");
109 
110  using equation_of_state_type = typename initial_data::equation_of_state_type;
111 
112  using system =
114 
115  static constexpr size_t thermodynamic_dim = system::thermodynamic_dim;
116 
117  using temporal_id = Tags::TimeStepId;
118  static constexpr bool local_time_stepping = false;
119 
120  using initial_data_tag =
121  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
124 
125  using boundary_condition_tag = initial_data_tag;
126  using analytic_variables_tags =
127  typename system::primitive_variables_tag::tags_list;
128 
129  using equation_of_state_tag =
131 
132  using normal_dot_numerical_flux =
134 
135  using limiter = Tags::Limiter<Limiters::Minmod<
139 
140  using step_choosers_common =
141  tmpl::list<//StepChoosers::Registrars::Cfl<volume_dim, Frame::Inertial>,
144  using step_choosers_for_step_only =
145  tmpl::list<StepChoosers::Registrars::PreventRapidIncrease>;
146  using step_choosers_for_slab_only =
147  tmpl::list<StepChoosers::Registrars::StepToTimes>;
148  using step_choosers = tmpl::conditional_t<
149  local_time_stepping,
150  tmpl::append<step_choosers_common, step_choosers_for_step_only>,
151  tmpl::list<>>;
152  using slab_choosers = tmpl::conditional_t<
153  local_time_stepping,
154  tmpl::append<step_choosers_common, step_choosers_for_slab_only>,
155  tmpl::append<step_choosers_common, step_choosers_for_step_only,
156  step_choosers_for_slab_only>>;
157 
158  using time_stepper_tag = Tags::TimeStepper<
159  tmpl::conditional_t<local_time_stepping, LtsTimeStepper, TimeStepper>>;
160  using boundary_scheme = tmpl::conditional_t<
161  local_time_stepping,
163  Dim, typename system::variables_tag,
165  normal_dot_numerical_flux, Tags::TimeStepId, time_stepper_tag>,
167  Dim, typename system::variables_tag,
169  normal_dot_numerical_flux, Tags::TimeStepId>>;
170 
171  using events = tmpl::list<
172  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
174  Tags::Time, analytic_variables_tags>,
175  tmpl::list<>>,
177  Dim, Tags::Time,
178  tmpl::append<typename system::variables_tag::tags_list,
179  typename system::primitive_variables_tag::tags_list>,
180  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
181  analytic_variables_tags, tmpl::list<>>>,
183  using triggers = Triggers::time_triggers;
184 
185  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
186  typename Event<events>::creatable_classes>;
187 
188  using step_actions = tmpl::flatten<tmpl::list<
191  tmpl::conditional_t<
192  evolution::is_analytic_solution_v<initial_data>,
194  tmpl::list<>>,
196  boundary_scheme,
199  tmpl::conditional_t<local_time_stepping,
200  tmpl::list<Actions::RecordTimeStepperData<>,
202  tmpl::list<Actions::MutateApply<boundary_scheme>,
208  // Conservative `UpdatePrimitives` expects system to possess
209  // list of recovery schemes so we use `MutateApply` instead.
211 
212  enum class Phase {
213  Initialization,
214  InitializeTimeStepperHistory,
215  RegisterWithObserver,
216  Evolve,
217  Exit
218  };
219 
220  using initialization_actions = tmpl::list<
231  tmpl::list<hydro::Tags::SoundSpeedSquaredCompute<DataVector>>>,
234  system,
236  typename system::variables_tag,
237  typename system::spacetime_variables_tag,
238  typename system::primitive_variables_tag,
241  typename system::spacetime_variables_tag,
242  typename system::primitive_variables_tag,
246  tmpl::conditional_t<
247  evolution::is_analytic_solution_v<initial_data>,
250  Dim, initial_data_tag, analytic_variables_tags>>>,
251  tmpl::list<>>,
256 
257  using component_list = tmpl::list<
262  tmpl::list<
263  Parallel::PhaseActions<Phase, Phase::Initialization,
264  initialization_actions>,
265 
267  Phase, Phase::InitializeTimeStepperHistory,
269 
271  Phase, Phase::RegisterWithObserver,
274 
276  Phase, Phase::Evolve,
277  tmpl::list<
280  thermodynamic_dim>>,
283  tmpl::conditional_t<
284  local_time_stepping,
286  step_actions, Actions::AdvanceTime>>>>>;
287 
288  using const_global_cache_tags =
289  tmpl::list<initial_data_tag, normal_dot_numerical_flux, time_stepper_tag,
291 
292  static constexpr Options::String help{
293  "Evolve the Valencia formulation of RelativisticEuler system.\n\n"};
294 
295  static Phase determine_next_phase(
296  const Phase& current_phase,
297  const Parallel::CProxy_GlobalCache<
298  EvolutionMetavars>& /*cache_proxy*/) noexcept {
299  switch (current_phase) {
300  case Phase::Initialization:
301  return Phase::InitializeTimeStepperHistory;
302  case Phase::InitializeTimeStepperHistory:
303  return Phase::RegisterWithObserver;
304  case Phase::RegisterWithObserver:
305  return Phase::Evolve;
306  case Phase::Evolve:
307  return Phase::Exit;
308  case Phase::Exit:
309  ERROR(
310  "Should never call determine_next_phase with the current phase "
311  "being 'Exit'");
312  default:
313  ERROR(
314  "Unknown type of phase. Did you static_cast<Phase> to an integral "
315  "value?");
316  }
317  }
318 };
319 
320 static const std::vector<void (*)()> charm_init_node_funcs{
321  &setup_error_handling, &disable_openblas_multithreading,
322  &domain::creators::register_derived_with_charm,
323  &domain::creators::time_dependence::register_derived_with_charm,
324  &domain::FunctionsOfTime::register_derived_with_charm,
331  &Parallel::register_derived_classes_with_charm<StepController>,
332  &Parallel::register_derived_classes_with_charm<TimeSequence<double>>,
333  &Parallel::register_derived_classes_with_charm<TimeSequence<std::uint64_t>>,
334  &Parallel::register_derived_classes_with_charm<TimeStepper>,
337 
338 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:42
Tags::TimeStepId
Tag for TimeStepId for the algorithm state.
Definition: Tags.hpp:34
observers::Actions::RegisterEventsWithObservers
Registers this element of a parallel component with the local Observer parallel component for each tr...
Definition: RegisterEvents.hpp:98
Limiters::Actions::SendData
Send local data needed for limiting.
Definition: LimiterActions.hpp:157
domain::Tags::Coordinates
Definition: Tags.hpp:131
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
Triggers::time_triggers
tmpl::list< Registrars::NearTimes, Registrars::PastTime, Registrars::Slabs, Registrars::Times > time_triggers
Definition: TimeTriggers.hpp:17
db::add_tag_prefix
typename detail::add_tag_prefix_impl< Prefix, Tag, Args... >::type add_tag_prefix
Definition: PrefixHelpers.hpp:52
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:85
dg::Initialization::slice_tags_to_face
tmpl::list< Tags... > slice_tags_to_face
Definition: InitializeInterfaces.hpp:32
disable_openblas_multithreading
void disable_openblas_multithreading() noexcept
Disable OpenBLAS multithreading since it conflicts with Charm++ parallelism.
Definition: Blas.cpp:15
domain::Tags::BoundaryDirectionsInterior
Definition: Tags.hpp:297
DgElementArray
The parallel component responsible for managing the DG elements that compose the computational domain...
Definition: DgElementArray.hpp:30
Registration::Registrar
A template for defining a registrar.
Definition: Registration.hpp:42
EvolutionMetavars
Definition: EvolveBurgers.hpp:94
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
dg::FirstOrderScheme::FirstOrderSchemeLts
Boundary contributions for a first-order DG scheme with local time-stepping.
Definition: FirstOrderSchemeLts.hpp:80
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:106
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
evolution::dg::Actions::ComputeTimeDerivative
Computes the time derivative for a DG time step.
Definition: ComputeTimeDerivative.hpp:133
RelativisticEuler::Valencia::System
Definition: System.hpp:30
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:54
cstdint
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::ChangeStepSize
Adjust the step size for local time stepping.
Definition: ChangeStepSize.hpp:48
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:62
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:43
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:188
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
dg::FirstOrderScheme::FirstOrderScheme
Boundary contributions for a first-order DG scheme.
Definition: FirstOrderScheme.hpp:67
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
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:468
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
Blas.hpp
dg::Actions::ReceiveDataForFluxes
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:177
dg::Formulation
Formulation
The DG formulation to use.
Definition: Formulation.hpp:26
StepChooser
Definition: StepChooser.hpp:43
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