use nalgebra::SVector;
use super::ode::ODE;
#[derive(Clone, Copy)]
pub struct Callback<'a, const D: usize, P> {
pub event: &'a dyn Fn(f64, SVector<f64, D>, &P) -> f64,
pub effect: &'a dyn Fn(&mut ODE<D, P>),
}
pub fn stop<const D: usize, P>(ode: &mut ODE<D, P>) {
ode.t_end = ode.t;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_basic_callbacks() {
type Params = ();
let _value_too_high = Callback {
event: &|_: f64, y: SVector<f64, 3>, _p: &Params| 10.0 - y[0],
effect: &stop,
};
}
}