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/Factory1D.hpp"
11 #include "Domain/Creators/Factory2D.hpp"
12 #include "Domain/Creators/Factory3D.hpp"
13 #include "Domain/Creators/RegisterDerivedWithCharm.hpp"
14 #include "Domain/Creators/TimeDependence/RegisterDerivedWithCharm.hpp"
15 #include "Domain/FunctionsOfTime/RegisterDerivedWithCharm.hpp"
16 #include "Domain/Tags.hpp"
17 #include "Evolution/Actions/RunEventsAndDenseTriggers.hpp"
18 #include "Evolution/ComputeTags.hpp"
19 #include "Evolution/Conservative/UpdateConservatives.hpp"
20 #include "Evolution/DiscontinuousGalerkin/Actions/ApplyBoundaryCorrections.hpp"
21 #include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivative.hpp"
22 #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
23 #include "Evolution/DiscontinuousGalerkin/Initialization/Mortars.hpp"
24 #include "Evolution/DiscontinuousGalerkin/Initialization/QuadratureTag.hpp"
26 #include "Evolution/DiscontinuousGalerkin/Limiters/Minmod.hpp"
27 #include "Evolution/DiscontinuousGalerkin/Limiters/Tags.hpp"
28 #include "Evolution/EventsAndDenseTriggers/DenseTrigger.hpp"
29 #include "Evolution/EventsAndDenseTriggers/DenseTriggers/Factory.hpp"
30 #include "Evolution/Initialization/ConservativeSystem.hpp"
31 #include "Evolution/Initialization/DgDomain.hpp"
32 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
33 #include "Evolution/Initialization/Evolution.hpp"
34 #include "Evolution/Initialization/GrTagsForHydro.hpp"
35 #include "Evolution/Initialization/Limiter.hpp"
36 #include "Evolution/Initialization/SetVariables.hpp"
37 #include "Evolution/Systems/RelativisticEuler/Valencia/BoundaryConditions/Factory.hpp"
38 #include "Evolution/Systems/RelativisticEuler/Valencia/BoundaryConditions/RegisterDerivedWithCharm.hpp"
39 #include "Evolution/Systems/RelativisticEuler/Valencia/BoundaryCorrections/Factory.hpp"
40 #include "Evolution/Systems/RelativisticEuler/Valencia/BoundaryCorrections/RegisterDerived.hpp"
41 #include "Evolution/Systems/RelativisticEuler/Valencia/FixConservatives.hpp"
42 #include "Evolution/Systems/RelativisticEuler/Valencia/System.hpp"
43 #include "Evolution/Systems/RelativisticEuler/Valencia/Tags.hpp"
44 #include "Evolution/VariableFixing/Actions.hpp"
45 #include "Evolution/VariableFixing/FixToAtmosphere.hpp"
46 #include "Evolution/VariableFixing/Tags.hpp"
47 #include "IO/Observer/Actions/RegisterEvents.hpp"
48 #include "IO/Observer/Helpers.hpp"
49 #include "IO/Observer/ObserverComponent.hpp"
50 #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
51 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
52 #include "Options/Options.hpp"
53 #include "Options/Protocols/FactoryCreation.hpp"
54 #include "Parallel/Actions/SetupDataBox.hpp"
55 #include "Parallel/Actions/TerminatePhase.hpp"
56 #include "Parallel/InitializationFunctions.hpp"
57 #include "Parallel/PhaseControl/CheckpointAndExitAfterWallclock.hpp"
58 #include "Parallel/PhaseControl/ExecutePhaseChange.hpp"
59 #include "Parallel/PhaseControl/PhaseControlTags.hpp"
60 #include "Parallel/PhaseControl/VisitAndReturn.hpp"
61 #include "Parallel/PhaseDependentActionList.hpp"
63 #include "ParallelAlgorithms/Actions/MutateApply.hpp"
64 #include "ParallelAlgorithms/Events/Factory.hpp"
65 #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp"
66 #include "ParallelAlgorithms/EventsAndTriggers/Completion.hpp"
67 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
68 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
69 #include "ParallelAlgorithms/EventsAndTriggers/LogicalTriggers.hpp"
71 #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
72 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
73 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
74 #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/SmoothFlow.hpp"
75 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
76 #include "PointwiseFunctions/Hydro/SoundSpeedSquared.hpp"
77 #include "PointwiseFunctions/Hydro/Tags.hpp"
79 #include "Time/Actions/ChangeSlabSize.hpp"
80 #include "Time/Actions/ChangeStepSize.hpp"
81 #include "Time/Actions/RecordTimeStepperData.hpp"
82 #include "Time/Actions/SelfStartActions.hpp"
83 #include "Time/Actions/UpdateU.hpp"
84 #include "Time/StepChoosers/Factory.hpp"
85 #include "Time/StepChoosers/StepChooser.hpp"
86 #include "Time/StepControllers/Factory.hpp"
88 #include "Time/Tags.hpp"
89 #include "Time/TimeSequence.hpp"
90 #include "Time/TimeSteppers/TimeStepper.hpp"
91 #include "Time/Triggers/TimeTriggers.hpp"
92 #include "Utilities/Blas.hpp"
94 #include "Utilities/Functional.hpp"
95 #include "Utilities/MemoryHelpers.hpp"
96 #include "Utilities/ProtocolHelpers.hpp"
97 #include "Utilities/TMPL.hpp"
98 
99 /// \cond
100 namespace Frame {
101 struct Inertial;
102 } // namespace Frame
103 namespace PUP {
104 class er;
105 } // namespace PUP
106 namespace Parallel {
107 template <typename Metavariables>
108 class CProxy_GlobalCache;
109 } // namespace Parallel
110 /// \endcond
111 
112 template <size_t Dim, typename InitialData>
113 struct EvolutionMetavars {
114  static constexpr size_t volume_dim = Dim;
115  static constexpr dg::Formulation dg_formulation =
116  dg::Formulation::StrongInertial;
117 
118  using initial_data = InitialData;
119  static_assert(
120  evolution::is_analytic_data_v<initial_data> xor
121  evolution::is_analytic_solution_v<initial_data>,
122  "initial_data must be either an analytic_data or an analytic_solution");
123 
124  using equation_of_state_type = typename initial_data::equation_of_state_type;
125 
127 
128  using temporal_id = Tags::TimeStepId;
129  static constexpr bool local_time_stepping = false;
130 
131  using initial_data_tag =
132  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
135 
136  using boundary_condition_tag = initial_data_tag;
137  using analytic_variables_tags =
138  typename system::primitive_variables_tag::tags_list;
139 
140  using equation_of_state_tag =
142 
143  using limiter = Tags::Limiter<Limiters::Minmod<
147 
148  using time_stepper_tag = Tags::TimeStepper<
149  tmpl::conditional_t<local_time_stepping, LtsTimeStepper, TimeStepper>>;
150 
151  struct factory_creation
152  : tt::ConformsTo<Options::protocols::FactoryCreation> {
153  using factory_classes = tmpl::map<
154  tmpl::pair<DenseTrigger, DenseTriggers::standard_dense_triggers>,
155  tmpl::pair<DomainCreator<volume_dim>, domain_creators<volume_dim>>,
156  tmpl::pair<
157  Event,
158  tmpl::flatten<tmpl::list<
160  dg::Events::field_observations<
161  volume_dim, Tags::Time,
162  tmpl::append<
163  typename system::variables_tag::tags_list,
164  typename system::primitive_variables_tag::tags_list>,
165  tmpl::conditional_t<
166  evolution::is_analytic_solution_v<initial_data>,
167  analytic_variables_tags, tmpl::list<>>>,
168  Events::time_events<system>>>>,
169  tmpl::pair<
171  StepChoosers::standard_step_choosers<system, false>>,
172  tmpl::pair<StepChooser<StepChooserUse::Slab>,
173  StepChoosers::standard_slab_choosers<
174  system, local_time_stepping, false>>,
175  tmpl::pair<StepController, StepControllers::standard_step_controllers>,
176  tmpl::pair<TimeSequence<double>,
177  TimeSequences::all_time_sequences<double>>,
178  tmpl::pair<TimeSequence<std::uint64_t>,
179  TimeSequences::all_time_sequences<std::uint64_t>>,
180  tmpl::pair<Trigger, tmpl::append<Triggers::logical_triggers,
182  };
183 
184  using observed_reduction_data_tags =
185  observers::collect_reduction_data_tags<tmpl::flatten<tmpl::list<
186  tmpl::at<typename factory_creation::factory_classes, Event>>>>;
187 
188  using step_actions = tmpl::flatten<tmpl::list<
191  tmpl::conditional_t<
192  local_time_stepping, tmpl::list<>,
193  tmpl::list<Actions::RecordTimeStepperData<>,
195  typename system::primitive_from_conservative>,
201  // Conservative `UpdatePrimitives` expects system to possess
202  // list of recovery schemes so we use `MutateApply` instead.
204 
205  enum class Phase {
206  Initialization,
207  InitializeTimeStepperHistory,
208  RegisterWithObserver,
209  LoadBalancing,
210  WriteCheckpoint,
211  Evolve,
212  Exit
213  };
214 
215  static std::string phase_name(Phase phase) noexcept {
216  if (phase == Phase::LoadBalancing) {
217  return "LoadBalancing";
218  }
219  ERROR(
220  "Passed phase that should not be used in input file. Integer "
221  "corresponding to phase is: "
222  << static_cast<int>(phase));
223  }
224 
225  using phase_changes =
226  tmpl::list<PhaseControl::Registrars::VisitAndReturn<EvolutionMetavars,
227  Phase::LoadBalancing>,
228  PhaseControl::Registrars::CheckpointAndExitAfterWallclock<
230 
231  using initialize_phase_change_decision_data =
233 
234  using phase_change_tags_and_combines_list =
236 
237  using dg_registration_list =
238  tmpl::list<observers::Actions::RegisterEventsWithObservers>;
239 
240  using initialization_actions = tmpl::list<
246  equation_of_state_tag>,
253  tmpl::list<hydro::Tags::SoundSpeedSquaredCompute<DataVector>>>,
255  tmpl::conditional_t<
256  evolution::is_analytic_solution_v<initial_data>,
259  Dim, initial_data_tag, analytic_variables_tags>>>,
260  tmpl::list<>>,
262  StepChoosers::step_chooser_compute_tags<EvolutionMetavars>>,
267 
268  using dg_element_array = DgElementArray<
270  tmpl::list<
271  Parallel::PhaseActions<Phase, Phase::Initialization,
272  initialization_actions>,
273 
275  Phase, Phase::InitializeTimeStepperHistory,
277 
278  Parallel::PhaseActions<Phase, Phase::RegisterWithObserver,
279  tmpl::list<dg_registration_list,
281 
283  Phase, Phase::Evolve,
288  step_actions, Actions::AdvanceTime,
290  phase_changes>>>>>;
291 
292  template <typename ParallelComponent>
293  struct registration_list {
294  using type =
296  dg_registration_list, tmpl::list<>>;
297  };
298 
299  using component_list =
300  tmpl::list<observers::Observer<EvolutionMetavars>,
302  dg_element_array>;
303 
304  using const_global_cache_tags =
305  tmpl::list<initial_data_tag, Tags::EventsAndTriggers,
307 
308  static constexpr Options::String help{
309  "Evolve the Valencia formulation of RelativisticEuler system.\n\n"};
310 
311  template <typename... Tags>
312  static Phase determine_next_phase(
314  phase_change_decision_data,
315  const Phase& current_phase,
316  const Parallel::CProxy_GlobalCache<EvolutionMetavars>&
317  cache_proxy) noexcept {
318  const auto next_phase =
319  PhaseControl::arbitrate_phase_change<phase_changes>(
320  phase_change_decision_data, current_phase,
321  *(cache_proxy.ckLocalBranch()));
322  if (next_phase.has_value()) {
323  return next_phase.value();
324  }
325  switch (current_phase) {
326  case Phase::Initialization:
327  return Phase::InitializeTimeStepperHistory;
328  case Phase::InitializeTimeStepperHistory:
329  return Phase::RegisterWithObserver;
330  case Phase::RegisterWithObserver:
331  return Phase::Evolve;
332  case Phase::Evolve:
333  return Phase::Exit;
334  case Phase::Exit:
335  ERROR(
336  "Should never call determine_next_phase with the current phase "
337  "being 'Exit'");
338  default:
339  ERROR(
340  "Unknown type of phase. Did you static_cast<Phase> to an integral "
341  "value?");
342  }
343  }
344 
345  // NOLINTNEXTLINE(google-runtime-references)
346  void pup(PUP::er& /*p*/) noexcept {}
347 };
348 
349 static const std::vector<void (*)()> charm_init_node_funcs{
350  &setup_error_handling, &setup_memory_allocation_failure_reporting,
352  &domain::creators::register_derived_with_charm,
353  &domain::creators::time_dependence::register_derived_with_charm,
354  &domain::FunctionsOfTime::register_derived_with_charm,
355  &RelativisticEuler::Valencia::BoundaryConditions::
356  register_derived_with_charm,
357  &RelativisticEuler::Valencia::BoundaryCorrections::
358  register_derived_with_charm,
359  &Parallel::register_derived_classes_with_charm<TimeStepper>,
362  &Parallel::register_factory_classes_with_charm<metavariables>};
363 
364 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:102
StepChooser< StepChooserUse::LtsStep >
Definition: StepChooser.hpp:143
std::string
PhaseControl::InitializePhaseChangeDecisionData
Initialize the Main chare's phase_change_decision_data for the option-selected PhaseChanges.
Definition: ExecutePhaseChange.hpp:169
Tags::Limiter
The global cache tag for the limiter.
Definition: Tags.hpp:42
evolution::Actions::RunEventsAndDenseTriggers
Run the events and dense triggers.
Definition: RunEventsAndDenseTriggers.hpp:43
Tags::TimeStepId
Tag for TimeStepId for the algorithm state.
Definition: Tags.hpp:33
Limiters::Actions::SendData
Send local data needed for limiting.
Definition: LimiterActions.hpp:142
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
Limiters::Minmod
A minmod-based generalized slope limiter.
Definition: Minmod.hpp:148
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
Parallel::Actions::TerminatePhase
Terminate the algorithm to proceed to the next phase.
Definition: TerminatePhase.hpp:26
PhaseControl::Tags::PhaseChangeAndTriggers
Tag for the collection of triggers that indicate synchronization points at which phase changes should...
Definition: PhaseControlTags.hpp:66
disable_openblas_multithreading
void disable_openblas_multithreading() noexcept
Disable OpenBLAS multithreading since it conflicts with Charm++ parallelism.
DgElementArray
The parallel component responsible for managing the DG elements that compose the computational domain...
Definition: DgElementArray.hpp:43
EvolutionMetavars
Definition: EvolveBurgers.hpp:103
Initialization::Actions::ConservativeSystem
Allocate variables needed for evolution of conservative systems.
Definition: ConservativeSystem.hpp:72
enable_floating_point_exceptions
void enable_floating_point_exceptions()
PhaseControl::Actions::ExecutePhaseChange
Check if any triggers are activated, and perform phase changes as needed.
Definition: ExecutePhaseChange.hpp:41
Events::Completion
Definition: Completion.hpp:15
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:37
Actions::UpdateConservatives
Compute the conservative variables from the primitive variables.
Definition: UpdateConservatives.hpp:32
Actions::ChangeSlabSize
Definition: ChangeSlabSize.hpp:106
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
RelativisticEuler::Valencia::Tags::TildeTau
The densitized energy density .
Definition: Tags.hpp:33
Event
Definition: Event.hpp:19
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:287
RelativisticEuler::Valencia::System
Definition: System.hpp:31
evolution::dg::Initialization::Mortars
Initialize mortars between elements for exchanging boundary correction terms.
Definition: Mortars.hpp:90
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:214
PhaseControl::get_phase_change_tags
tmpl::push_back< tmpl::flatten< tmpl::transform< Registration::registrants< PhaseChangeRegistrars >, detail::get_phase_change_tags_and_combines< tmpl::_1 > >>, TagsAndCombines::UsePhaseChangeArbitration > get_phase_change_tags
Metafunction for determining the merged collection of tags in phase_change_tags_and_combines_lists fr...
Definition: PhaseControlTags.hpp:114
Tags::AnalyticSolution
Definition: Tags.hpp:58
Triggers::time_triggers
tmpl::list< NearTimes, SlabCompares, Slabs, TimeCompares, Times > time_triggers
Definition: TimeTriggers.hpp:17
cstdint
evolution::Actions::InitializeRunEventsAndDenseTriggers
Definition: RunEventsAndDenseTriggers.hpp:132
tuples::TaggedTuple< Tags... >
Limiters::Actions::Limit
Receive limiter data from neighbors, then apply limiter.
Definition: LimiterActions.hpp:71
Trigger
Definition: Trigger.hpp:17
StepController.hpp
Tags::Time
Tag for the current time as a double.
Definition: Tags.hpp:73
RelativisticEuler::Valencia::Tags::TildeS
The densitized momentum density .
Definition: Tags.hpp:39
AdvanceTime.hpp
SelfStart::self_start_procedure
tmpl::flatten< tmpl::list< SelfStart::Actions::Initialize< System >, ::Actions::Label< detail::PhaseStart >, SelfStart::Actions::CheckForCompletion< detail::PhaseEnd, System >, ::Actions::AdvanceTime, SelfStart::Actions::CheckForOrderIncrease, StepActions, ::Actions::Goto< detail::PhaseStart >, ::Actions::Label< detail::PhaseEnd >, SelfStart::Actions::Cleanup, ::Actions::AdvanceTime, Parallel::Actions::TerminatePhase > > self_start_procedure
Definition: SelfStartActions.hpp:471
Tags::AnalyticData
The analytic data, with the type of the analytic data set as the template parameter.
Definition: Tags.hpp:43
Tags::EventsAndTriggers
Definition: Tags.hpp:51
PhaseChange
PhaseChange objects determine the storage types and logic for moving between phases based on runtime ...
Definition: PhaseChange.hpp:141
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:214
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Frame
Definition: IndexType.hpp:36
Actions::UpdateU
Perform variable updates for one substep.
Definition: UpdateU.hpp:96
evolution::dg::Actions::ApplyBoundaryCorrections
Computes the boundary corrections and lifts them to the volume.
Definition: ApplyBoundaryCorrections.hpp:105
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:82
UpdateU.hpp
std::conditional_t
Parallel::register_derived_classes_with_charm
void register_derived_classes_with_charm() noexcept
Register derived classes of the Base class.
Definition: RegisterDerivedClassesWithCharm.hpp:35
Blas.hpp
dg::Formulation
Formulation
The DG formulation to use.
Definition: Formulation.hpp:34
tt::ConformsTo
Indicate a class conforms to the Protocol.
Definition: ProtocolHelpers.hpp:22
Parallel
Functionality for parallelization.
Definition: ElementReceiveInterpPoints.hpp:13
VariableFixing::FixToAtmosphere
Fix the primitive variables to an atmosphere in low density regions.
Definition: FixToAtmosphere.hpp:65
RelativisticEuler::Valencia::FixConservatives
Fix conservative variables using the method proposed in F. Foucart's PhD thesis (Cornell)
Definition: FixConservatives.hpp:53
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13