Skip to main content

Module ode

Module ode 

Source
Expand description

Layer 1e — ordinary-differential-equation solvers (Euler, RKF45, Rosenbrock23). Ordinary differential equation solvers for systems dy/dx = f(x, y).

Ports the OpenFOAM ODE layer: user systems implement the OdeSystem trait, and one of the concrete steppers integrates them with adaptive step control — Euler (explicit 1st order), Rkf45 (explicit Runge-Kutta-Fehlberg 4(5)), and Rosenbrock23 (semi-implicit, for stiff systems, requiring a Jacobian). The independent variable x, state y, and step size are bare f64 in the caller’s own units; tolerances are set through OdeSolverConfig.

§Storing an integrator: OdeIntegrator

The three steppers above take the system by reference on every call, which is awkward for any caller that wants to keep “the integrator for this material point” as a struct field — storing a borrow would force a lifetime parameter, which the workspace design rules forbid.

integrator solves that with two enums that own what they integrate: OdeSolver selects the stepper, and OdeIntegrator selects how the system is supplied — OdeIntegrator::TypedState (a concrete system owned by value, statically dispatched, preferred) or OdeIntegrator::DynSystem (an Arc<dyn OdeSystem + Send + Sync>, kept by maintainer decision for flexibility). Neither borrows, so neither needs a lifetime.

Re-exports§

pub use euler::Euler;
pub use integrator::DynSystemIntegrator;
pub use integrator::NoTypedSystem;
pub use integrator::OdeIntegrator;
pub use integrator::OdeSolver;
pub use integrator::SharedOdeSystem;
pub use integrator::TypedStateIntegrator;
pub use parallel::adaptive_quadrature_batch;
pub use parallel::ensemble_backend_for;
pub use parallel::integrate_ensemble;
pub use parallel::integrate_ensemble_mixed;
pub use parallel::quadrature_backend_for;
pub use parallel::quadrature_batch;
pub use parallel::AdaptiveSettings;
pub use parallel::GaussOrder;
pub use parallel::OdeEnsemble;
pub use parallel::OdeEnsembleFailure;
pub use parallel::OdeLane;
pub use parallel::OdeLaneSolution;
pub use parallel::OdeLaneStatus;
pub use parallel::QuadratureBatch;
pub use parallel::QuadratureBatchFailure;
pub use parallel::QuadratureInterval;
pub use parallel::QuadratureRule;
pub use parallel::QuadratureSolution;
pub use parallel::QuadratureStatus;
pub use rkf45::Rkf45;
pub use rosenbrock23::Rosenbrock23;

Modules§

euler
integrator
Enum-dispatched ODE integration — solver choice and system ownership.
parallel
Batched numerical integration on the hybrid execution backend — N independent initial-value problems, or N independent definite integrals, advanced at once, serially or across CPU cores.
rkf45
rosenbrock23

Structs§

OdeSolverConfig
Common parameters for the adaptive step-size controller. Defaults match Foam::adaptiveSolver and Foam::ODESolver.

Enums§

OdeError
Failure modes of an adaptive integration.

Traits§

OdeSystem
Abstract ODE system dy/dx = f(x, y). Maps to Foam::ODESystem.