|
| 1 | +# Linear interpolations |
| 2 | +@muladd @inline function linear_interpolant(Θ, dt, u0, u1, idxs::Nothing, T::Type{Val{0}}) |
| 3 | + Θm1 = (1 - Θ) |
| 4 | + @.. broadcast=false Θm1 * u0+Θ * u1 |
| 5 | +end |
| 6 | + |
| 7 | +@muladd @inline function linear_interpolant(Θ, dt, u0, u1, idxs, T::Type{Val{0}}) |
| 8 | + Θm1 = (1 - Θ) |
| 9 | + @.. broadcast=false Θm1 * u0[idxs]+Θ * u1[idxs] |
| 10 | +end |
| 11 | + |
| 12 | +@muladd @inline function linear_interpolant!(out, Θ, dt, u0, u1, idxs::Nothing, |
| 13 | + T::Type{Val{0}}) |
| 14 | + Θm1 = (1 - Θ) |
| 15 | + @.. broadcast=false out=Θm1 * u0 + Θ * u1 |
| 16 | + out |
| 17 | +end |
| 18 | + |
| 19 | +@muladd @inline function linear_interpolant!(out, Θ, dt, u0, u1, idxs, T::Type{Val{0}}) |
| 20 | + Θm1 = (1 - Θ) |
| 21 | + @views @.. broadcast=false out=Θm1 * u0[idxs] + Θ * u1[idxs] |
| 22 | + out |
| 23 | +end |
| 24 | + |
| 25 | +@inline function linear_interpolant(Θ, dt, u0, u1, idxs::Nothing, T::Type{Val{1}}) |
| 26 | + @.. broadcast=false (u1 - u0)/dt |
| 27 | +end |
| 28 | + |
| 29 | +@inline function linear_interpolant(Θ, dt, u0, u1, idxs, T::Type{Val{1}}) |
| 30 | + @.. broadcast=false (u1[idxs] - u0[idxs])/dt |
| 31 | +end |
| 32 | + |
| 33 | +@inline function linear_interpolant!(out, Θ, dt, u0, u1, idxs::Nothing, T::Type{Val{1}}) |
| 34 | + @.. broadcast=false out=(u1 - u0) / dt |
| 35 | + out |
| 36 | +end |
| 37 | + |
| 38 | +@inline function linear_interpolant!(out, Θ, dt, u0, u1, idxs, T::Type{Val{1}}) |
| 39 | + @views @.. broadcast=false out=(u1[idxs] - u0[idxs]) / dt |
| 40 | + out |
| 41 | +end |
| 42 | + |
| 43 | +####################################################################################### |
| 44 | +# interpolation specializations |
| 45 | +const MPRKCaches = Union{MPEConstantCache, MPECache, MPEConservativeCache, |
| 46 | + MPRK22ConstantCache, MPRK22Cache, MPRK22ConservativeCache, |
| 47 | + MPRK43ConstantCache, MPRK43Cache, MPRK43ConservativeCache, |
| 48 | + SSPMPRK22ConstantCache, SSPMPRK22Cache, SSPMPRK22ConservativeCache, |
| 49 | + SSPMPRK43ConstantCache, SSPMPRK43Cache, SSPMPRK43ConservativeCache} |
| 50 | + |
| 51 | +function interp_summary(::Type{cacheType}, |
| 52 | + dense::Bool) where {cacheType <: MPRKCaches} |
| 53 | + "1st order linear" |
| 54 | +end |
| 55 | + |
| 56 | +function _ode_interpolant(Θ, dt, u0, u1, k, |
| 57 | + cache::MPRKCaches, |
| 58 | + idxs, # Optionally specialize for ::Nothing and others |
| 59 | + T::Type{Val{0}}, |
| 60 | + differential_vars::Nothing) |
| 61 | + linear_interpolant(Θ, dt, u0, u1, idxs, T) |
| 62 | +end |
| 63 | + |
| 64 | +function _ode_interpolant!(out, Θ, dt, u0, u1, k, |
| 65 | + cache::MPRKCaches, |
| 66 | + idxs, # Optionally specialize for ::Nothing and others |
| 67 | + T::Type{Val{0}}, |
| 68 | + differential_vars::Nothing) |
| 69 | + linear_interpolant!(out, Θ, dt, u0, u1, idxs, T) |
| 70 | +end |
| 71 | + |
| 72 | +function _ode_interpolant(Θ, dt, u0, u1, k, |
| 73 | + cache::MPRKCaches, |
| 74 | + idxs, # Optionally specialize for ::Nothing and others |
| 75 | + T::Type{Val{1}}, |
| 76 | + differential_vars::Nothing) |
| 77 | + linear_interpolant(Θ, dt, u0, u1, idxs, T) |
| 78 | +end |
| 79 | + |
| 80 | +function _ode_interpolant!(out, Θ, dt, u0, u1, k, |
| 81 | + cache::MPRKCaches, |
| 82 | + idxs, # Optionally specialize for ::Nothing and others |
| 83 | + T::Type{Val{1}}, |
| 84 | + differential_vars::Nothing) |
| 85 | + linear_interpolant!(out, Θ, dt, u0, u1, idxs, T) |
| 86 | +end |
0 commit comments