Explicit steppers#
Header: <pressio/ode_steppers_explicit.hpp>
Public namespace: pressio::ode
Scope#
A pressio “explicit stepper” is an abstraction representing “how” to take a step when applying an explicit scheme to initial value problems expressable in the following form
or with a mass matrix:
where \(y\) is the state, \(f\) is the right hand side (RHS), \(t\) is the independent variable, and \(M\) is the mass matrix. Note that both the right hand side and the mass matrix potentially depend on the state and the independent variable. We adopt the typical notation \(t\) for the independent variable but this does NOT necessarily mean that it refers to time. The independent variable can represent something else.
Recall the definition
Explicit methods calculate the next state using the current state and potentially previous ones.
API#
namespace pressio{ namespace ode{
template<
class SystemType,
std::enable_if_t<
RealValuedOdeSystem<mpl::remove_cvref_t<SystemType>>::value,
int > = 0
>
auto create_explicit_stepper(StepScheme schemeName, // (1)
SystemType && odeSystem)
{
using sys_type = mpl::remove_cvref_t<SystemType>;
using ind_var_type = typename sys_type::independent_variable_type;
using state_type = typename sys_type::state_type;
using rhs_type = typename sys_type::rhs_type;
/* IMPORTANT: use "SystemType" as template arg because that it the
right type carrying how we store the system and NOT SystemType &&
for the following reason: when user passes a non-temporary object,
SystemType is deduced to be a reference, so the concrete stepper class
state_type, ind_var_type, SystemType, rhs_type>;
return impl::create_explicit_stepper<impl_type>
(schemeName, std::forward<SystemType>(odeSystem));
state_type, ind_var_type, SystemType, rhs_type>;
//
// auxiliary scheme-specific functions
//
template<class ...Args>
auto create_forward_euler_stepper(Args && ...args){
return create_explicit_stepper(StepScheme::ForwardEuler,
std::forward<Args>(args)...);
}
template<class ...Args>
auto create_rk4_stepper(Args && ...args){
return create_explicit_stepper(StepScheme::RungeKutta4,
std::forward<Args>(args)...);
}
template<class ...Args>
auto create_ab2_stepper(Args && ...args){
(StepScheme::SSPRungeKutta3, std::forward<Args>(args)...);
}
Parameters#
|
the target stepping scheme |
|
problem instance |
Constraints#
Concepts are documented here.
Note: constraints are enforced via proper C++20 concepts when PRESSIO_ENABLE_CXX20
is enabled,
otherwise via SFINAE and static asserts.
Preconditions#
schemeName
must be one ofpressio::ode::StepScheme::{ForwardEuler, RungeKutta4, AdamsBashforth2, SSPRungeKutta3}
.if
odeSystem
does not bind to a temporary object, it must bind to an lvalue object whose lifetime is longer that that of the instantiated stepper, i.e., it is destructed after the stepper goes out of scope
Examples#
Full Demos