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

(1)#\[ \frac{d \boldsymbol{y}}{dt} = \boldsymbol{f}(\boldsymbol{y},t; ...), \qquad y(t_0) = y_0\]

or with a mass matrix:

(2)#\[ M(\boldsymbol{y}, t, ...) \frac{d \boldsymbol{y}}{dt} = \boldsymbol{f}(\boldsymbol{y},t; ...), \qquad y(t_0) = y_0\]

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{

#if defined PRESSIO_ENABLE_CXX20
template<class SystemType>
  requires RealValuedOdeSystem<mpl::remove_cvref_t<SystemType>>
  && (Traits<typename mpl::remove_cvref_t<SystemType>::state_type>::rank == 1)
  && (Traits<typename mpl::remove_cvref_t<SystemType>::rhs_type>::rank == 1)
  && requires(      typename mpl::remove_cvref_t<SystemType>::state_type & s1,
	      const typename mpl::remove_cvref_t<SystemType>::state_type & s2,
	      const typename mpl::remove_cvref_t<SystemType>::rhs_type & f1,
	      const typename mpl::remove_cvref_t<SystemType>::rhs_type & f2,
	      const typename mpl::remove_cvref_t<SystemType>::rhs_type & f3,
	      const typename mpl::remove_cvref_t<SystemType>::rhs_type & f4,
	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > alpha)
  {
    { ::pressio::ops::deep_copy(s1, s2) };
    { ::pressio::ops::update(s1, alpha, s2, alpha, f1, alpha) };
    { ::pressio::ops::update(s1, alpha, f1, alpha) };
    { ::pressio::ops::update(s1, alpha, f1, alpha, f2, alpha) };
    { ::pressio::ops::update(s1, alpha, f1, alpha, f2, alpha, f3, alpha, f4, alpha) };
  }
#endif
auto create_explicit_stepper(StepScheme schemeName,                     // (1)
			     SystemType && odeSystem)

#if defined PRESSIO_ENABLE_CXX20
template<class SystemType>
  requires RealValuedOdeSystemFusingMassMatrixAndRhs<mpl::remove_cvref_t<SystemType>>
  && (Traits<typename mpl::remove_cvref_t<SystemType>::state_type>::rank == 1)
  && (Traits<typename mpl::remove_cvref_t<SystemType>::rhs_type>::rank == 1)
  && (Traits<typename mpl::remove_cvref_t<SystemType>::mass_matrix_type>::rank == 2)
  && requires(      typename mpl::remove_cvref_t<SystemType>::state_type & s1,
	      const typename mpl::remove_cvref_t<SystemType>::state_type & s2,
	      const typename mpl::remove_cvref_t<SystemType>::state_type & s3,
	      const typename mpl::remove_cvref_t<SystemType>::state_type & s4,
	      const typename mpl::remove_cvref_t<SystemType>::state_type & s5,
	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > alpha)
  {
    { ::pressio::ops::deep_copy(s1, s2) };
    { ::pressio::ops::update(s1, alpha, s2, alpha) };
    { ::pressio::ops::update(s1, alpha, s2, alpha, s3, alpha) };
    { ::pressio::ops::update(s1, alpha, s2, alpha, s3, alpha, s4, alpha, s5, alpha) };
  }
#endif
auto create_explicit_stepper(StepScheme schemeName,                     // (2)
			     SystemType && odeSystem)

Parameters#

schemeName

the target stepping scheme

odeSystem

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 of pressio::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#