Standard Use#

Header: <pressio/ode_steppers_implicit.hpp>

Public namespace: pressio::ode

Scope#

This page describes the “standard use” of an “implicit stepper” for systems expressed either as

(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\]

What do we mean by standard use?#

We refer to a use case as “standard” when you define your problem via objects that are responsible of computing f, its jacobian df/dy and, if applicable, the mass matrix M, and you want to do implicit stepping for it.

API#

namespace pressio{ namespace ode{

#if defined PRESSIO_ENABLE_CXX20
template<class SystemType>
  requires RealValuedOdeSystemFusingRhsAndJacobian<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>::jacobian_type>::rank == 2)
  && requires(      typename mpl::remove_cvref_t<SystemType>::state_type    & s,
	            typename mpl::remove_cvref_t<SystemType>::rhs_type      & r,
	            typename mpl::remove_cvref_t<SystemType>::jacobian_type & J,
	      const 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>::rhs_type   & r1,
	      const typename mpl::remove_cvref_t<SystemType>::rhs_type   & r2,
	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > a,
	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > b,
	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > c,
  	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > d,
	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > e)
  {
    { ::pressio::ops::deep_copy(s, s1) };
    { ::pressio::ops::update(r, a, s1, b, s2, c) };
    { ::pressio::ops::update(r, a, s1, b, s2, c, s3, d) };
    { ::pressio::ops::update(r, a, s1, b, s2, c, r1, d, r2, e) };
    { ::pressio::ops::scale(J, a) };
    { ::pressio::ops::add_to_diagonal(J, a) };
  }
#endif
auto create_implicit_stepper(StepScheme schemeName,                     // (1)
			     SystemType && system)

#if defined PRESSIO_ENABLE_CXX20
template<class SystemType>
  requires RealValuedCompleteOdeSystem<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>::jacobian_type>::rank    == 2)
  && (Traits<typename mpl::remove_cvref_t<SystemType>::mass_matrix_type>::rank == 2)
  && requires(      typename mpl::remove_cvref_t<SystemType>::state_type       & s,
	            typename mpl::remove_cvref_t<SystemType>::rhs_type         & r,
	            typename mpl::remove_cvref_t<SystemType>::jacobian_type    & J,
	      const typename mpl::remove_cvref_t<SystemType>::mass_matrix_type & M,
	      const 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>::rhs_type & r1,
	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > a,
	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > b,
	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > c,
	      ode::scalar_of_t< mpl::remove_cvref_t<SystemType> > d)
  {
    { ::pressio::ops::deep_copy(s, s1) };

    // bdf1 and bdf2
    { ::pressio::ops::update(s, a, s1, b, s2, c) };
    { ::pressio::ops::update(s, a, s1, b, s2, c, s3, d) };
    { ::pressio::ops::product(::pressio::nontranspose(), a, M, s1, b, r) };
    { ::pressio::ops::update(r, a, r1, b) };
    { ::pressio::ops::update(J, a, M, b)  };
  }
#endif
auto create_implicit_stepper(StepScheme schemeName,                     // (2)
			     SystemType && system)

}} // end namespace pressio::ode

Parameters#

schemeName

the target stepping scheme

system

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#

  • odeScheme must be one of pressio::ode::StepScheme::{BDF1, BDF2}.

  • if system 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

  1. full demo