EvolveScalarWave.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 "Domain/Creators/RegisterDerivedWithCharm.hpp"
10 #include "Domain/Tags.hpp"
11 #include "ErrorHandling/Error.hpp"
13 #include "Evolution/Actions/ComputeTimeDerivative.hpp" // IWYU pragma: keep
14 #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp" // IWYU pragma: keep
15 #include "Evolution/DiscontinuousGalerkin/InitializeElement.hpp" // IWYU pragma: keep
16 #include "Evolution/Systems/ScalarWave/Equations.hpp" // IWYU pragma: keep // for UpwindFlux
17 #include "Evolution/Systems/ScalarWave/Observe.hpp" // IWYU pragma: keep
19 #include "IO/Observer/Actions.hpp" // IWYU pragma: keep
20 #include "IO/Observer/Helpers.hpp" // IWYU pragma: keep
21 #include "IO/Observer/ObserverComponent.hpp" // IWYU pragma: keep
22 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyBoundaryFluxesLocalTimeStepping.hpp" // IWYU pragma: keep
23 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyFluxes.hpp" // IWYU pragma: keep
24 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ComputeNonconservativeBoundaryFluxes.hpp" // IWYU pragma: keep
26 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp" // IWYU pragma: keep
27 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
28 #include "Options/Options.hpp"
29 #include "Parallel/GotoAction.hpp" // IWYU pragma: keep
30 #include "Parallel/InitializationFunctions.hpp"
31 #include "Parallel/Reduction.hpp"
33 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
36 #include "Time/Actions/AdvanceTime.hpp" // IWYU pragma: keep
37 #include "Time/Actions/ChangeStepSize.hpp" // IWYU pragma: keep
38 #include "Time/Actions/FinalTime.hpp" // IWYU pragma: keep
39 #include "Time/Actions/RecordTimeStepperData.hpp" // IWYU pragma: keep
40 #include "Time/Actions/SelfStartActions.hpp" // IWYU pragma: keep
41 #include "Time/Actions/UpdateU.hpp" // IWYU pragma: keep
42 #include "Time/StepChoosers/Cfl.hpp" // IWYU pragma: keep
43 #include "Time/StepChoosers/Constant.hpp" // IWYU pragma: keep
44 #include "Time/StepChoosers/Increase.hpp" // IWYU pragma: keep
45 #include "Time/StepChoosers/StepChooser.hpp"
47 #include "Time/Tags.hpp"
48 #include "Time/TimeSteppers/TimeStepper.hpp"
49 #include "Utilities/Functional.hpp"
50 #include "Utilities/TMPL.hpp"
51 
52 /// \cond
53 namespace Frame {
54 // IWYU pragma: no_forward_declare MathFunction
55 struct Inertial;
56 } // namespace Frame
57 namespace Parallel {
58 template <typename Metavariables>
59 class CProxy_ConstGlobalCache;
60 } // namespace Parallel
61 /// \endcond
62 
63 template <size_t Dim>
64 struct EvolutionMetavars {
65  // Customization/"input options" to simulation
67  using temporal_id = Tags::TimeId;
68  static constexpr bool local_time_stepping = true;
69  using analytic_solution_tag =
71  using boundary_condition_tag = analytic_solution_tag;
72  using normal_dot_numerical_flux =
74  // A tmpl::list of tags to be added to the ConstGlobalCache by the
75  // metavariables
76  using const_global_cache_tag_list =
77  tmpl::list<analytic_solution_tag,
78  OptionTags::TypedTimeStepper<tmpl::conditional_t<
79  local_time_stepping, LtsTimeStepper, TimeStepper>>>;
80  using domain_creator_tag = OptionTags::DomainCreator<Dim, Frame::Inertial>;
81 
82  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
83  tmpl::list<ScalarWave::Actions::Observe>>;
84 
85  using step_choosers =
86  tmpl::list<StepChoosers::Registrars::Cfl<Dim, Frame::Inertial>,
89 
90  using compute_rhs = tmpl::flatten<tmpl::list<
99  tmpl::conditional_t<local_time_stepping, tmpl::list<>,
102  using update_variables = tmpl::flatten<tmpl::list<
103  tmpl::conditional_t<local_time_stepping,
105  tmpl::list<>>,
107 
108  struct EvolvePhaseStart;
109  using component_list = tmpl::list<
114  tmpl::flatten<tmpl::list<
118  tmpl::conditional_t<local_time_stepping,
120  tmpl::list<>>,
121  compute_rhs, update_variables,
123 
124  static constexpr OptionString help{
125  "Evolve a Scalar Wave in Dim spatial dimension.\n\n"
126  "The analytic solution is: PlaneWave\n"
127  "The numerical flux is: UpwindFlux\n"};
128 
129  enum class Phase {
131  RegisterWithObserver,
132  Evolve,
133  Exit
134  };
135 
136  static Phase determine_next_phase(
137  const Phase& current_phase,
138  const Parallel::CProxy_ConstGlobalCache<
139  EvolutionMetavars>& /*cache_proxy*/) noexcept {
140  switch (current_phase) {
141  case Phase::Initialization:
142  return Phase::RegisterWithObserver;
143  case Phase::RegisterWithObserver:
144  return Phase::Evolve;
145  case Phase::Evolve:
146  return Phase::Exit;
147  case Phase::Exit:
148  ERROR(
149  "Should never call determine_next_phase with the current phase "
150  "being 'Exit'");
151  default:
152  ERROR(
153  "Unknown type of phase. Did you static_cast<Phase> an integral "
154  "value?");
155  }
156  }
157 };
158 
159 static const std::vector<void (*)()> charm_init_node_funcs{
160  &setup_error_handling,
161  &domain::creators::register_derived_with_charm,
162  &Parallel::register_derived_classes_with_charm<MathFunction<1>>,
163  &Parallel::register_derived_classes_with_charm<
165  &Parallel::register_derived_classes_with_charm<StepController>,
166  &Parallel::register_derived_classes_with_charm<TimeStepper>};
167 static const std::vector<void (*)()> charm_init_proc_funcs{
Terminate after reaching a specified time.
Definition: FinalTime.hpp:42
Functions for serializing factory-created classes.
The set of directions to neighboring Elements.
Definition: Tags.hpp:145
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
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)
Defines WaveEquationSolutions::PlaneWave.
Defines action AdvanceTime.
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.
The set of directions which correspond to external boundaries. Used for representing data on the inte...
Definition: Tags.hpp:163
Defines actions SendDataForFluxes and ReceiveDataForFluxes.
Temporary action for observing volume and reduction data.
Definition: Observe.hpp:41
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
Defines action FinalTime.
StepChoosers suggest upper bounds on step sizes. Concrete StepChoosers should define operator() retur...
Definition: StepChooser.hpp:45
Initialize a dG element with analytic initial data.
Definition: InitializeElement.hpp:96
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:27
The group parallel component that is responsible for reducing data to be observed.
Definition: ObserverComponent.hpp:25
Defines base-class MathFunction.
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
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
Defines class ScalarWaveSystem.
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 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
The TimeStepper, specifying a (base) type. Can be retrieved through OptionTags::TimeStepper.
Definition: Tags.hpp:113
Defines tags related to domain quantities.
Compute element boundary contributions to the temporal step of the variables.
Definition: ApplyFluxes.hpp:67
Defines macro ERROR.
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.
Definition: System.hpp:28
Compute on the boundaries for a non-conservative system.
Definition: ComputeNonconservativeBoundaryFluxes.hpp:45