EvolveValenciaDivClean.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <vector>
7 
8 #include "Domain/Creators/RegisterDerivedWithCharm.hpp"
9 #include "Domain/Tags.hpp"
11 #include "Evolution/Actions/ComputeTimeDerivative.hpp" // IWYU pragma: keep
12 #include "Evolution/Actions/ComputeVolumeFluxes.hpp"
13 #include "Evolution/Actions/ComputeVolumeSources.hpp"
14 #include "Evolution/Conservative/UpdateConservatives.hpp"
15 #include "Evolution/Conservative/UpdatePrimitives.hpp"
16 #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
18 #include "Evolution/DiscontinuousGalerkin/SlopeLimiters/Minmod.hpp"
19 #include "Evolution/DiscontinuousGalerkin/SlopeLimiters/Tags.hpp"
20 #include "Evolution/Systems/GrMhd/ValenciaDivClean/FixConservatives.hpp"
21 #include "Evolution/Systems/GrMhd/ValenciaDivClean/Initialize.hpp"
22 #include "Evolution/Systems/GrMhd/ValenciaDivClean/NewmanHamlin.hpp"
23 #include "Evolution/Systems/GrMhd/ValenciaDivClean/Observe.hpp"
24 #include "Evolution/Systems/GrMhd/ValenciaDivClean/PalenzuelaEtAl.hpp"
25 #include "Evolution/Systems/GrMhd/ValenciaDivClean/System.hpp"
26 #include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
27 #include "Evolution/VariableFixing/Actions.hpp"
28 #include "Evolution/VariableFixing/FixToAtmosphere.hpp"
29 #include "Evolution/VariableFixing/Tags.hpp"
30 #include "IO/Observer/Actions.hpp"
31 #include "IO/Observer/Helpers.hpp"
32 #include "IO/Observer/ObserverComponent.hpp"
33 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyBoundaryFluxesLocalTimeStepping.hpp"
34 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyFluxes.hpp"
36 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp" // IWYU pragma: keep
37 #include "NumericalAlgorithms/DiscontinuousGalerkin/NumericalFluxes/LocalLaxFriedrichs.hpp"
38 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
39 #include "Options/Options.hpp"
40 #include "Parallel/GotoAction.hpp"
41 #include "Parallel/InitializationFunctions.hpp"
43 #include "PointwiseFunctions/AnalyticSolutions/GrMhd/SmoothFlow.hpp"
44 #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/FishboneMoncriefDisk.hpp"
45 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
46 #include "PointwiseFunctions/Hydro/Tags.hpp"
48 #include "Time/Actions/ChangeStepSize.hpp"
50 #include "Time/Actions/RecordTimeStepperData.hpp"
51 #include "Time/Actions/SelfStartActions.hpp" // IWYU pragma: keep
52 #include "Time/Actions/UpdateU.hpp"
53 #include "Time/StepChoosers/Cfl.hpp"
54 #include "Time/StepChoosers/Constant.hpp"
55 #include "Time/StepChoosers/Increase.hpp"
56 #include "Time/StepChoosers/StepChooser.hpp"
58 #include "Time/Tags.hpp"
59 #include "Time/TimeSteppers/TimeStepper.hpp"
60 #include "Utilities/Functional.hpp"
61 #include "Utilities/TMPL.hpp"
62 
63 /// \cond
64 namespace Frame {
65 struct Inertial;
66 } // namespace Frame
67 namespace Parallel {
68 template <typename Metavariables>
69 class CProxy_ConstGlobalCache;
70 } // namespace Parallel
71 /// \endcond
72 
73 struct EvolutionMetavars {
74  // To switch which analytic solution is evolved you only need to change the
75  // line `using analytic_solution = ...;` and include the header file for the
76  // solution.
77  // using analytic_solution = grmhd::Solutions::SmoothFlow;
79 
81  typename analytic_solution::equation_of_state_type>;
82  static constexpr size_t thermodynamic_dim = system::thermodynamic_dim;
83  using temporal_id = Tags::TimeId;
84  static constexpr bool local_time_stepping = false;
85  using analytic_solution_tag = OptionTags::AnalyticSolution<analytic_solution>;
86  using boundary_condition_tag = analytic_solution_tag;
87  using analytic_variables_tags =
88  typename system::primitive_variables_tag::tags_list;
89  using equation_of_state_tag = hydro::Tags::EquationOfState<
90  typename analytic_solution_tag::type::equation_of_state_type>;
91  using normal_dot_numerical_flux = OptionTags::NumericalFluxParams<
93  // Do not limit the divergence-cleaning field Phi
94  using limiter = OptionTags::SlopeLimiterParams<SlopeLimiters::Minmod<
99  using step_choosers =
100  tmpl::list<StepChoosers::Registrars::Cfl<3, Frame::Inertial>,
103  using ordered_list_of_primitive_recovery_schemes = tmpl::list<
106 
107  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
108  tmpl::list<grmhd::ValenciaDivClean::Actions::Observe>>;
109 
110  using compute_rhs = tmpl::flatten<tmpl::list<
116  tmpl::conditional_t<local_time_stepping, tmpl::list<>,
119 
120  using update_variables = tmpl::flatten<tmpl::list<
121  tmpl::conditional_t<local_time_stepping,
123  tmpl::list<>>,
128 
129  struct EvolvePhaseStart;
130  using component_list = tmpl::list<
135  tmpl::flatten<tmpl::list<
142  VariableFixing::FixToAtmosphere<thermodynamic_dim>>,
143  Actions::UpdateConservatives,
145  tmpl::conditional_t<local_time_stepping,
147  tmpl::list<>>,
148  compute_rhs, update_variables,
150 
151  using const_global_cache_tag_list =
152  tmpl::list<analytic_solution_tag,
153  OptionTags::TypedTimeStepper<tmpl::conditional_t<
154  local_time_stepping, LtsTimeStepper, TimeStepper>>,
156 
157  using domain_creator_tag = OptionTags::DomainCreator<3, Frame::Inertial>;
158 
159  static constexpr OptionString help{
160  "Evolve the Valencia formulation of the GRMHD system with divergence "
161  "cleaning.\n\n"};
162 
163  enum class Phase { Initialization, RegisterWithObserver, Evolve, Exit };
164 
165  static Phase determine_next_phase(
166  const Phase& current_phase,
167  const Parallel::CProxy_ConstGlobalCache<
168  EvolutionMetavars>& /*cache_proxy*/) noexcept {
169  switch (current_phase) {
170  case Phase::Initialization:
171  return Phase::RegisterWithObserver;
172  case Phase::RegisterWithObserver:
173  return Phase::Evolve;
174  case Phase::Evolve:
175  return Phase::Exit;
176  case Phase::Exit:
177  ERROR(
178  "Should never call determine_next_phase with the current phase "
179  "being 'Exit'");
180  default:
181  ERROR(
182  "Unknown type of phase. Did you static_cast<Phase> an integral "
183  "value?");
184  }
185  }
186 };
187 
188 static const std::vector<void (*)()> charm_init_node_funcs{
189  &setup_error_handling, &domain::creators::register_derived_with_charm,
190  &Parallel::register_derived_classes_with_charm<
192  &Parallel::register_derived_classes_with_charm<StepController>,
193  &Parallel::register_derived_classes_with_charm<TimeStepper>};
194 
195 static const std::vector<void (*)()> charm_init_proc_funcs{
The global cache tag that retrieves the parameters for the slope limiter from the input file...
Definition: Tags.hpp:15
Terminate after reaching a specified time.
Definition: FinalTime.hpp:42
Functions for serializing factory-created classes.
Definition: DgElementArray.hpp:39
Adjust the step size for local time stepping.
Definition: ChangeStepSize.hpp:45
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:35
Fix the primitive variables to an atmosphere in low density regions.
Definition: FixToAtmosphere.hpp:47
Items for initializing the DataBoxes of parallel components.
Definition: ConservativeSystem.hpp:21
Perform variable updates for one substep.
Definition: UpdateU.hpp:47
T system(T... args)
Compute the primitive variables from the conservative variables.
Definition: UpdatePrimitives.hpp:36
Defines action AdvanceTime.
Receive limiter data from neighbors, then apply limiter.
Definition: LimiterActions.hpp:68
Compute the primitive variables from the conservative variables using the scheme of Newman and Hamlin...
Definition: NewmanHamlin.hpp:50
Labels a location in the action list that can be jumped to using Goto.
Definition: GotoAction.hpp:37
The analytic solution, with the type of the analytic solution set as the template parameter...
Definition: Tags.hpp:22
Defines base class StepController.
Abstract base class for TimeSteppers.
Definition: TimeStepper.hpp:44
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:59
Defines classes and functions for making classes creatable from input files.
Defines actions SendDataForFluxes and ReceiveDataForFluxes.
Adjust variables with a variable fixer.
Definition: Actions.hpp:43
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:55
Base class for TimeSteppers with local time-stepping support, derived from TimeStepper.
Definition: TimeStepper.hpp:105
Compute the conservative variables from the primitive variables.
Definition: UpdateConservatives.hpp:33
Compute the primitive variables from the conservative variables using the scheme of Palenzuela et al...
Definition: PalenzuelaEtAl.hpp:51
Defines action FinalTime.
Compute the local Lax-Friedrichs numerical flux.
Definition: LocalLaxFriedrichs.hpp:43
StepChoosers suggest upper bounds on step sizes. Concrete StepChoosers should define operator() retur...
Definition: StepChooser.hpp:45
The densitized energy density .
Definition: Tags.hpp:50
The constraint damping parameter.
Definition: Tags.hpp:18
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:27
The densitized momentum density .
Definition: Tags.hpp:57
The group parallel component that is responsible for reducing data to be observed.
Definition: ObserverComponent.hpp:25
Compute the volume fluxes of the evolved variables.
Definition: ComputeVolumeFluxes.hpp:40
Temporary action for observing volume and reduction data.
Definition: Observe.hpp:38
Definition: EvolveBurgers.hpp:61
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 densitized magnetic field .
Definition: Tags.hpp:64
Jumps to a Label.
Definition: GotoAction.hpp:68
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
Perform the boundary part of the update of the variables for local time stepping. ...
Definition: ApplyBoundaryFluxesLocalTimeStepping.hpp:55
Functions to enable/disable termination on floating point exceptions.
Records the variables and their time derivatives in the time stepper history.
Definition: RecordTimeStepperData.hpp:48
The densitized rest-mass density .
Definition: Tags.hpp:44
Fluid disk orbiting a Kerr black hole.
Definition: FishboneMoncriefDisk.hpp:151
The global cache tag that retrieves the parameters for the numerical flux from the input file...
Definition: Tags.hpp:59
tmpl::flatten< tmpl::list< SelfStart::Actions::Initialize, ::Actions::Label< detail::PhaseStart >, SelfStart::Actions::CheckForCompletion< detail::PhaseEnd >, ::Actions::AdvanceTime, SelfStart::Actions::CheckForOrderIncrease, ComputeRhs, SelfStart::Actions::StartNextOrderIfReady< detail::PhaseStart >, UpdateVariables, ::Actions::Goto< detail::PhaseStart >, ::Actions::Label< detail::PhaseEnd >, SelfStart::Actions::Cleanup > > self_start_procedure
The list of actions required to self-start an integrator.
Definition: SelfStartActions.hpp:454
Defines action UpdateU.
Wraps the template metaprogramming library used (brigand)
Advance time one substep.
Definition: AdvanceTime.hpp:45
Packages data on external boundaries for calculating numerical flux. Computes contributions on the in...
Definition: ImposeBoundaryConditions.hpp:78
Defines actions ApplyLimiter and SendDataForLimiter.
The TimeStepper, specifying a (base) type. Can be retrieved through OptionTags::TimeStepper.
Definition: Tags.hpp:113
Defines tags related to domain quantities.
Compute the volume sources of the evolved variables.
Definition: ComputeVolumeSources.hpp:35
Definition: System.hpp:41
Compute element boundary contributions to the temporal step of the variables.
Definition: ApplyFluxes.hpp:67
Send local data needed for limiting.
Definition: LimiterActions.hpp:155
The input file tag for the DomainCreator to use.
Definition: Tags.hpp:44
Tag for TimeId for the algorithm state.
Definition: Tags.hpp:35
Defines tags related to Time quantities.
The equation of state.
Definition: Tags.hpp:57