SpECTRE  v2024.09.29
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
ImexTimeStepper Class Referenceabstract

#include <ImexTimeStepper.hpp>

Public Types

using provided_time_stepper_interfaces = implementation defined
 
- Public Types inherited from TimeStepper
using provided_time_stepper_interfaces = implementation defined
 

Public Member Functions

 WRAPPED_PUPable_abstract (ImexTimeStepper)
 
virtual size_t imex_order () const =0
 Convergence order of the integrator when used in IMEX mode. More...
 
template<typename Vars >
void add_inhomogeneous_implicit_terms (const gsl::not_null< Vars * > u, const TimeSteppers::History< Vars > &implicit_history, const TimeDelta &time_step) const
 Add the change for the current implicit substep, Yn,inhomogeneous, to u, given a past history of the implicit derivatives. More...
 
template<typename Vars >
double implicit_weight (const TimeSteppers::History< Vars > &implicit_history, const TimeDelta &time_step) const
 The coefficient wn of the implicit derivative for the current substep. For a Runge-Kutta method, this is the coefficient on the diagonal of the Butcher tableau. More...
 
- Public Member Functions inherited from TimeStepper
 WRAPPED_PUPable_abstract (TimeStepper)
 
template<typename Vars >
void update_u (const gsl::not_null< Vars * > u, const TimeSteppers::History< Vars > &history, const TimeDelta &time_step) const
 Set u to the value at the end of the current substep. More...
 
template<typename Vars >
std::optional< StepperErrorEstimateupdate_u (const gsl::not_null< Vars * > u, const TimeSteppers::History< Vars > &history, const TimeDelta &time_step, const std::optional< StepperErrorTolerances > &tolerances) const
 Set u to the value at the end of the current substep; report the error measure when available. More...
 
template<typename Vars >
void clean_history (const gsl::not_null< TimeSteppers::History< Vars > * > history) const
 Remove old entries from the history. More...
 
template<typename Vars >
bool dense_update_u (const gsl::not_null< Vars * > u, const TimeSteppers::History< Vars > &history, const double time) const
 Compute the solution value at a time between steps. To evaluate at a time within a given step, call this method at the start of the step containing the time. The function returns true on success, otherwise the call should be retried after the next substep. More...
 
virtual size_t order () const =0
 The convergence order of the stepper. More...
 
virtual uint64_t number_of_substeps () const =0
 Number of substeps in this TimeStepper. More...
 
virtual uint64_t number_of_substeps_for_error () const =0
 Number of substeps in this TimeStepper when providing an error measure for adaptive time-stepping. More...
 
virtual size_t number_of_past_steps () const =0
 Number of past time steps needed for multi-step method. More...
 
virtual double stable_step () const =0
 Rough estimate of the maximum step size this method can take stably as a multiple of the step for Euler's method. More...
 
virtual bool monotonic () const =0
 Whether computational and temporal orderings of operations match. More...
 
virtual TimeStepId next_time_id (const TimeStepId &current_id, const TimeDelta &time_step) const =0
 The TimeStepId after the current substep. More...
 
virtual TimeStepId next_time_id_for_error (const TimeStepId &current_id, const TimeDelta &time_step) const =0
 The TimeStepId after the current substep when providing an error measure for adaptive time-stepping. More...
 
template<typename Vars >
bool can_change_step_size (const TimeStepId &time_id, const TimeSteppers::History< Vars > &history) const
 Whether a change in the step size is allowed before taking a step. Step sizes can never be changed on a substep. More...
 

Static Public Attributes

static constexpr bool imex = true
 
- Static Public Attributes inherited from TimeStepper
static constexpr bool local_time_stepping = false
 
static constexpr bool imex = false
 

Detailed Description

Base class for TimeSteppers with IMEX support, derived from TimeStepper.

All supported time-stepping algorithms (both implicit and explicit) consist of substeps that add linear combinations of derivative values. For implicit substeps, it is convenient to split out the contribution of the final implicit term from contributions from the history. We therefore write an implicit substep as

(1)Yn+1=Yn,explicit+Yn,inhomogeneous+wnS(Yn+1)

Here Yn,explicit is the value of the evolved variables before the implicit substep is applied, Yn,inhomogeneous is the contribution of the past values from the implicit derivative history, and S() is the implicit portion of the right-hand-side (generally source terms for PDEs). We call wn the implicit weight. This split form is convenient for most consumers of this class, so we present methods for calculating Yn,inhomogeneous and wn individually instead of a method to perform a full step update.

History cleanup is the same for the explicit and implicit parts, and should be done together.

Dense output formulae are the same for the explicit and implicit parts of any conservative IMEX stepper. To evaluate dense output, call dense_update_u with the implicit history after a successful call to dense_update_u with the explicit history.

Several of the member functions of this class are templated and perform type erasure before forwarding their arguments to the derived classes. This is implemented using the macros IMEX_TIME_STEPPER_DECLARE_OVERLOADS, which must be placed in a private section of the class body, and IMEX_TIME_STEPPER_DEFINE_OVERLOADS(derived_class), which must be placed in the cpp file.

Member Function Documentation

◆ add_inhomogeneous_implicit_terms()

template<typename Vars >
void ImexTimeStepper::add_inhomogeneous_implicit_terms ( const gsl::not_null< Vars * >  u,
const TimeSteppers::History< Vars > &  implicit_history,
const TimeDelta time_step 
) const
inline

Add the change for the current implicit substep, Yn,inhomogeneous, to u, given a past history of the implicit derivatives.

Derived classes must implement this as a function with signature

template <typename T>
void add_inhomogeneous_implicit_terms_impl(
const ConstUntypedHistory<T>& implicit_history,
const TimeDelta& time_step) const;
Represents an interval of time within a single slab.
Definition: Time.hpp:88
Require a pointer to not be a nullptr
Definition: Gsl.hpp:198
Note
Unlike the update_u methods, which overwrite their result arguments, this function adds the result to the existing value.

◆ imex_order()

virtual size_t ImexTimeStepper::imex_order ( ) const
pure virtual

Convergence order of the integrator when used in IMEX mode.

Implemented in TimeSteppers::Heun2, TimeSteppers::Rk3Kennedy, TimeSteppers::Rk3Pareschi, and TimeSteppers::Rk4Kennedy.

◆ implicit_weight()

template<typename Vars >
double ImexTimeStepper::implicit_weight ( const TimeSteppers::History< Vars > &  implicit_history,
const TimeDelta time_step 
) const
inline

The coefficient wn of the implicit derivative for the current substep. For a Runge-Kutta method, this is the coefficient on the diagonal of the Butcher tableau.

Derived classes must implement this as a function with signature

template <typename T>
double implicit_weight_impl(
const ConstUntypedHistory<T>& implicit_history,
const TimeDelta& time_step) const;

The documentation for this class was generated from the following file: