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"
14 #include "Evolution/ComputeTags.hpp"
15 #include "Evolution/Conservative/UpdateConservatives.hpp"
16 #include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivative.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/DgDomain.hpp"
23 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
24 #include "Evolution/Initialization/Evolution.hpp"
25 #include "Evolution/Initialization/GrTagsForHydro.hpp"
26 #include "Evolution/Initialization/Limiter.hpp"
27 #include "Evolution/Initialization/SetVariables.hpp"
28 #include "Evolution/Systems/RelativisticEuler/Valencia/FixConservatives.hpp"
29 #include "Evolution/Systems/RelativisticEuler/Valencia/System.hpp"
30 #include "Evolution/Systems/RelativisticEuler/Valencia/Tags.hpp"
31 #include "Evolution/VariableFixing/Actions.hpp"
32 #include "Evolution/VariableFixing/FixToAtmosphere.hpp"
33 #include "Evolution/VariableFixing/Tags.hpp"
34 #include "IO/Observer/Actions/RegisterEvents.hpp"
35 #include "IO/Observer/Helpers.hpp"
36 #include "IO/Observer/ObserverComponent.hpp"
37 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp"
38 #include "NumericalAlgorithms/DiscontinuousGalerkin/BoundarySchemes/FirstOrder/FirstOrderScheme.hpp"
39 #include "NumericalAlgorithms/DiscontinuousGalerkin/BoundarySchemes/FirstOrder/FirstOrderSchemeLts.hpp"
40 #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
41 #include "NumericalAlgorithms/DiscontinuousGalerkin/NumericalFluxes/LocalLaxFriedrichs.hpp"
42 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
43 #include "Options/Options.hpp"
44 #include "Parallel/Actions/SetupDataBox.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/Events/ObserveTimeStep.hpp"
58 #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp"
59 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
60 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
62 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
63 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
64 #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/SmoothFlow.hpp"
65 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
66 #include "PointwiseFunctions/Hydro/SoundSpeedSquared.hpp"
67 #include "PointwiseFunctions/Hydro/Tags.hpp"
69 #include "Time/Actions/ChangeSlabSize.hpp"
70 #include "Time/Actions/ChangeStepSize.hpp"
71 #include "Time/Actions/RecordTimeStepperData.hpp"
72 #include "Time/Actions/SelfStartActions.hpp"
73 #include "Time/Actions/UpdateU.hpp"
74 #include "Time/StepChoosers/Cfl.hpp"
75 #include "Time/StepChoosers/Constant.hpp"
76 #include "Time/StepChoosers/Increase.hpp"
77 #include "Time/StepChoosers/PreventRapidIncrease.hpp"
78 #include "Time/StepChoosers/StepChooser.hpp"
79 #include "Time/StepChoosers/StepToTimes.hpp"
81 #include "Time/Tags.hpp"
82 #include "Time/TimeSequence.hpp"
83 #include "Time/TimeSteppers/TimeStepper.hpp"
84 #include "Time/Triggers/TimeTriggers.hpp"
85 #include "Utilities/Blas.hpp"
87 #include "Utilities/Functional.hpp"
88 #include "Utilities/TMPL.hpp"
89 
90 /// \cond
91 namespace Frame {
92 struct Inertial;
93 } // namespace Frame
94 namespace Parallel {
95 template <typename Metavariables>
96 class CProxy_GlobalCache;
97 } // namespace Parallel
98 /// \endcond
99 
100 template <size_t Dim, typename InitialData>
101 struct EvolutionMetavars {
102  static constexpr size_t volume_dim = Dim;
103  static constexpr dg::Formulation dg_formulation =
104  dg::Formulation::StrongInertial;
105 
106  using initial_data = InitialData;
107  static_assert(
108  evolution::is_analytic_data_v<initial_data> xor
109  evolution::is_analytic_solution_v<initial_data>,
110  "initial_data must be either an analytic_data or an analytic_solution");
111 
112  using equation_of_state_type = typename initial_data::equation_of_state_type;
113 
114  using system =
116 
117  static constexpr size_t thermodynamic_dim = system::thermodynamic_dim;
118 
119  using temporal_id = Tags::TimeStepId;
120  static constexpr bool local_time_stepping = false;
121 
122  using initial_data_tag =
123  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
126 
127  using boundary_condition_tag = initial_data_tag;
128  using analytic_variables_tags =
129  typename system::primitive_variables_tag::tags_list;
130 
131  using equation_of_state_tag =
133 
134  using normal_dot_numerical_flux =
136 
137  using limiter = Tags::Limiter<Limiters::Minmod<
141 
142  using step_choosers_common =
143  tmpl::list<//StepChoosers::Registrars::Cfl<volume_dim, Frame::Inertial>,
146  using step_choosers_for_step_only =
147  tmpl::list<StepChoosers::Registrars::PreventRapidIncrease>;
148  using step_choosers_for_slab_only =
149  tmpl::list<StepChoosers::Registrars::StepToTimes>;
150  using step_choosers = tmpl::conditional_t<
151  local_time_stepping,
152  tmpl::append<step_choosers_common, step_choosers_for_step_only>,
153  tmpl::list<>>;
154  using slab_choosers = tmpl::conditional_t<
155  local_time_stepping,
156  tmpl::append<step_choosers_common, step_choosers_for_slab_only>,
157  tmpl::append<step_choosers_common, step_choosers_for_step_only,
158  step_choosers_for_slab_only>>;
159 
160  using time_stepper_tag = Tags::TimeStepper<
161  tmpl::conditional_t<local_time_stepping, LtsTimeStepper, TimeStepper>>;
162  using boundary_scheme = tmpl::conditional_t<
163  local_time_stepping,
165  Dim, typename system::variables_tag,
167  normal_dot_numerical_flux, Tags::TimeStepId, time_stepper_tag>,
169  Dim, typename system::variables_tag,
171  normal_dot_numerical_flux, Tags::TimeStepId>>;
172 
173  using events = tmpl::list<
174  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
176  Tags::Time, analytic_variables_tags>,
177  tmpl::list<>>,
179  Dim, Tags::Time,
180  tmpl::append<typename system::variables_tag::tags_list,
181  typename system::primitive_variables_tag::tags_list>,
182  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
183  analytic_variables_tags, tmpl::list<>>>,
186  using triggers = Triggers::time_triggers;
187 
188  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
189  typename Event<events>::creatable_classes>;
190 
191  using step_actions = tmpl::flatten<tmpl::list<
193  tmpl::conditional_t<
194  evolution::is_analytic_solution_v<initial_data>,
196  tmpl::list<>>,
198  boundary_scheme,
201  tmpl::conditional_t<local_time_stepping,
202  tmpl::list<Actions::RecordTimeStepperData<>,
204  tmpl::list<Actions::MutateApply<boundary_scheme>,
210  // Conservative `UpdatePrimitives` expects system to possess
211  // list of recovery schemes so we use `MutateApply` instead.
213 
214  enum class Phase {
215  Initialization,
216  InitializeTimeStepperHistory,
217  RegisterWithObserver,
218  Evolve,
219  Exit
220  };
221 
222  using initialization_actions = tmpl::list<
228  equation_of_state_tag>,
235  tmpl::list<hydro::Tags::SoundSpeedSquaredCompute<DataVector>>>,
238  system,
240  typename system::variables_tag,
241  typename system::spacetime_variables_tag,
242  typename system::primitive_variables_tag,
245  typename system::spacetime_variables_tag,
246  typename system::primitive_variables_tag,
250  tmpl::conditional_t<
251  evolution::is_analytic_solution_v<initial_data>,
254  Dim, initial_data_tag, analytic_variables_tags>>>,
255  tmpl::list<>>,
260 
261  using component_list = tmpl::list<
266  tmpl::list<
267  Parallel::PhaseActions<Phase, Phase::Initialization,
268  initialization_actions>,
269 
271  Phase, Phase::InitializeTimeStepperHistory,
273 
275  Phase, Phase::RegisterWithObserver,
278 
280  Phase, Phase::Evolve,
281  tmpl::list<
284  thermodynamic_dim>>,
287  tmpl::conditional_t<
288  local_time_stepping,
290  step_actions, Actions::AdvanceTime>>>>>;
291 
292  using const_global_cache_tags =
293  tmpl::list<initial_data_tag, normal_dot_numerical_flux, time_stepper_tag,
295 
296  static constexpr Options::String help{
297  "Evolve the Valencia formulation of RelativisticEuler system.\n\n"};
298 
299  static Phase determine_next_phase(
300  const Phase& current_phase,
301  const Parallel::CProxy_GlobalCache<
302  EvolutionMetavars>& /*cache_proxy*/) noexcept {
303  switch (current_phase) {
304  case Phase::Initialization:
305  return Phase::InitializeTimeStepperHistory;
306  case Phase::InitializeTimeStepperHistory:
307  return Phase::RegisterWithObserver;
308  case Phase::RegisterWithObserver:
309  return Phase::Evolve;
310  case Phase::Evolve:
311  return Phase::Exit;
312  case Phase::Exit:
313  ERROR(
314  "Should never call determine_next_phase with the current phase "
315  "being 'Exit'");
316  default:
317  ERROR(
318  "Unknown type of phase. Did you static_cast<Phase> to an integral "
319  "value?");
320  }
321  }
322 };
323 
324 static const std::vector<void (*)()> charm_init_node_funcs{
325  &setup_error_handling, &disable_openblas_multithreading,
326  &domain::creators::register_derived_with_charm,
327  &domain::creators::time_dependence::register_derived_with_charm,
328  &domain::FunctionsOfTime::register_derived_with_charm,
335  &Parallel::register_derived_classes_with_charm<StepController>,
336  &Parallel::register_derived_classes_with_charm<TimeSequence<double>>,
337  &Parallel::register_derived_classes_with_charm<TimeSequence<std::uint64_t>>,
338  &Parallel::register_derived_classes_with_charm<TimeStepper>,
341 
342 static const std::vector<void (*)()> charm_init_proc_funcs{
FloatingPointExceptions.hpp
hydro::Tags::EquationOfState
The equation of state.
Definition: Tags.hpp:57
RegisterDerivedClassesWithCharm.hpp
Actions::SetupDataBox
Add into the DataBox default constructed items for the collection of tags requested by any of the act...
Definition: SetupDataBox.hpp:81
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:33
observers::Actions::RegisterEventsWithObservers
Registers this element of a parallel component with the local Observer parallel component for each tr...
Definition: RegisterEvents.hpp:97
Limiters::Actions::SendData
Send local data needed for limiting.
Definition: LimiterActions.hpp:157
domain::Tags::Coordinates
Definition: Tags.hpp:130
Tags.hpp
LimiterActions.hpp
Options.hpp
VariableFixing::Actions::FixVariables
Adjust variables with a variable fixer.
Definition: Actions.hpp:42
Initialization::Actions::AddComputeTags
Initialize the list of compute tags in ComputeTagsList
Definition: AddComputeTags.hpp:42
Tags.hpp
vector
std::system
T system(T... args)
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:51
Initialization::Actions::RemoveOptionsAndTerminatePhase
Definition: RemoveOptionsAndTerminatePhase.hpp:27
Initialization::Actions::Minmod
Allocate items for minmod limiter.
Definition: Limiter.hpp:38
Actions::AdvanceTime
Advance time one substep.
Definition: AdvanceTime.hpp:50
dg::Initialization::face_compute_tags
tmpl::list< Tags... > face_compute_tags
Definition: InitializeInterfaces.hpp:41
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:84
dg::Initialization::slice_tags_to_face
tmpl::list< Tags... > slice_tags_to_face
Definition: InitializeInterfaces.hpp:31
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:296
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:95
Initialization::Actions::ConservativeSystem
Allocate variables needed for evolution of conservative systems.
Definition: ConservativeSystem.hpp:72
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:32
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:51
dg::Actions::InitializeInterfaces
Initialize items related to the interfaces between Elements and on external boundaries.
Definition: InitializeInterfaces.hpp:120
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:65
evolution::dg::Actions::ComputeTimeDerivative
Computes the time derivative for a DG time step.
Definition: ComputeTimeDerivative.hpp:353
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:85
Initialization::Actions::TimeStepperHistory
Initialize time-stepper items.
Definition: Evolution.hpp:192
Tags::AnalyticSolution
Definition: Tags.hpp:58
cstdint
observers::Observer
The group parallel component that is responsible for reducing data to be observed.
Definition: ObserverComponent.hpp:29
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:78
Tags::Time
Tag for the current time as a double.
Definition: Tags.hpp:73
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:68
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:49
dg::Actions::ImposeDirichletBoundaryConditions
Packages data on external boundaries for calculating numerical flux. Computes contributions on the in...
Definition: ImposeBoundaryConditions.hpp:60
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:46
evolution::Initialization::Actions::SetVariables
Sets variables needed for evolution of hyperbolic systems.
Definition: SetVariables.hpp:54
Tags::TimeStepper
Tag for a TimeStepper of type StepperType.
Definition: Tags.hpp:187
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:66
Frame
Definition: IndexType.hpp:36
Actions::UpdateU
Perform variable updates for one substep.
Definition: UpdateU.hpp:49
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:80
SelfStart::self_start_procedure
typename detail::self_start_procedure_impl< StepActions >::type self_start_procedure
Definition: SelfStartActions.hpp:467
Parallel::register_derived_classes_with_charm
void register_derived_classes_with_charm() noexcept
Register derived classes of the Base class.
Definition: RegisterDerivedClassesWithCharm.hpp:31
UpdateU.hpp
Blas.hpp
dg::Actions::ReceiveDataForFluxes
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:175
dg::Formulation
Formulation
The DG formulation to use.
Definition: Formulation.hpp:34
StepChooser
Definition: StepChooser.hpp:43
Initialization::Actions::DiscontinuousGalerkin
Initialize items related to the discontinuous Galerkin method.
Definition: DiscontinuousGalerkin.hpp:70
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:36