diff --git a/lib/OrdinaryDiffEqAdamsBashforthMoulton/Project.toml b/lib/OrdinaryDiffEqAdamsBashforthMoulton/Project.toml index bf8227cebc..0bc84c87db 100644 --- a/lib/OrdinaryDiffEqAdamsBashforthMoulton/Project.toml +++ b/lib/OrdinaryDiffEqAdamsBashforthMoulton/Project.toml @@ -22,7 +22,7 @@ DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqLowOrderRK = "<0.0.1, 1" Polyester = "0.7.16" Random = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/OrdinaryDiffEqAdamsBashforthMoulton.jl b/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/OrdinaryDiffEqAdamsBashforthMoulton.jl index 4a6951f9e3..05b2a19bb4 100644 --- a/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/OrdinaryDiffEqAdamsBashforthMoulton.jl +++ b/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/OrdinaryDiffEqAdamsBashforthMoulton.jl @@ -14,6 +14,7 @@ import RecursiveArrayTools: recursivefill! using MuladdMacro, FastBroadcast import Static: False import ADTypes: AutoForwardDiff +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_perform_step.jl b/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_perform_step.jl index a000e9f714..d5fa5a27f1 100644 --- a/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_perform_step.jl +++ b/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_perform_step.jl @@ -6,7 +6,7 @@ function initialize!(integrator, ABM43ConstantCache, ABM54ConstantCache}) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -31,7 +31,7 @@ function initialize!(integrator, integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # pre-start FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::AB3ConstantCache, repeat_step = false) @@ -46,7 +46,7 @@ end cache.step += 1 ttmp = t + (2 / 3) * dt ralk2 = f(uprev + (2 / 3) * dt * k1, p, ttmp) #Ralston Method - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u = uprev + (dt / 4) * (k1 + 3 * ralk2) if cnt == 1 k3 = k1 @@ -61,7 +61,7 @@ end cache.k2 = k2 cache.k3 = k3 integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -80,7 +80,7 @@ end ttmp = t + (2 / 3) * dt @.. broadcast=false tmp=uprev + (2 / 3) * dt * k1 f(ralk2, tmp, p, ttmp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=uprev + (dt / 4) * (k1 + 3 * ralk2) #Ralston Method if cnt == 1 cache.k3 .= k1 @@ -93,7 +93,7 @@ end cache.k2 .= k1 end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::ABM32ConstantCache, repeat_step = false) @@ -108,7 +108,7 @@ end cache.step += 1 ttmp = t + (2 / 3) * dt ralk2 = f(uprev + (2 / 3) * dt * k1, p, ttmp) #Ralston Method - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u = uprev + (dt / 4) * (k1 + 3 * ralk2) k2 = k1 else @@ -121,7 +121,7 @@ end cache.k2 = k2 cache.k3 = k3 integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -140,7 +140,7 @@ end ttmp = t + (2 / 3) * dt @.. broadcast=false tmp=uprev + (2 / 3) * dt * k1 f(ralk2, tmp, p, ttmp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=uprev + (dt / 4) * (k1 + 3 * ralk2) #Ralston Method cache.k2 .= k1 else @@ -157,7 +157,7 @@ end cache.k2 .= k1 end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::AB4ConstantCache, repeat_step = false) @@ -175,7 +175,7 @@ end k2 = f(uprev + halfdt * k1, p, ttmp) k3 = f(uprev + halfdt * k2, p, ttmp) k4 = f(uprev + dt * k3, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) u = uprev + (dt / 6) * (2 * (k2 + k3) + (k1 + k4)) #RK4 if cnt == 1 cache.k4 = k1 @@ -191,7 +191,7 @@ end cache.k2 = k1 end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -215,7 +215,7 @@ end f(t3, tmp, p, ttmp) @.. broadcast=false tmp=uprev + dt * t3 f(t4, tmp, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) @.. broadcast=false u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 if cnt == 1 cache.k4 .= k1 @@ -231,7 +231,7 @@ end cache.k2 .= k1 end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::ABM43ConstantCache, repeat_step = false) @@ -249,7 +249,7 @@ end k2 = f(uprev + halfdt * k1, p, ttmp) k3 = f(uprev + halfdt * k2, p, ttmp) k4 = f(uprev + dt * k3, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) u = uprev + (dt / 6) * (2 * (k2 + k3) + (k1 + k4)) #RK4 if cnt == 1 cache.k3 = k1 @@ -265,7 +265,7 @@ end cache.k2 = k1 end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -289,7 +289,7 @@ end f(t3, tmp, p, ttmp) @.. broadcast=false tmp=uprev + dt * t3 f(t4, tmp, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) @.. broadcast=false u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 if cnt == 1 cache.k3 .= k1 @@ -310,7 +310,7 @@ end cache.k2 .= k1 end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::AB5ConstantCache, repeat_step = false) @@ -328,7 +328,7 @@ end k2 = f(uprev + halfdt * k1, p, ttmp) k3 = f(uprev + halfdt * k2, p, ttmp) k4 = f(uprev + dt * k3, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) u = uprev + (dt / 6) * (2 * (k2 + k3) + (k1 + k4)) #RK4 if cnt == 1 cache.k5 = k1 @@ -347,7 +347,7 @@ end cache.k2 = k1 end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -371,7 +371,7 @@ end f(t3, tmp, p, ttmp) @.. broadcast=false tmp=uprev + dt * t3 f(t4, tmp, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 if cnt == 1 cache.k5 .= k1 @@ -392,7 +392,7 @@ end cache.k2 .= k1 end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::ABM54ConstantCache, repeat_step = false) @@ -410,7 +410,7 @@ end k2 = f(uprev + halfdt * k1, p, ttmp) k3 = f(uprev + halfdt * k2, p, ttmp) k4 = f(uprev + dt * k3, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) u = uprev + (dt / 6) * (2 * (k2 + k3) + (k1 + k4)) #RK4 if cnt == 1 cache.k4 = k1 @@ -429,7 +429,7 @@ end cache.k2 = k1 end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -454,7 +454,7 @@ end @.. broadcast=false tmp=uprev + dt * t3 f(t4, tmp, p, t + dt) @.. broadcast=false u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) if cnt == 1 cache.k4 .= k1 elseif cnt == 2 @@ -480,7 +480,7 @@ end cache.k2 .= k1 end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # Variable Step Size Multistep Methods @@ -541,7 +541,7 @@ end end end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -558,7 +558,7 @@ function initialize!(integrator, cache::VCAB3Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # pre-start FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::VCAB3Cache, repeat_step = false) @@ -607,14 +607,14 @@ end end end f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end cache.ϕstar_nm1, cache.ϕstar_n = ϕstar_n, ϕstar_nm1 end function initialize!(integrator, cache::VCAB4ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -675,7 +675,7 @@ end end end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -692,7 +692,7 @@ function initialize!(integrator, cache::VCAB4Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # pre-start FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::VCAB4Cache, repeat_step = false) @@ -747,7 +747,7 @@ end end end f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end cache.ϕstar_nm1, cache.ϕstar_n = ϕstar_n, ϕstar_nm1 end @@ -756,7 +756,7 @@ end function initialize!(integrator, cache::VCAB5ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -824,7 +824,7 @@ end end end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -841,7 +841,7 @@ function initialize!(integrator, cache::VCAB5Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # pre-start FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::VCAB5Cache, repeat_step = false) @@ -903,7 +903,7 @@ end end end f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end cache.ϕstar_nm1, cache.ϕstar_n = ϕstar_n, ϕstar_nm1 end @@ -912,7 +912,7 @@ end function initialize!(integrator, cache::VCABM3ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -953,7 +953,7 @@ end u += g[i] * ϕstar_n[i] end du_np1 = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, du_np1, k + 1) u += g[end - 1] * ϕ_np1[end - 1] if integrator.opts.adaptive @@ -971,7 +971,7 @@ end end end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -988,7 +988,7 @@ function initialize!(integrator, cache::VCABM3Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # pre-start FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::VCABM3Cache, repeat_step = false) @@ -1024,7 +1024,7 @@ end @.. broadcast=false u+=g[i] * ϕstar_n[i] end f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, k4, k + 1) @.. broadcast=false u+=g[end - 1] * ϕ_np1[end - 1] if integrator.opts.adaptive @@ -1041,7 +1041,7 @@ end end end f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end cache.ϕstar_nm1, cache.ϕstar_n = ϕstar_n, ϕstar_nm1 end @@ -1050,7 +1050,7 @@ end function initialize!(integrator, cache::VCABM4ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -1097,7 +1097,7 @@ end u += g[i] * ϕstar_n[i] end du_np1 = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, du_np1, k + 1) u += g[end - 1] * ϕ_np1[end - 1] if integrator.opts.adaptive @@ -1115,7 +1115,7 @@ end end end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1132,7 +1132,7 @@ function initialize!(integrator, cache::VCABM4Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # pre-start FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::VCABM4Cache, repeat_step = false) @@ -1174,7 +1174,7 @@ end @.. broadcast=false u+=g[i] * ϕstar_n[i] end f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, k4, k + 1) @.. broadcast=false u+=g[end - 1] * ϕ_np1[end - 1] if integrator.opts.adaptive @@ -1191,7 +1191,7 @@ end end end f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end cache.ϕstar_nm1, cache.ϕstar_n = ϕstar_n, ϕstar_nm1 end @@ -1200,7 +1200,7 @@ end function initialize!(integrator, cache::VCABM5ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -1254,7 +1254,7 @@ end u += g[i] * ϕstar_n[i] end du_np1 = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, du_np1, k + 1) u += g[end - 1] * ϕ_np1[end - 1] if integrator.opts.adaptive @@ -1272,7 +1272,7 @@ end end end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1289,7 +1289,7 @@ function initialize!(integrator, cache::VCABM5Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # pre-start FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::VCABM5Cache, repeat_step = false) @@ -1339,7 +1339,7 @@ end @.. broadcast=false u=muladd(g[3], ϕstar_n[3], u) @.. broadcast=false u=muladd(g[4], ϕstar_n[4], u) f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, k4, 6) @.. broadcast=false u=muladd(g[6 - 1], ϕ_np1[6 - 1], u) if integrator.opts.adaptive @@ -1361,7 +1361,7 @@ end cache.ϕstar_nm1[3] .= ϕstar_n[3] cache.ϕstar_nm1[4] .= ϕstar_n[4] f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end cache.ϕstar_nm1, cache.ϕstar_n = ϕstar_n, ϕstar_nm1 return nothing @@ -1372,7 +1372,7 @@ end function initialize!(integrator, cache::VCABMConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -1401,7 +1401,7 @@ end u = muladd(g[i], ϕstar_n[i], u) end du_np1 = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, du_np1, k + 1) u = muladd(g[k], ϕ_np1[k], u) if integrator.opts.adaptive @@ -1418,7 +1418,7 @@ end return nothing end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if step <= 4 || order < 3 cache.order = min(order + 1, 3) else @@ -1466,7 +1466,7 @@ function initialize!(integrator, cache::VCABMCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # pre-start FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::VCABMCache, repeat_step = false) @@ -1489,7 +1489,7 @@ end @.. broadcast=false u=muladd(g[i], ϕstar_n[i], u) end f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, k4, k + 1) @.. broadcast=false u=muladd(g[k], ϕ_np1[k], u) if integrator.opts.adaptive @@ -1505,7 +1505,7 @@ end return nothing end f(k4, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if step <= 4 || order < 3 cache.order = min(order + 1, 3) else diff --git a/lib/OrdinaryDiffEqBDF/Project.toml b/lib/OrdinaryDiffEqBDF/Project.toml index 554298b9fd..efd5726b28 100644 --- a/lib/OrdinaryDiffEqBDF/Project.toml +++ b/lib/OrdinaryDiffEqBDF/Project.toml @@ -31,7 +31,7 @@ LinearAlgebra = "<0.0.1, 1" MacroTools = "0.5.13" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqDifferentiation = "<0.0.1, 1" OrdinaryDiffEqNonlinearSolve = "<0.0.1, 1" OrdinaryDiffEqSDIRK = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqBDF/src/bdf_perform_step.jl b/lib/OrdinaryDiffEqBDF/src/bdf_perform_step.jl index 82adbd82ef..a040c6076d 100644 --- a/lib/OrdinaryDiffEqBDF/src/bdf_perform_step.jl +++ b/lib/OrdinaryDiffEqBDF/src/bdf_perform_step.jl @@ -2,7 +2,7 @@ function initialize!(integrator, cache::ABDF2ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -60,7 +60,7 @@ end nlsolvefail(nlsolver) && return integrator.fsallast = f(uₙ, p, t + dtₙ) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive tmp = integrator.fsallast - (1 + dtₙ / dtₙ₋₁) * integrator.fsalfirst + @@ -92,7 +92,7 @@ function initialize!(integrator, cache::ABDF2Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::ABDF2Cache, repeat_step = false) @@ -151,7 +151,7 @@ end step_limiter!(uₙ, integrator, p, t + dtₙ) f(integrator.fsallast, uₙ, p, t + dtₙ) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive btilde0 = (dtₙ₋₁ + dtₙ) * 1 // 6 btilde1 = 1 + dtₙ / dtₙ₋₁ @@ -182,7 +182,7 @@ function initialize!(integrator, cache::SBDFConstantCache) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) cache.du₁ = f1(uprev, p, t) cache.du₂ = f2(uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.fsalfirst = cache.du₁ + cache.du₂ @@ -243,7 +243,7 @@ function perform_step!(integrator, cache::SBDFConstantCache, repeat_step = false cache.k₁ = du₂) cache.du₁ = f1(u, p, t + dt) cache.du₂ = f2(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.fsallast = cache.du₁ + cache.du₂ integrator.k[1] = integrator.fsalfirst @@ -262,7 +262,7 @@ function initialize!(integrator, cache::SBDFCache) integrator.k[2] = integrator.fsallast f1(cache.du₁, uprev, p, t) f2(cache.du₂, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 @.. broadcast=false integrator.fsalfirst=cache.du₁ + cache.du₂ end @@ -317,7 +317,7 @@ function perform_step!(integrator, cache::SBDFCache, repeat_step = false) cache.k₁ .= du₂) f1(du₁, u, p, t + dt) f2(du₂, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 @.. broadcast=false integrator.fsallast=du₁ + du₂ end @@ -328,7 +328,7 @@ function initialize!(integrator, cache::QNDF1ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -403,7 +403,7 @@ function perform_step!(integrator, cache::QNDF1ConstantCache, repeat_step = fals cache.dtₙ₋₁ = dt cache.uprev2 = uprev integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -418,7 +418,7 @@ function initialize!(integrator, cache::QNDF1Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::QNDF1Cache, repeat_step = false) @@ -492,7 +492,7 @@ function perform_step!(integrator, cache::QNDF1Cache, repeat_step = false) cache.uprev2 .= uprev cache.dtₙ₋₁ = dt f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return end @@ -500,7 +500,7 @@ function initialize!(integrator, cache::QNDF2ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -599,7 +599,7 @@ function perform_step!(integrator, cache::QNDF2ConstantCache, repeat_step = fals cache.dtₙ₋₂ = dtₙ₋₁ cache.dtₙ₋₁ = dt integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -614,7 +614,7 @@ function initialize!(integrator, cache::QNDF2Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::QNDF2Cache, repeat_step = false) @@ -712,7 +712,7 @@ function perform_step!(integrator, cache::QNDF2Cache, repeat_step = false) cache.dtₙ₋₂ = dtₙ₋₁ cache.dtₙ₋₁ = dt f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return end @@ -720,7 +720,7 @@ function initialize!(integrator, cache::QNDFConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -823,7 +823,7 @@ function perform_step!(integrator, cache::QNDFConstantCache{max_order}, cache.prevorder = k if integrator.opts.dense integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end end integrator.k[1] = integrator.fsalfirst @@ -839,7 +839,7 @@ function initialize!(integrator, cache::QNDFCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::QNDFCache{max_order}, @@ -947,7 +947,7 @@ function perform_step!(integrator, cache::QNDFCache{max_order}, cache.prevorder = k if integrator.opts.dense f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end end return nothing @@ -958,7 +958,7 @@ function initialize!(integrator, cache::MEBDF2ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -1002,7 +1002,7 @@ end ### finalize integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1016,7 +1016,7 @@ function initialize!(integrator, cache::MEBDF2Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::MEBDF2Cache, repeat_step = false) @@ -1058,14 +1058,14 @@ end ### finalize f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::FBDFConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -1210,7 +1210,7 @@ function perform_step!(integrator, cache::FBDFConstantCache{max_order}, end integrator.fsallast = f(u, p, tdt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1224,7 +1224,7 @@ function initialize!(integrator, cache::FBDFCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::FBDFCache{max_order}, @@ -1337,5 +1337,5 @@ function perform_step!(integrator, cache::FBDFCache{max_order}, end f(integrator.fsallast, u, p, tdt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end diff --git a/lib/OrdinaryDiffEqBDF/src/dae_perform_step.jl b/lib/OrdinaryDiffEqBDF/src/dae_perform_step.jl index a89ddc0001..2be69e8277 100644 --- a/lib/OrdinaryDiffEqBDF/src/dae_perform_step.jl +++ b/lib/OrdinaryDiffEqBDF/src/dae_perform_step.jl @@ -200,7 +200,7 @@ end @.. broadcast=false du=(nlsolver.α * z + nlsolver.tmp) * inv(nlsolver.γ * dt) @.. broadcast=false integrator.fsallast=du - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive btilde0 = (dtₙ₋₁ + dtₙ) * 1 // 6 btilde1 = 1 + ρ @@ -227,7 +227,7 @@ function initialize!(integrator, cache::DFBDFConstantCache) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.du, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) integrator.k[1] = integrator.fsalfirst @@ -358,7 +358,7 @@ function initialize!(integrator, cache::DFBDFCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast #integrator.f(integrator.fsalfirst, integrator.du, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - #integrator.stats.nf += 1 + #OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::DFBDFCache{max_order}, diff --git a/lib/OrdinaryDiffEqCore/Project.toml b/lib/OrdinaryDiffEqCore/Project.toml index 8be36cf535..54e9b821eb 100644 --- a/lib/OrdinaryDiffEqCore/Project.toml +++ b/lib/OrdinaryDiffEqCore/Project.toml @@ -1,7 +1,7 @@ name = "OrdinaryDiffEqCore" uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8" authors = ["ParamThakkar123 "] -version = "1.0.0" +version = "1.1.0" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" @@ -34,6 +34,12 @@ StaticArrayInterface = "0d7ed370-da01-4f52-bd93-41d350b8b718" StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c" TruncatedStacktraces = "781d530d-4396-4725-bb49-402e4bee1e77" +[weakdeps] +EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" + +[extensions] +OrdinaryDiffEqCoreEnzymeCore = "EnzymeCore" + [compat] ADTypes = "0.2, 1" Adapt = "3.0, 4" diff --git a/lib/OrdinaryDiffEqCore/ext/OrdinaryDiffEqCoreEnzymeCoreExt.jl b/lib/OrdinaryDiffEqCore/ext/OrdinaryDiffEqCoreEnzymeCoreExt.jl new file mode 100644 index 0000000000..c43dd98c3e --- /dev/null +++ b/lib/OrdinaryDiffEqCore/ext/OrdinaryDiffEqCoreEnzymeCoreExt.jl @@ -0,0 +1,12 @@ +module OrdinaryDiffEqCoreEnzymeCoreExt +import OrdinaryDiffEqCore, EnzymeCore + +Enzyme.EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.increment_nf!), args...) = true +Enzyme.EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.fixed_t_for_floatingpoint_error!), args...) = true +Enzyme.EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.increment_accept!), args...) = true +Enzyme.EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.increment_reject!), args...) = true +Enzyme.EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.increment_nf_perform_step!), args...) = true +Enzyme.EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.check_error!), args...) = true +Enzyme.EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.log_step!), args...) = true + +end \ No newline at end of file diff --git a/lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl b/lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl index 4d97950267..99592d1069 100644 --- a/lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl +++ b/lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl @@ -419,7 +419,11 @@ function DiffEqBase.auto_dt_reset!(integrator::ODEIntegrator) integrator.opts.internalnorm, integrator.sol.prob, integrator) integrator.dtpropose = integrator.dt - integrator.stats.nf += 2 + increment_nf!(integrator.stats, 2) +end + +function increment_nf!(stats, amt = 1) + stats.nf += amt end function DiffEqBase.set_t!(integrator::ODEIntegrator, t::Real) diff --git a/lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl b/lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl index bf8b029ec9..3024f40827 100644 --- a/lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl +++ b/lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl @@ -231,57 +231,32 @@ function _loopfooter!(integrator) (integrator.opts.force_dtmin && abs(integrator.dt) <= timedepentdtmin(integrator)) if integrator.accept_step # Accept - integrator.stats.naccept += 1 + increment_accept!(integrator.stats) integrator.last_stepfail = false dtnew = DiffEqBase.value(step_accept_controller!(integrator, integrator.alg, q)) * oneunit(integrator.dt) integrator.tprev = integrator.t - integrator.t = if has_tstop(integrator) - tstop = integrator.tdir * first_tstop(integrator) - if abs(ttmp - tstop) < - 100eps(float(max(integrator.t, tstop) / oneunit(integrator.t))) * - oneunit(integrator.t) - tstop - else - ttmp - end - else - ttmp - end + integrator.t = fixed_t_for_floatingpoint_error!(integrator, ttmp) calc_dt_propose!(integrator, dtnew) handle_callbacks!(integrator) else # Reject - integrator.stats.nreject += 1 + increment_reject!(integrator.stats) end elseif !integrator.opts.adaptive #Not adaptive - integrator.stats.naccept += 1 + increment_accept!(integrator.stats) integrator.tprev = integrator.t - integrator.t = if has_tstop(integrator) - tstop = integrator.tdir * first_tstop(integrator) - if abs(ttmp - tstop) < - 100eps(float(integrator.t / oneunit(integrator.t))) * oneunit(integrator.t) - tstop - else - ttmp - end - else - ttmp - end + integrator.t = fixed_t_for_floatingpoint_error!(integrator, ttmp) integrator.last_stepfail = false integrator.accept_step = true integrator.dtpropose = integrator.dt handle_callbacks!(integrator) end if integrator.opts.progress && integrator.iter % integrator.opts.progress_steps == 0 - t1, t2 = integrator.sol.prob.tspan - @logmsg(LogLevel(-1), - integrator.opts.progress_name, - _id=integrator.opts.progress_id, - message=integrator.opts.progress_message(integrator.dt, integrator.u, - integrator.p, integrator.t), - progress=(integrator.t - t1) / (t2 - t1)) + log_step!(integrator.opts.progress_name, integrator.opts.progress_id, + integrator.opts.progress_message, integrator.dt, integrator.u, + integrator.p, integrator.t, integrator.sol.prob.tspan) end # Take value because if t is dual then maxeig can be dual @@ -295,6 +270,37 @@ function _loopfooter!(integrator) nothing end +function increment_accept!(stats) + stats.naccept += 1 +end + +function increment_reject!(stats) + stats.nreject += 1 +end + +function log_step!(progress_name, progress_id, progress_message, dt, u, p, t, tspan) + t1, t2 = tspan + @logmsg(LogLevel(-1),progress_name, + _id=progress_id, + message=progress_message(dt, u, p, t), + progress=(t - t1) / (t2 - t1)) +end + +function fixed_t_for_floatingpoint_error!(integrator, ttmp) + if has_tstop(integrator) + tstop = integrator.tdir * first_tstop(integrator) + if abs(ttmp - tstop) < + 100eps(float(max(integrator.t, tstop) / oneunit(integrator.t))) * + oneunit(integrator.t) + tstop + else + ttmp + end + else + ttmp + end +end + # Use a generated function to call apply_callback! in a type-stable way @generated function apply_ith_callback!(integrator, time, upcrossing, event_idx, cb_idx, @@ -471,7 +477,7 @@ handle_callback_modifiers!(integrator::ODEIntegrator) = nothing function reset_fsal!(integrator) # Under these conditions, these algorithms are not FSAL anymore - integrator.stats.nf += 1 + increment_nf!(integrator.stats, 1) # Ignore DAEs but they already re-ran initialization # Mass matrix DAEs do need to reset FSAL if available diff --git a/lib/OrdinaryDiffEqDefault/Project.toml b/lib/OrdinaryDiffEqDefault/Project.toml index bbcf79a48a..28fda89b62 100644 --- a/lib/OrdinaryDiffEqDefault/Project.toml +++ b/lib/OrdinaryDiffEqDefault/Project.toml @@ -24,7 +24,7 @@ EnumX = "1.0.4" LinearAlgebra = "<0.0.1, 1" LinearSolve = "2.32.0" OrdinaryDiffEqBDF = "<0.0.1, 1" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqRosenbrock = "<0.0.1, 1" OrdinaryDiffEqTsit5 = "<0.0.1, 1" OrdinaryDiffEqVerner = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqDifferentiation/Project.toml b/lib/OrdinaryDiffEqDifferentiation/Project.toml index 45728b4d86..399a3d542c 100644 --- a/lib/OrdinaryDiffEqDifferentiation/Project.toml +++ b/lib/OrdinaryDiffEqDifferentiation/Project.toml @@ -33,7 +33,7 @@ FunctionWrappersWrappers = "0.1" InteractiveUtils = "1.10" LinearAlgebra = "1.10" LinearSolve = "2" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" Random = "<0.0.1, 1" SafeTestsets = "0.1.0" SciMLBase = "2" diff --git a/lib/OrdinaryDiffEqDifferentiation/src/OrdinaryDiffEqDifferentiation.jl b/lib/OrdinaryDiffEqDifferentiation/src/OrdinaryDiffEqDifferentiation.jl index 4fdbd9f54b..e490647c60 100644 --- a/lib/OrdinaryDiffEqDifferentiation/src/OrdinaryDiffEqDifferentiation.jl +++ b/lib/OrdinaryDiffEqDifferentiation/src/OrdinaryDiffEqDifferentiation.jl @@ -30,6 +30,7 @@ using DiffEqBase: TimeGradientWrapper, UJacobianWrapper, TimeDerivativeWrapper, UDerivativeWrapper using SciMLBase: AbstractSciMLOperator +import OrdinaryDiffEqCore using OrdinaryDiffEqCore: OrdinaryDiffEqAlgorithm, OrdinaryDiffEqAdaptiveImplicitAlgorithm, DAEAlgorithm, OrdinaryDiffEqImplicitAlgorithm, CompositeAlgorithm, diff --git a/lib/OrdinaryDiffEqDifferentiation/src/derivative_wrappers.jl b/lib/OrdinaryDiffEqDifferentiation/src/derivative_wrappers.jl index b5948646cf..5104b94e86 100644 --- a/lib/OrdinaryDiffEqDifferentiation/src/derivative_wrappers.jl +++ b/lib/OrdinaryDiffEqDifferentiation/src/derivative_wrappers.jl @@ -101,7 +101,7 @@ function derivative!(df::AbstractArray{<:Number}, f, end df .= first.(ForwardDiff.partials.(grad_config)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) elseif alg_autodiff(alg) isa AutoFiniteDiff FiniteDiff.finite_difference_gradient!(df, f, x, grad_config, dir = diffdir(integrator)) @@ -125,7 +125,7 @@ function derivative(f, x::Union{Number, AbstractArray{<:Number}}, tmp = length(x) # We calculate derivative for all elements in gradient alg = unwrap_alg(integrator, true) if alg_autodiff(alg) isa AutoForwardDiff - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.iter == 1 try d = ForwardDiff.derivative(f, x) @@ -239,13 +239,13 @@ function jacobian!(J::AbstractMatrix{<:Number}, f, x::AbstractArray{<:Number}, else forwarddiff_color_jacobian!(J, f, x, jac_config) end - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) elseif alg_autodiff(alg) isa AutoFiniteDiff isforward = alg_difftype(alg) === Val{:forward} if isforward forwardcache = get_tmp_cache(integrator, alg, unwrap_cache(integrator, true))[2] f(forwardcache, x) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) tmp = jacobian_finitediff_forward!(J, f, x, jac_config, forwardcache, integrator) else # not forward difference diff --git a/lib/OrdinaryDiffEqDifferentiation/src/linsolve_utils.jl b/lib/OrdinaryDiffEqDifferentiation/src/linsolve_utils.jl index f2f77162fd..aa48161e1b 100644 --- a/lib/OrdinaryDiffEqDifferentiation/src/linsolve_utils.jl +++ b/lib/OrdinaryDiffEqDifferentiation/src/linsolve_utils.jl @@ -35,7 +35,7 @@ function dolinsolve(integrator, linsolve; A = nothing, linu = nothing, b = nothi if alg_autodiff(_alg) isa AutoForwardDiff integrator.stats.nf += linres.iters elseif alg_autodiff(_alg) isa AutoFiniteDiff - integrator.stats.nf += 2 * linres.iters + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) * linres.iters else error("$alg_autodiff not yet supported in dolinsolve function") end diff --git a/lib/OrdinaryDiffEqExplicitRK/src/OrdinaryDiffEqExplicitRK.jl b/lib/OrdinaryDiffEqExplicitRK/src/OrdinaryDiffEqExplicitRK.jl index 4dfdbbbdc7..559bc471ce 100644 --- a/lib/OrdinaryDiffEqExplicitRK/src/OrdinaryDiffEqExplicitRK.jl +++ b/lib/OrdinaryDiffEqExplicitRK/src/OrdinaryDiffEqExplicitRK.jl @@ -9,6 +9,7 @@ import OrdinaryDiffEqCore: alg_order, alg_adaptive_order, alg_stability_size, full_cache using TruncatedStacktraces, RecursiveArrayTools, FastBroadcast, MuladdMacro, DiffEqBase import LinearAlgebra: norm +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqExplicitRK/src/explicit_rk_perform_step.jl b/lib/OrdinaryDiffEqExplicitRK/src/explicit_rk_perform_step.jl index 08ddee112a..a2133263b5 100644 --- a/lib/OrdinaryDiffEqExplicitRK/src/explicit_rk_perform_step.jl +++ b/lib/OrdinaryDiffEqExplicitRK/src/explicit_rk_perform_step.jl @@ -2,7 +2,7 @@ function initialize!(integrator, cache::ExplicitRKConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -27,7 +27,7 @@ end utilde = utilde + A[j, i] * kk[j] end kk[i] = f(uprev + dt * utilde, p, t + c[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #Calc Last @@ -37,7 +37,7 @@ end end u_beforefinal = uprev + dt * utilde_last kk[end] = f(u_beforefinal, p, t + c[end] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = kk[end] # Uses fsallast as temp even if not fsal # Accumulate Result @@ -65,7 +65,7 @@ end if !isfsal(alg.tableau) integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end integrator.k[1] = integrator.fsalfirst @@ -81,7 +81,7 @@ function initialize!(integrator, cache::ExplicitRKCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @generated function accumulate_explicit_stages!(out, A, uprev, kk, dt, ::Val{s}, @@ -235,6 +235,6 @@ end if !isfsal(alg.tableau) f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end end diff --git a/lib/OrdinaryDiffEqExponentialRK/Project.toml b/lib/OrdinaryDiffEqExponentialRK/Project.toml index c3dadcf16a..a2fab24e98 100644 --- a/lib/OrdinaryDiffEqExponentialRK/Project.toml +++ b/lib/OrdinaryDiffEqExponentialRK/Project.toml @@ -25,7 +25,7 @@ FastBroadcast = "0.3.5" LinearAlgebra = "<0.0.1, 1" LinearSolve = "2.32.0" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqDifferentiation = "<0.0.1, 1" OrdinaryDiffEqSDIRK = "<0.0.1, 1" OrdinaryDiffEqTsit5 = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqExponentialRK/src/OrdinaryDiffEqExponentialRK.jl b/lib/OrdinaryDiffEqExponentialRK/src/OrdinaryDiffEqExponentialRK.jl index c3c7fd4108..bfe8715f03 100644 --- a/lib/OrdinaryDiffEqExponentialRK/src/OrdinaryDiffEqExponentialRK.jl +++ b/lib/OrdinaryDiffEqExponentialRK/src/OrdinaryDiffEqExponentialRK.jl @@ -10,6 +10,7 @@ import OrdinaryDiffEqCore: alg_order, alg_adaptive_order, ismultistep, ExponentialAlgorithm, fsal_typeof, isdtchangeable, calculate_residuals, calculate_residuals!, full_cache +import OrdinaryDiffEqCore using RecursiveArrayTools using MuladdMacro, FastBroadcast using LinearAlgebra: axpy!, mul! diff --git a/lib/OrdinaryDiffEqExponentialRK/src/exponential_rk_perform_step.jl b/lib/OrdinaryDiffEqExponentialRK/src/exponential_rk_perform_step.jl index 74b56b5df8..12abd86a98 100644 --- a/lib/OrdinaryDiffEqExponentialRK/src/exponential_rk_perform_step.jl +++ b/lib/OrdinaryDiffEqExponentialRK/src/exponential_rk_perform_step.jl @@ -13,7 +13,7 @@ end function initialize!(integrator, cache::ExpRKConstantCache) # Pre-start fsal integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) # Initialize interpolation derivatives @@ -26,7 +26,7 @@ function initialize!(integrator, cache::ExpRKCache) # Pre-start fsal integrator.fsalfirst = zero(cache.rtmp) integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) # Initialize interpolation derivatives @@ -47,7 +47,7 @@ function perform_step!(integrator, cache::LawsonEulerConstantCache, repeat_step if isa(f, SplitFunction) integrator.stats.nf2 += 1 else - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd v = uprev + dt * nl if alg.krylov @@ -60,7 +60,7 @@ function perform_step!(integrator, cache::LawsonEulerConstantCache, repeat_step # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -76,7 +76,7 @@ function perform_step!(integrator, cache::LawsonEulerCache, repeat_step = false) if isa(f, SplitFunction) integrator.stats.nf2 += 1 else - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd @.. broadcast=false tmp=uprev + dt * G if alg.krylov @@ -90,7 +90,7 @@ function perform_step!(integrator, cache::LawsonEulerCache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -110,7 +110,7 @@ function perform_step!(integrator, cache::NorsettEulerConstantCache, repeat_step # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -136,7 +136,7 @@ function perform_step!(integrator, cache::NorsettEulerCache, repeat_step = false # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -154,7 +154,7 @@ function perform_step!(integrator, cache::ETDRK2ConstantCache, repeat_step = fal if isa(f, SplitFunction) integrator.stats.nf2 += 1 else - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end w2 = phiv(dt, A, F2, 2; m = min(alg.m, size(A, 1)), opnorm = integrator.opts.internalopnorm, iop = alg.iop) @@ -173,7 +173,7 @@ function perform_step!(integrator, cache::ETDRK2ConstantCache, repeat_step = fal # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -199,7 +199,7 @@ function perform_step!(integrator, cache::ETDRK2Cache, repeat_step = false) if isa(f, SplitFunction) integrator.stats.nf2 += 1 else - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end F2 .+= mul!(rtmp, A, uprev) arnoldi!(Ks, A, F2; m = min(alg.m, size(A, 1)), @@ -230,7 +230,7 @@ function perform_step!(integrator, cache::ETDRK2Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -257,7 +257,7 @@ function perform_step!(integrator, cache::ETDRK3ConstantCache, repeat_step = fal if isa(f, SplitFunction) integrator.stats.nf2 += 2 else - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) end # Krylov on F3 (third column) w3 = phiv(dt, A, F3, 3; kwargs...) @@ -283,7 +283,7 @@ function perform_step!(integrator, cache::ETDRK3ConstantCache, repeat_step = fal # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -319,7 +319,7 @@ function perform_step!(integrator, cache::ETDRK3Cache, repeat_step = false) if isa(f, SplitFunction) integrator.stats.nf2 += 2 else - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) end # Krylov for F3 (third column) arnoldi!(Ks, A, F3; kwargs...) @@ -353,7 +353,7 @@ function perform_step!(integrator, cache::ETDRK3Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -390,7 +390,7 @@ function perform_step!(integrator, cache::ETDRK4ConstantCache, repeat_step = fal if isa(f, SplitFunction) integrator.stats.nf2 += 3 else - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) end # Krylov on F4 (fourth column) w4 = phiv(dt, A, F4, 3; kwargs...) @@ -417,7 +417,7 @@ function perform_step!(integrator, cache::ETDRK4ConstantCache, repeat_step = fal # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -467,7 +467,7 @@ function perform_step!(integrator, cache::ETDRK4Cache, repeat_step = false) if isa(f, SplitFunction) integrator.stats.nf2 += 3 else - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) end # Krylov for F4 (fourth column) arnoldi!(Ks, A, F4; kwargs...) @@ -507,7 +507,7 @@ function perform_step!(integrator, cache::ETDRK4Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -554,7 +554,7 @@ function perform_step!(integrator, cache::HochOst4ConstantCache, repeat_step = f if isa(f, SplitFunction) integrator.stats.nf2 += 4 else - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) end # Krylov on F5 (fifth column) w5 = phiv(dt, A, F5, 3; kwargs...) @@ -584,7 +584,7 @@ function perform_step!(integrator, cache::HochOst4ConstantCache, repeat_step = f # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -649,7 +649,7 @@ function perform_step!(integrator, cache::HochOst4Cache, repeat_step = false) if isa(f, SplitFunction) integrator.stats.nf2 += 4 else - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) end # Krylov on F5 (fifth column) arnoldi!(Ks, A, F5; kwargs...) @@ -703,7 +703,7 @@ function perform_step!(integrator, cache::HochOst4Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -729,7 +729,7 @@ function perform_step!(integrator, cache::Exp4ConstantCache, repeat_step = false w4 = K1 * [-7 / 300, 97 / 150, -37 / 300] u4 = uprev + dt * w4 d4 = f(u4, p, t + dt) - f0 - dt * (J * w4) # TODO: what should be the time? - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Krylov for the first remainder d4 B2 = [zero(d4) d4] K2 = phiv_timestep(ts, J, B2; kwargs...) @@ -739,7 +739,7 @@ function perform_step!(integrator, cache::Exp4ConstantCache, repeat_step = false w7 = K1 * [59 / 300, -7 / 75, 269 / 300] + K2 * [2 / 3, 2 / 3, 2 / 3] u7 = uprev + dt * w7 d7 = f(u7, p, t + dt) - f0 - dt * (J * w7) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Krylov for the second remainder d7 B3 = [zero(d7) d7] k7 = phiv_timestep(ts[1], J, B3; kwargs...) @@ -749,7 +749,7 @@ function perform_step!(integrator, cache::Exp4ConstantCache, repeat_step = false # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -777,7 +777,7 @@ function perform_step!(integrator, cache::Exp4Cache, repeat_step = false) @muladd @.. broadcast=false tmp=uprev + dt * rtmp # tmp is now u4 mul!(rtmp2, J, rtmp) f(rtmp, tmp, p, t + dt) # TODO: what should be the time? - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @muladd @.. broadcast=false @view(B[:, 2])=rtmp - f0 - dt * rtmp2 # B[:,2] is now d4 # Partially update entities that use k1, k2, k3 mul!(rtmp, K, [59 / 300, -7 / 75, 269 / 300]) # rtmp is now w7 @@ -792,7 +792,7 @@ function perform_step!(integrator, cache::Exp4Cache, repeat_step = false) @muladd @.. broadcast=false tmp=uprev + dt * rtmp # tmp is now u7 mul!(rtmp2, J, rtmp) f(rtmp, tmp, p, t + dt) # TODO: what should be the time? - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @muladd @.. broadcast=false @view(B[:, 2])=rtmp - f0 - dt * rtmp2 # B[:,2] is now d7 # Partially update entities that use k4, k5, k6 mul!(rtmp, K, [1.0, -4 / 3, 1.0]) @@ -805,7 +805,7 @@ function perform_step!(integrator, cache::Exp4Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -825,7 +825,7 @@ function perform_step!(integrator, cache::EPIRK4s3AConstantCache, repeat_step = U3 = uprev + K[:, 2] R2 = f(U2, p, t + dt / 2) - f0 - J * K[:, 1] # remainder of U2 R3 = f(U3, p, t + 2dt / 3) - f0 - J * K[:, 2] # remainder of U3 - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) # Update u (horizontally) B = zeros(eltype(f0), length(f0), 5) @@ -836,7 +836,7 @@ function perform_step!(integrator, cache::EPIRK4s3AConstantCache, repeat_step = # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -870,7 +870,7 @@ function perform_step!(integrator, cache::EPIRK4s3ACache, repeat_step = false) @.. broadcast=false rtmp=rtmp - f0 - rtmp2 # rtmp is now R3 B[:, 4] .-= (13.5 / dt^2) * rtmp B[:, 5] .+= (81 / dt^3) * rtmp - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) # Update u du = @view(K[:, 1]) @@ -879,7 +879,7 @@ function perform_step!(integrator, cache::EPIRK4s3ACache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -901,7 +901,7 @@ function perform_step!(integrator, cache::EPIRK4s3BConstantCache, repeat_step = U3 = uprev + K[:, 2] R2 = f(U2, p, t + dt / 2) - f0 - J * K[:, 1] # remainder of U2 R3 = f(U3, p, t + 3dt / 4) - f0 - J * K[:, 2] # remainder of U3 - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) # Update u (horizontally) B = zeros(eltype(f0), length(f0), 5) @@ -912,7 +912,7 @@ function perform_step!(integrator, cache::EPIRK4s3BConstantCache, repeat_step = # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -949,7 +949,7 @@ function perform_step!(integrator, cache::EPIRK4s3BCache, repeat_step = false) @.. broadcast=false rtmp=rtmp - f0 - rtmp2 # rtmp is now R3 B[:, 4] .-= (16 / dt^2) * rtmp B[:, 5] .+= (144 / dt^3) * rtmp - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) # Update u fill!(@view(B[:, 3]), zero(eltype(B))) @@ -960,7 +960,7 @@ function perform_step!(integrator, cache::EPIRK4s3BCache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -981,7 +981,7 @@ function perform_step!(integrator, cache::EPIRK5s3ConstantCache, repeat_step = f k = phiv_timestep(48dt / 55, J, B; kwargs...) U2 = uprev + k R2 = f(U2, p, t + 48dt / 55) - f0 - J * k # remainder of U2 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Compute U3 horizontally B[:, 2] = (53 / 5) * f0 @@ -990,7 +990,7 @@ function perform_step!(integrator, cache::EPIRK5s3ConstantCache, repeat_step = f k = phiv_timestep(4dt / 9, J, B; kwargs...) U3 = uprev + k R3 = f(U3, p, t + 4dt / 9) - f0 - J * k # remainder of U3 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Update u (horizontally) B = fill(zero(eltype(f0)), length(f0), 5) @@ -1001,7 +1001,7 @@ function perform_step!(integrator, cache::EPIRK5s3ConstantCache, repeat_step = f # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1027,7 +1027,7 @@ function perform_step!(integrator, cache::EPIRK5s3Cache, repeat_step = false) @.. broadcast=false tmp=uprev + k # tmp is now U2 f(rtmp, tmp, p, t + 48dt / 55) mul!(rtmp2, J, k) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false rtmp=rtmp - f0 - rtmp2 # rtmp is now R2 # Compute U3 horizontally @@ -1044,7 +1044,7 @@ function perform_step!(integrator, cache::EPIRK5s3Cache, repeat_step = false) @.. broadcast=false tmp=uprev + k # tmp is now U3 f(rtmp, tmp, p, t + 4dt / 9) mul!(rtmp2, J, k) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false rtmp=rtmp - f0 - rtmp2 # rtmp is now R3 B[:, 4] .+= (2187 / (106 * dt^2)) .* rtmp B[:, 5] .-= (2187 / (106 * dt^3)) .* rtmp @@ -1055,7 +1055,7 @@ function perform_step!(integrator, cache::EPIRK5s3Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -1074,7 +1074,7 @@ function perform_step!(integrator, cache::EXPRB53s3ConstantCache, repeat_step = K = phiv_timestep([dt / 2, 9dt / 10], J, B; kwargs...) U2 = uprev + K[:, 1] R2 = f(U2, p, t + dt / 2) - f0 - J * K[:, 1] # remainder of U2 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) U3 = uprev + K[:, 2] # partially # Compute the second group for U3 @@ -1082,7 +1082,7 @@ function perform_step!(integrator, cache::EXPRB53s3ConstantCache, repeat_step = K = phiv_timestep([dt / 2, 9dt / 10], J, B; kwargs...) U3 .+= 216 / (25 * dt^2) .* K[:, 1] + 8 / dt^2 .* K[:, 2] R3 = f(U3, p, t + 9dt / 10) - f0 - J * (U3 - uprev) # remainder of U3 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Compute the third group for u B = fill(zero(eltype(f0)), length(f0), 5) @@ -1093,7 +1093,7 @@ function perform_step!(integrator, cache::EXPRB53s3ConstantCache, repeat_step = # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1117,7 +1117,7 @@ function perform_step!(integrator, cache::EXPRB53s3Cache, repeat_step = false) @.. broadcast=false tmp=uprev + @view(K[:, 1]) # tmp is now U2 f(rtmp, tmp, p, t + dt / 2) mul!(rtmp2, J, @view(K[:, 1])) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false rtmp=rtmp - f0 - rtmp2 # rtmp is now R2 @.. broadcast=false tmp=uprev + @view(K[:, 2]) # tmp is now U3 (partially) @@ -1132,7 +1132,7 @@ function perform_step!(integrator, cache::EXPRB53s3Cache, repeat_step = false) ## U3 and R3 @views tmp .+= 216 / (25 * dt^2) .* K[:, 1] + 8 / dt^2 .* K[:, 2] # tmp is now U3 f(rtmp, tmp, p, t + 9dt / 10) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) tmp .-= uprev mul!(rtmp2, J, tmp) @.. broadcast=false rtmp=rtmp - f0 - rtmp2 # rtmp is now R3 @@ -1147,7 +1147,7 @@ function perform_step!(integrator, cache::EXPRB53s3Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -1177,7 +1177,7 @@ function perform_step!(integrator, cache::EPIRK5P1ConstantCache, repeat_step = f ## U1 and R1 U1 = uprev + K1[:, 1] R1 = f(U1, p, t + g11) - f0 - J * K1[:, 1] # remainder of U1 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Compute the second column (R1) B = [zero(R1) R1] @@ -1185,7 +1185,7 @@ function perform_step!(integrator, cache::EPIRK5P1ConstantCache, repeat_step = f ## U2 and R2 U2 = uprev + K1[:, 2] + a22 * k2 R2 = f(U2, p, t + g21) - f0 - J * (U2 - uprev) # remainder of U2 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Compute the third column (dR = R2 - 2R1) B = fill(zero(eltype(f0)), length(f0), 4) @@ -1196,7 +1196,7 @@ function perform_step!(integrator, cache::EPIRK5P1ConstantCache, repeat_step = f # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1230,7 +1230,7 @@ function perform_step!(integrator, cache::EPIRK5P1Cache, repeat_step = false) @.. broadcast=false tmp=uprev + @view(K[:, 1]) # tmp is now U1 f(rtmp, tmp, p, t + g11) mul!(rtmp2, J, @view(K[:, 1])) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false rtmp=rtmp - f0 - rtmp2 # rtmp is now R1 @.. broadcast=false tmp=uprev + @view(K[:, 2]) # partially update U2 (stored tmp) @.. broadcast=false u=uprev + @view(K[:, 3]) # partially update u @@ -1243,7 +1243,7 @@ function perform_step!(integrator, cache::EPIRK5P1Cache, repeat_step = false) ## U2 and R2 axpy!(a22, k, tmp) # tmp is now U2 f(rtmp, tmp, p, t + g21) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) tmp .-= uprev mul!(rtmp2, J, tmp) @.. broadcast=false rtmp=rtmp - f0 - rtmp2 # rtmp is now R2 @@ -1257,7 +1257,7 @@ function perform_step!(integrator, cache::EPIRK5P1Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -1289,7 +1289,7 @@ function perform_step!(integrator, cache::EPIRK5P2ConstantCache, repeat_step = f ## U1 and R1 U1 = uprev + K1[:, 1] R1 = f(U1, p, t + g11) - f0 - J * K1[:, 1] # remainder of U1 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Compute the second column (R1) B = [zero(R1) zero(R1) R1] @@ -1297,7 +1297,7 @@ function perform_step!(integrator, cache::EPIRK5P2ConstantCache, repeat_step = f ## U2 and R2 U2 = uprev + K1[:, 2] + a22 * k2 R2 = f(U2, p, t + g21) - f0 - J * (U2 - uprev) # remainder of U2 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Compute the third column (dR = R2 - 2R1) dR = R2 - 2R1 @@ -1308,7 +1308,7 @@ function perform_step!(integrator, cache::EPIRK5P2ConstantCache, repeat_step = f # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1344,7 +1344,7 @@ function perform_step!(integrator, cache::EPIRK5P2Cache, repeat_step = false) @.. broadcast=false tmp=uprev + @view(K[:, 1]) # tmp is now U1 f(rtmp, tmp, p, t + g11) mul!(rtmp2, J, @view(K[:, 1])) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false rtmp=rtmp - f0 - rtmp2 # rtmp is now R1 @.. broadcast=false tmp=uprev + @view(K[:, 2]) # partially update U2 (stored in tmp) @.. broadcast=false u=uprev + @view(K[:, 3]) # partially update u @@ -1358,7 +1358,7 @@ function perform_step!(integrator, cache::EPIRK5P2Cache, repeat_step = false) ## U2 and R2 axpy!(a22, k, tmp) # tmp is now U2 f(rtmp, tmp, p, t + g21) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) tmp .-= uprev mul!(rtmp2, J, tmp) @.. broadcast=false rtmp=rtmp - f0 - rtmp2 # rtmp is now R2 @@ -1374,7 +1374,7 @@ function perform_step!(integrator, cache::EPIRK5P2Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -1390,7 +1390,7 @@ function perform_step!(integrator, cache::Exprb32ConstantCache, repeat_step = fa opnorm = integrator.opts.internalopnorm, iop = alg.iop) U2 = uprev + dt * w1[:, 2] F2 = _compute_nl(f, U2, p, t + dt, A) + A * uprev - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) w2 = phiv(dt, A, F2, 3; m = min(alg.m, size(A, 1)), opnorm = integrator.opts.internalopnorm, iop = alg.iop) u = uprev + dt * (w1[:, 2] - 2w1[:, 4] + 2w2[:, 4]) @@ -1404,7 +1404,7 @@ function perform_step!(integrator, cache::Exprb32ConstantCache, repeat_step = fa # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1427,7 +1427,7 @@ function perform_step!(integrator, cache::Exprb32Cache, repeat_step = false) # Krylov for F2 @muladd @.. broadcast=false tmp=uprev + dt * @view(w1[:, 2]) _compute_nl!(F2, f, tmp, p, t + dt, J, rtmp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) F2 .+= mul!(rtmp, J, uprev) arnoldi!( Ks, J, F2; m = min(alg.m, size(J, 1)), opnorm = integrator.opts.internalopnorm, @@ -1448,7 +1448,7 @@ function perform_step!(integrator, cache::Exprb32Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -1467,12 +1467,12 @@ function perform_step!(integrator, cache::Exprb43ConstantCache, repeat_step = fa w1 = phiv(dt, Ks, 4) U2 = uprev + dt / 2 * w1_half[:, 2] F2 = _compute_nl(f, U2, p, t + dt / 2, A) + Au - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Krylov on F2 (second column) w2 = phiv(dt, A, F2, 4; kwargs...) U3 = uprev + dt * w2[:, 2] F3 = _compute_nl(f, U3, p, t + dt, A) + Au - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Krylov on F3 (third column) w3 = phiv(dt, A, F3, 4; kwargs...) u = uprev + @@ -1488,7 +1488,7 @@ function perform_step!(integrator, cache::Exprb43ConstantCache, repeat_step = fa # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1514,14 +1514,14 @@ function perform_step!(integrator, cache::Exprb43Cache, repeat_step = false) @muladd @.. broadcast=false @views tmp = uprev + halfdt * w1_half[:, 2] # tmp is U2 _compute_nl!(F2, f, tmp, p, t + halfdt, J, rtmp) F2 .+= Au - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Krylov for F2 arnoldi!(Ks, J, F2; kwargs...) phiv!(w2, dt, Ks, 4; cache = phiv_cache) @muladd @.. broadcast=false @views tmp = uprev + dt * w2[:, 2] # tmp is U3 _compute_nl!(F3, f, tmp, p, t + dt, J, rtmp) F3 .+= Au - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Krylov for F3 (third column) arnoldi!(Ks, J, F3; kwargs...) phiv!(w3, dt, Ks, 4; cache = phiv_cache) @@ -1539,7 +1539,7 @@ function perform_step!(integrator, cache::Exprb43Cache, repeat_step = false) # Update integrator state f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -1552,7 +1552,7 @@ function initialize!(integrator, cache::ETD2ConstantCache) # Pre-start fsal lin = integrator.f.f1(integrator.uprev, integrator.p, integrator.t) nl = integrator.f.f2(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 nlprev = zero(nl) # to be computed in the first iteration via ETD1 integrator.fsalfirst = ETD2Fsal(lin, nl, nlprev) @@ -1581,7 +1581,7 @@ function perform_step!(integrator, cache::ETD2ConstantCache, repeat_step = false nlprev = nl lin = f.f1(u, p, t + dt) nl = f.f2(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.k[2] = lin + nl integrator.fsallast.lin = lin @@ -1599,7 +1599,7 @@ function initialize!(integrator, cache::ETD2Cache) @unpack lin, nl = integrator.fsalfirst integrator.f.f1(lin, integrator.uprev, integrator.p, integrator.t) integrator.f.f2(nl, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 # Avoid undefined entries if k is an array of arrays @@ -1630,7 +1630,7 @@ function perform_step!(integrator, cache::ETD2Cache, repeat_step = false) fsallast.nlprev .= nl f.f1(fsallast.lin, u, p, t + dt) f.f2(fsallast.nl, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 @.. broadcast=false integrator.k[2]=fsallast.lin + fsallast.nl end diff --git a/lib/OrdinaryDiffEqExtrapolation/Project.toml b/lib/OrdinaryDiffEqExtrapolation/Project.toml index 96da66f8ba..325138cd55 100644 --- a/lib/OrdinaryDiffEqExtrapolation/Project.toml +++ b/lib/OrdinaryDiffEqExtrapolation/Project.toml @@ -20,7 +20,7 @@ DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" LinearSolve = "2.32.0" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqDifferentiation = "<0.0.1, 1" Polyester = "0.7.16" Random = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqExtrapolation/src/OrdinaryDiffEqExtrapolation.jl b/lib/OrdinaryDiffEqExtrapolation/src/OrdinaryDiffEqExtrapolation.jl index 1497208b5f..0d556b647e 100644 --- a/lib/OrdinaryDiffEqExtrapolation/src/OrdinaryDiffEqExtrapolation.jl +++ b/lib/OrdinaryDiffEqExtrapolation/src/OrdinaryDiffEqExtrapolation.jl @@ -18,6 +18,7 @@ import OrdinaryDiffEqCore: alg_order, alg_maximum_order, get_current_adaptive_or _digest_beta1_beta2, timedepentdtmin, _unwrap_val, _reshape, _vec using DiffEqBase, FastBroadcast, Polyester, MuladdMacro, RecursiveArrayTools, LinearSolve +import OrdinaryDiffEqCore import OrdinaryDiffEqDifferentiation: TimeDerivativeWrapper, UDerivativeWrapper, calc_J, WOperator, TimeGradientWrapper, UJacobianWrapper, build_grad_config, diff --git a/lib/OrdinaryDiffEqExtrapolation/src/extrapolation_perform_step.jl b/lib/OrdinaryDiffEqExtrapolation/src/extrapolation_perform_step.jl index 48fec8c66d..8e4f3554a6 100644 --- a/lib/OrdinaryDiffEqExtrapolation/src/extrapolation_perform_step.jl +++ b/lib/OrdinaryDiffEqExtrapolation/src/extrapolation_perform_step.jl @@ -7,7 +7,7 @@ function initialize!(integrator, cache::AitkenNevilleCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) cache.step_no = 1 alg = unwrap_alg(integrator, false) @@ -28,11 +28,11 @@ function perform_step!(integrator, cache::AitkenNevilleCache, repeat_step = fals # Solve using Euler method @muladd @.. broadcast=false u=uprev + dt_temp * fsalfirst f(k, u, p, t + dt_temp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) for j in 2:(2^(i - 1)) @muladd @.. broadcast=false u=u + dt_temp * k f(k, u, p, t + j * dt_temp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @.. broadcast=false T[i, 1]=u end @@ -65,7 +65,7 @@ function perform_step!(integrator, cache::AitkenNevilleCache, repeat_step = fals end end end - integrator.stats.nf += 2^max_order - 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2)^max_order - 1 end # Richardson extrapolation @@ -121,14 +121,14 @@ function perform_step!(integrator, cache::AitkenNevilleCache, repeat_step = fals @.. broadcast=false u=T[cache.cur_order, cache.cur_order] cache.step_no = cache.step_no + 1 f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::AitkenNevilleConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -153,12 +153,12 @@ function perform_step!(integrator, cache::AitkenNevilleConstantCache, repeat_ste # Solve using Euler method with dt_temp = dt/n_{i} @muladd u = @.. broadcast=false uprev+dt_temp * integrator.fsalfirst k = f(u, p, t + dt_temp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) for j in 2:(2^(i - 1)) @muladd u = @.. broadcast=false u+dt_temp * k k = f(u, p, t + j * dt_temp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end T[i, 1] = u end @@ -185,7 +185,7 @@ function perform_step!(integrator, cache::AitkenNevilleConstantCache, repeat_ste end end - integrator.stats.nf += 2^max_order - 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2)^max_order - 1 end # Richardson extrapolation @@ -243,7 +243,7 @@ function perform_step!(integrator, cache::AitkenNevilleConstantCache, repeat_ste integrator.u = T[cache.cur_order, cache.cur_order] k = f(integrator.u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = k integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -258,7 +258,7 @@ function initialize!(integrator, cache::ImplicitEulerExtrapolationCache) resize!(integrator.k, integrator.kshortsize) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) cache.step_no = 1 #alg = unwrap_alg(integrator, true) @@ -332,7 +332,7 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationCache, @.. broadcast=false diff1[1]=u_tmps[1] - u_tmps2[1] f(k_tmps[1], u_tmps[1], p, t + j * dt_temp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @.. broadcast=false T[index, 1]=u_tmps[1] @@ -478,7 +478,7 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationCache, @.. broadcast=false k_tmps[1]=-k_tmps[1] @.. broadcast=false u_tmps[1]=u_tmps[1] + k_tmps[1] f(k_tmps[1], u_tmps[1], p, t + j * dt_temp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @.. broadcast=false T[n_curr + 1, 1]=u_tmps[1] @@ -511,7 +511,7 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationCache, cache.step_no = cache.step_no + 1 f(integrator.fsallast, integrator.u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::ImplicitEulerExtrapolationConstantCache) @@ -574,7 +574,7 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationConstantCach end diff1 = u_tmp - u_tmp2 k_copy = f(u_tmp, p, t + j * dt_temp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end T[index, 1] = u_tmp @@ -681,7 +681,7 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationConstantCach integrator.stats.nsolve += 1 u_tmp = u_tmp + k k_copy = f(u_tmp, p, t + j * dt_temp) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end T[n_curr + 1, 1] = u_tmp @@ -714,7 +714,7 @@ function perform_step!(integrator, cache::ImplicitEulerExtrapolationConstantCach # Use extrapolated value of u integrator.u = T[n_curr + 1, n_curr + 1] k_temp = f(integrator.u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = k_temp integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -771,7 +771,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointDeuflhardCache, @.. broadcast=false u_temp1=u_temp2 + dt_int * fsalfirst # Euler starting step for j in 2:j_int f(k, cache.u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false T[i + 1]=u_temp2 + 2 * dt_int * k # Explicit Midpoint rule @.. broadcast=false u_temp2=u_temp1 @.. broadcast=false u_temp1=T[i + 1] @@ -891,7 +891,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointDeuflhardCache, @.. broadcast=false u_temp1=u_temp2 + dt_int * fsalfirst # Euler starting step for j in 2:j_int f(k, cache.u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false T[n_curr + 1]=u_temp2 + 2 * dt_int * k @.. broadcast=false u_temp2=u_temp1 @.. broadcast=false u_temp1=T[n_curr + 1] @@ -935,7 +935,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointDeuflhardCache, end f(cache.k, integrator.u, p, t + dt) # Update FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::ExtrapolationMidpointDeuflhardConstantCache) @@ -992,7 +992,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointDeuflhardConstant u_temp1 = u_temp2 + dt_int * integrator.fsalfirst # Euler starting step for j in 2:j_int T[i + 1] = u_temp2 + 2 * dt_int * f(u_temp1, p, t + (j - 1) * dt_int) # Explicit Midpoint rule - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u_temp2 = u_temp1 u_temp1 = T[i + 1] end @@ -1094,7 +1094,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointDeuflhardConstant for j in 2:j_int T[n_curr + 1] = u_temp2 + 2 * dt_int * f(u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u_temp2 = u_temp1 u_temp1 = T[n_curr + 1] end @@ -1203,7 +1203,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationCache, @.. broadcast=false diff1[1]=u_temp1 - u_temp2 for j in 2:j_int f(k, cache.u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false linsolve_tmps[1]=dt_int * k - (u_temp1 - u_temp2) linsolve = cache.linsolve[1] @@ -1481,7 +1481,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationCache, @.. broadcast=false u_temp1=u_temp2 + k # Euler starting step for j in 2:j_int f(k, cache.u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false linsolve_tmps[1]=dt_int * k - (u_temp1 - u_temp2) linsolve = cache.linsolve[1] @@ -1534,7 +1534,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationCache, end f(cache.k, integrator.u, p, t + dt) # Update FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::ImplicitDeuflhardExtrapolationConstantCache) @@ -1599,7 +1599,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationConstant -_vec(dt_int * f(u_temp1, p, t + (j - 1) * dt_int) - (u_temp1 - u_temp2)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u_temp2 = u_temp1 u_temp1 = T[i + 1] if (i <= 1) @@ -1647,7 +1647,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationConstant t + (j - 1) * dt_int) - (u_temp3 - u_temp4)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u_temp4 = u_temp3 u_temp3 = T[index + 1] if (index <= 1) @@ -1693,7 +1693,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationConstant t + (j - 1) * dt_int) - (u_temp3 - u_temp4)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u_temp4 = u_temp3 u_temp3 = T[index + 1] if (index <= 1) @@ -1765,7 +1765,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationConstant f(u_temp1, p, t + (j - 1) * dt_int) - (u_temp1 - u_temp2)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u_temp2 = u_temp1 u_temp1 = T[n_curr + 1] end @@ -1801,7 +1801,7 @@ function perform_step!(integrator, cache::ImplicitDeuflhardExtrapolationConstant integrator.fsallast = f(u, p, t + dt) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::ExtrapolationMidpointHairerWannerCache) @@ -1857,7 +1857,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointHairerWannerCache @.. broadcast=false u_temp1=u_temp2 + dt_int * fsalfirst # Euler starting step for j in 2:j_int f(k, cache.u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false T[i + 1]=u_temp2 + 2 * dt_int * k # Explicit Midpoint rule @.. broadcast=false u_temp2=u_temp1 @.. broadcast=false u_temp1=T[i + 1] @@ -1979,7 +1979,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointHairerWannerCache @.. broadcast=false u_temp1=u_temp2 + dt_int * fsalfirst # Euler starting step for j in 2:j_int f(k, cache.u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false T[n_curr + 1]=u_temp2 + 2 * dt_int * k @.. broadcast=false u_temp2=u_temp1 @.. broadcast=false u_temp1=T[n_curr + 1] @@ -2023,7 +2023,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointHairerWannerCache end f(cache.k, integrator.u, p, t + dt) # Update FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::ExtrapolationMidpointHairerWannerConstantCache) @@ -2082,7 +2082,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointHairerWannerConst u_temp1 = u_temp2 + dt_int * integrator.fsalfirst # Euler starting step for j in 2:j_int T[i + 1] = u_temp2 + 2 * dt_int * f(u_temp1, p, t + (j - 1) * dt_int) # Explicit Midpoint rule - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u_temp2 = u_temp1 u_temp1 = T[i + 1] end @@ -2183,7 +2183,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointHairerWannerConst for j in 2:j_int T[n_curr + 1] = u_temp2 + 2 * dt_int * f(u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u_temp2 = u_temp1 u_temp1 = T[n_curr + 1] end @@ -2219,7 +2219,7 @@ function perform_step!(integrator, cache::ExtrapolationMidpointHairerWannerConst integrator.fsallast = f(u, p, t + dt) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::ImplicitHairerWannerExtrapolationConstantCache) @@ -2287,7 +2287,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationConst -_vec(dt_int * f(u_temp1, p, t + (j - 1) * dt_int) - (u_temp1 - u_temp2)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if (j == j_int + 1) T[i + 1] = 0.5(T[i + 1] + u_temp2) end @@ -2339,7 +2339,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationConst t + (j - 1) * dt_int) - (u_temp3 - u_temp4)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if (j == j_int + 1) T[index + 1] = 0.5(T[index + 1] + u_temp4) end @@ -2387,7 +2387,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationConst t + (j - 1) * dt_int) - (u_temp3 - u_temp4)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if (j == j_int + 1) T[index + 1] = 0.5(T[index + 1] + u_temp4) end @@ -2464,7 +2464,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationConst f(u_temp1, p, t + (j - 1) * dt_int) - (u_temp1 - u_temp2)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if (j == j_int + 1) T[n_curr + 1] = 0.5(T[n_curr + 1] + u_temp2) end @@ -2577,7 +2577,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache @.. broadcast=false diff1[1]=u_temp1 - u_temp2 for j in 2:(j_int + 1) f(k, cache.u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false linsolve_tmps[1]=dt_int * k - (u_temp1 - u_temp2) linsolve = cache.linsolve[1] @@ -2862,7 +2862,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache @.. broadcast=false u_temp1=u_temp2 + k # Euler starting step for j in 2:(j_int + 1) f(k, cache.u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false linsolve_tmps[1]=dt_int * k - (u_temp1 - u_temp2) linsolve = cache.linsolve[1] @@ -2924,7 +2924,7 @@ function perform_step!(integrator, cache::ImplicitHairerWannerExtrapolationCache end f(cache.k, integrator.u, p, t + dt) # Update FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::ImplicitEulerBarycentricExtrapolationConstantCache) @@ -2992,7 +2992,7 @@ function perform_step!(integrator, _reshape( W \ -_vec(dt_int * f(u_temp1, p, t + (j - 1) * dt_int)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if (j == j_int + 1) T[i + 1] = 0.25(T[i + 1] + 2 * u_temp1 + u_temp2) end @@ -3042,7 +3042,7 @@ function perform_step!(integrator, -_vec(dt_int * f(u_temp3, p, t + (j - 1) * dt_int)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if (j == j_int + 1) T[index + 1] = 0.25(T[index + 1] + 2 * u_temp3 + u_temp4) end @@ -3088,7 +3088,7 @@ function perform_step!(integrator, -_vec(dt_int * f(u_temp3, p, t + (j - 1) * dt_int)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if (j == j_int + 1) T[index + 1] = 0.25(T[index + 1] + 2 * u_temp3 + u_temp4) end @@ -3163,7 +3163,7 @@ function perform_step!(integrator, -_vec(dt_int * f(u_temp1, p, t + (j - 1) * dt_int)), axes(uprev)) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if (j == j_int + 1) T[n_curr + 1] = 0.25(T[n_curr + 1] + 2 * u_temp1 + u_temp2) end @@ -3278,7 +3278,7 @@ function perform_step!(integrator, cache::ImplicitEulerBarycentricExtrapolationC @.. broadcast=false diff1[1]=u_temp1 - u_temp2 for j in 2:(j_int + 1) f(k, cache.u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false linsolve_tmps[1]=dt_int * k linsolve = cache.linsolve[1] @@ -3578,7 +3578,7 @@ function perform_step!(integrator, cache::ImplicitEulerBarycentricExtrapolationC @.. broadcast=false u_temp1=u_temp2 + k # Euler starting step for j in 2:(j_int + 1) f(k, cache.u_temp1, p, t + (j - 1) * dt_int) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false linsolve_tmps[1]=dt_int * k linsolve = cache.linsolve[1] @@ -3635,5 +3635,5 @@ function perform_step!(integrator, cache::ImplicitEulerBarycentricExtrapolationC end f(cache.k, integrator.u, p, t + dt) # Update FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end diff --git a/lib/OrdinaryDiffEqFIRK/Project.toml b/lib/OrdinaryDiffEqFIRK/Project.toml index 38efd4bb8c..200b1c0544 100644 --- a/lib/OrdinaryDiffEqFIRK/Project.toml +++ b/lib/OrdinaryDiffEqFIRK/Project.toml @@ -24,7 +24,7 @@ LinearAlgebra = "<0.0.1, 1" LinearSolve = "2.32.0" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqDifferentiation = "<0.0.1, 1" OrdinaryDiffEqNonlinearSolve = "<0.0.1, 1" Random = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqFIRK/src/OrdinaryDiffEqFIRK.jl b/lib/OrdinaryDiffEqFIRK/src/OrdinaryDiffEqFIRK.jl index 7f0a163319..9d92ae5b59 100644 --- a/lib/OrdinaryDiffEqFIRK/src/OrdinaryDiffEqFIRK.jl +++ b/lib/OrdinaryDiffEqFIRK/src/OrdinaryDiffEqFIRK.jl @@ -22,6 +22,7 @@ using SciMLOperators: AbstractSciMLOperator using LinearAlgebra: I, UniformScaling, mul!, lu import LinearSolve import FastBroadcast: @.. +import OrdinaryDiffEqCore using OrdinaryDiffEqDifferentiation: UJacobianWrapper, build_J_W, build_jac_config, UDerivativeWrapper, calc_J!, dolinsolve, calc_J, diff --git a/lib/OrdinaryDiffEqFIRK/src/firk_perform_step.jl b/lib/OrdinaryDiffEqFIRK/src/firk_perform_step.jl index b60e9b0e38..4c55660956 100644 --- a/lib/OrdinaryDiffEqFIRK/src/firk_perform_step.jl +++ b/lib/OrdinaryDiffEqFIRK/src/firk_perform_step.jl @@ -42,7 +42,7 @@ function initialize!(integrator, cache::RadauIIA5ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -55,7 +55,7 @@ function initialize!(integrator, cache::RadauIIA9ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -72,7 +72,7 @@ function initialize!(integrator, cache::RadauIIA3Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) nothing end @@ -84,7 +84,7 @@ function initialize!(integrator, cache::RadauIIA5Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive @unpack abstol, reltol = integrator.opts if reltol isa Number @@ -106,7 +106,7 @@ function initialize!(integrator, cache::RadauIIA9Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive @unpack abstol, reltol = integrator.opts if reltol isa Number @@ -160,7 +160,7 @@ end # evaluate function ff1 = f(uprev + z1, p, t + c1 * dt) ff2 = f(uprev + z2, p, t + c2 * dt) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) fw1 = @. TI11 * ff1 + TI12 * ff2 fw2 = @. TI21 * ff1 + TI22 * ff2 @@ -280,7 +280,7 @@ end f(fsallast, tmp, p, t + c1 * dt) @. tmp = uprev + z2 f(k2, tmp, p, t + c2 * dt) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) @. fw1 = TI11 * fsallast + TI12 * k2 @. fw2 = TI21 * fsallast + TI22 * k2 @@ -371,7 +371,7 @@ end integrator.EEst = internalnorm(atmp, t) end f(fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return end @@ -437,7 +437,7 @@ end ff1 = f(uprev + z1, p, t + c1 * dt) ff2 = f(uprev + z2, p, t + c2 * dt) ff3 = f(uprev + z3, p, t + dt) # c3 = 1 - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) fw1 = @.. broadcast=false TI11*ff1+TI12*ff2+TI13*ff3 fw2 = @.. broadcast=false TI21*ff1+TI22*ff2+TI23*ff3 @@ -522,7 +522,7 @@ end if !(integrator.EEst < oneunit(integrator.EEst)) && integrator.iter == 1 || integrator.u_modified f0 = f(uprev .+ utilde, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) utilde = @.. broadcast=false f0+tmp alg.smooth_est && (utilde = LU1 \ utilde; integrator.stats.nsolve += 1) atmp = calculate_residuals(utilde, uprev, u, atol, rtol, internalnorm, t) @@ -541,7 +541,7 @@ end end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -619,7 +619,7 @@ end f(k2, tmp, p, t + c2 * dt) @.. broadcast=false tmp=uprev + z3 f(k3, tmp, p, t + dt) # c3 = 1 - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) @.. broadcast=false fw1=TI11 * fsallast + TI12 * k2 + TI13 * k3 @.. broadcast=false fw2=TI21 * fsallast + TI22 * k2 + TI23 * k3 @@ -755,7 +755,7 @@ end integrator.u_modified @.. broadcast=false utilde=uprev + utilde f(fsallast, utilde, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false ubuff=fsallast + tmp if alg.smooth_est @@ -780,7 +780,7 @@ end end end f(fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return end @@ -878,7 +878,7 @@ end ff3 = f(uprev + z3, p, t + c3 * dt) ff4 = f(uprev + z4, p, t + c4 * dt) ff5 = f(uprev + z5, p, t + dt) # c5 = 1 - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) fw1 = @.. broadcast=false TI11*ff1+TI12*ff2+TI13*ff3+TI14*ff4+TI15*ff5 fw2 = @.. broadcast=false TI21*ff1+TI22*ff2+TI23*ff3+TI24*ff4+TI25*ff5 @@ -982,7 +982,7 @@ end if !(integrator.EEst < oneunit(integrator.EEst)) && integrator.iter == 1 || integrator.u_modified f0 = f(uprev .+ utilde, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) utilde = @.. broadcast=false f0+tmp alg.smooth_est && (utilde = LU1 \ utilde; integrator.stats.nsolve += 1) atmp = calculate_residuals(utilde, uprev, u, atol, rtol, internalnorm, t) @@ -1007,7 +1007,7 @@ end end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1120,7 +1120,7 @@ end f(k4, tmp, p, t + c4 * dt) @.. broadcast=false tmp=uprev + z5 f(k5, tmp, p, t + dt) # c5 = 1 - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) @.. broadcast=false fw1=TI11 * fsallast + TI12 * k2 + TI13 * k3 + TI14 * k4 + TI15 * k5 @@ -1304,7 +1304,7 @@ end integrator.u_modified @.. broadcast=false utilde=uprev + utilde f(fsallast, utilde, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false ubuff=fsallast + tmp if alg.smooth_est @@ -1336,6 +1336,6 @@ end end f(fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return end diff --git a/lib/OrdinaryDiffEqFeagin/src/OrdinaryDiffEqFeagin.jl b/lib/OrdinaryDiffEqFeagin/src/OrdinaryDiffEqFeagin.jl index a4ad6d2fd3..e49507ebae 100644 --- a/lib/OrdinaryDiffEqFeagin/src/OrdinaryDiffEqFeagin.jl +++ b/lib/OrdinaryDiffEqFeagin/src/OrdinaryDiffEqFeagin.jl @@ -13,6 +13,7 @@ import OrdinaryDiffEqCore: alg_order, calculate_residuals!, using FastBroadcast, Polyester, MuladdMacro, RecursiveArrayTools using DiffEqBase: @def, @tight_loop_macros using Static: False +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqFeagin/src/feagin_rk_perform_step.jl b/lib/OrdinaryDiffEqFeagin/src/feagin_rk_perform_step.jl index 73dd68e2cf..01f352fd39 100644 --- a/lib/OrdinaryDiffEqFeagin/src/feagin_rk_perform_step.jl +++ b/lib/OrdinaryDiffEqFeagin/src/feagin_rk_perform_step.jl @@ -1,6 +1,6 @@ function initialize!(integrator, cache::Feagin10ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -66,7 +66,7 @@ end a1612 * k13 + a1613 * k14 + a1614 * k15 + a1615 * k16), p, t + c16 * dt) - integrator.stats.nf += 16 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 16) u = uprev + dt * (b1 * k1 + b2 * k2 + b3 * k3 + b5 * k5 + b7 * k7 + b9 * k9 + b10 * k10 + b11 * k11 + @@ -78,7 +78,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end k = f(u, p, t + dt) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = k integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -93,7 +93,7 @@ function initialize!(integrator, cache::Feagin10Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #= @@ -256,7 +256,7 @@ end b13 * k13[i] + b14 * k14[i] + b15 * k15[i] + b16 * k16[i] + b17 * k17[i]) end - integrator.stats.nf += 16 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 16) step_limiter!(u, integrator, p, t + dt) @@ -269,12 +269,12 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end f(integrator.fsallast, u, p, t + dt) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::Feagin12ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -396,7 +396,7 @@ end (a2421 * k22 + a2422 * k23 + a2423 * k24)), p, t + c24 * dt) - integrator.stats.nf += 24 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 24) u = uprev + dt * ((b1 * k1 + b2 * k2 + b3 * k3 + b5 * k5) + (b7 * k7 + b8 * k8 + b10 * k10 + b11 * k11) + @@ -404,7 +404,7 @@ end (b17 * k17 + b18 * k18 + b19 * k19 + b20 * k20) + (b21 * k21 + b22 * k22 + b23 * k23) + (b24 * k24 + b25 * k25)) k = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = k if integrator.opts.adaptive utilde = @.. broadcast=false dt*(k2-k24)*adaptiveConst @@ -425,7 +425,7 @@ function initialize!(integrator, cache::Feagin12Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #= @@ -672,7 +672,7 @@ end (b21 * k21[i] + b22 * k22[i] + b23 * k23[i]) + (b24 * k24[i] + b25 * k25[i])) end - integrator.stats.nf += 24 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 24) step_limiter!(u, integrator, p, t + dt) @@ -685,12 +685,12 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::Feagin14ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -886,7 +886,7 @@ end a3429 * k30 + a3430 * k31 + a3431 * k32 + a3432 * k33 + a3433 * k34), p, t + c34 * dt) - integrator.stats.nf += 34 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 34) u = uprev + dt * (b1 * k1 + b2 * k2 + b3 * k3 + b5 * k5 + b7 * k7 + b8 * k8 + b10 * k10 + b11 * k11 + @@ -901,7 +901,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end k = f(u, p, t + dt) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = k integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -916,7 +916,7 @@ function initialize!(integrator, cache::Feagin14Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #= @@ -1280,7 +1280,7 @@ end b31 * k31[i] + b32 * k32[i] + b33 * k33[i] + b34 * k34[i] + b35 * k35[i]) end - integrator.stats.nf += 35 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 35) step_limiter!(u, integrator, p, t + dt) @@ -1293,5 +1293,5 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end f(integrator.fsallast, u, p, t + dt) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end diff --git a/lib/OrdinaryDiffEqFunctionMap/Project.toml b/lib/OrdinaryDiffEqFunctionMap/Project.toml index 6a4bf4bfcc..a556751605 100644 --- a/lib/OrdinaryDiffEqFunctionMap/Project.toml +++ b/lib/OrdinaryDiffEqFunctionMap/Project.toml @@ -18,7 +18,7 @@ DiffEqBase = "6.152.2" DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" Random = "<0.0.1, 1" RecursiveArrayTools = "3.27.0" Reexport = "1.2.2" diff --git a/lib/OrdinaryDiffEqFunctionMap/src/OrdinaryDiffEqFunctionMap.jl b/lib/OrdinaryDiffEqFunctionMap/src/OrdinaryDiffEqFunctionMap.jl index 039f313ffb..7240d44878 100644 --- a/lib/OrdinaryDiffEqFunctionMap/src/OrdinaryDiffEqFunctionMap.jl +++ b/lib/OrdinaryDiffEqFunctionMap/src/OrdinaryDiffEqFunctionMap.jl @@ -12,6 +12,7 @@ import RecursiveArrayTools: recursivecopy! import FastBroadcast: @.. import MuladdMacro: @muladd import Static: False +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqFunctionMap/src/fixed_timestep_perform_step.jl b/lib/OrdinaryDiffEqFunctionMap/src/fixed_timestep_perform_step.jl index 3da3118eab..d1734e99f1 100644 --- a/lib/OrdinaryDiffEqFunctionMap/src/fixed_timestep_perform_step.jl +++ b/lib/OrdinaryDiffEqFunctionMap/src/fixed_timestep_perform_step.jl @@ -16,7 +16,7 @@ function perform_step!(integrator, cache::FunctionMapCache, repeat_step = false) else f(u, uprev, p, t + dt) end - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end end @@ -28,11 +28,11 @@ function perform_step!(integrator, cache::FunctionMapConstantCache, repeat_step integrator.f.f === DiffEqBase.DISCRETE_OUTOFPLACE_DEFAULT) if FunctionMap_scale_by_time(alg) tmp = f(uprev, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @muladd integrator.u = @.. broadcast=false uprev+dt * tmp else integrator.u = f(uprev, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end end end diff --git a/lib/OrdinaryDiffEqHighOrderRK/Project.toml b/lib/OrdinaryDiffEqHighOrderRK/Project.toml index be9ca6047f..d1ac67c08b 100644 --- a/lib/OrdinaryDiffEqHighOrderRK/Project.toml +++ b/lib/OrdinaryDiffEqHighOrderRK/Project.toml @@ -18,7 +18,7 @@ DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" Random = "<0.0.1, 1" RecursiveArrayTools = "3.27.0" Reexport = "1.2.2" diff --git a/lib/OrdinaryDiffEqHighOrderRK/src/OrdinaryDiffEqHighOrderRK.jl b/lib/OrdinaryDiffEqHighOrderRK/src/OrdinaryDiffEqHighOrderRK.jl index 3905b53291..2de86d9be4 100644 --- a/lib/OrdinaryDiffEqHighOrderRK/src/OrdinaryDiffEqHighOrderRK.jl +++ b/lib/OrdinaryDiffEqHighOrderRK/src/OrdinaryDiffEqHighOrderRK.jl @@ -18,6 +18,7 @@ using DiffEqBase import FastBroadcast: @.. import RecursiveArrayTools: recursivefill! using DiffEqBase: @def, @tight_loop_macros +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqHighOrderRK/src/high_order_rk_perform_step.jl b/lib/OrdinaryDiffEqHighOrderRK/src/high_order_rk_perform_step.jl index fe66e071f1..8027c7a1eb 100644 --- a/lib/OrdinaryDiffEqHighOrderRK/src/high_order_rk_perform_step.jl +++ b/lib/OrdinaryDiffEqHighOrderRK/src/high_order_rk_perform_step.jl @@ -1,6 +1,6 @@ function initialize!(integrator, cache::TanYam7ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -36,7 +36,7 @@ end a108 * k8), p, t + dt) - integrator.stats.nf += 9 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 9) u = uprev + dt * (b1 * k1 + b4 * k4 + b5 * k5 + b6 * k6 + b7 * k7 + b8 * k8 + b9 * k9) if integrator.opts.adaptive utilde = dt * @@ -47,7 +47,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end integrator.fsallast = f(u, p, t + dt) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -61,7 +61,7 @@ function initialize!(integrator, cache::TanYam7Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::TanYam7Cache, repeat_step = false) @@ -118,7 +118,7 @@ end b9 * k9) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 10 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 10) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=dt * (btilde1 * k1 + btilde4 * k4 + btilde5 * k5 + @@ -131,7 +131,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return nothing end @@ -183,7 +183,7 @@ end @tight_loop_macros for i in uidx @inbounds u[i] = uprev[i] + dt*(b1*k1[i]+b4*k4[i]+b5*k5[i]+b6*k6[i]+b7*k7[i]+b8*k8[i]+b9*k9[i]) end - integrator.stats.nf += 10 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 10) if integrator.opts.adaptive @tight_loop_macros for i in uidx @inbounds utilde[i] = dt*(btilde1*k1[i]+btilde4*k4[i]+btilde5*k5[i]+btilde6*k6[i]+btilde7*k7[i]+btilde8*k8[i]+btilde9*k9[i]+btilde10*k10[i]) @@ -192,13 +192,13 @@ end integrator.EEst = integrator.opts.internalnorm(atmp,t) end f(k, u, p, t+dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end =# function initialize!(integrator, cache::TsitPap8ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -288,7 +288,7 @@ end a1309 * k9 + a1310 * k10), p, t + dt) - integrator.stats.nf += 12 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 12) u = uprev + dt * (b1 * k1 + b6 * k6 + b7 * k7 + b8 * k8 + b9 * k9 + b10 * k10 + b11 * k11 + b12 * k12) @@ -301,7 +301,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -315,7 +315,7 @@ function initialize!(integrator, cache::TsitPap8Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::TsitPap8Cache, repeat_step = false) @@ -394,7 +394,7 @@ end b11 * k11 + b12 * k12) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 13 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 13) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=dt * (btilde1 * k1 + btilde6 * k6 + btilde7 * k7 + @@ -408,7 +408,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return nothing end @@ -472,7 +472,7 @@ end @tight_loop_macros for i in uidx @inbounds u[i] = uprev[i] + dt*(b1*k1[i]+b6*k6[i]+b7*k7[i]+b8*k8[i]+b9*k9[i]+b10*k10[i]+b11*k11[i]+b12*k12[i]) end - integrator.stats.nf += 13 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 13) if integrator.opts.adaptive @tight_loop_macros for i in uidx @inbounds utilde[i] = dt*(btilde1*k1[i] + btilde6*k6[i] + btilde7*k7[i] + btilde8*k8[i] + btilde9*k9[i] + btilde10*k10[i] + btilde11*k11[i] + btilde12*k12[i] + btilde13*k13[i]) @@ -481,7 +481,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp,t) end f(k, u, p, t+dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end =# @@ -489,7 +489,7 @@ function initialize!(integrator, cache::DP8ConstantCache) integrator.kshortsize = 7 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -539,7 +539,7 @@ end a1209 * k9 + a1210 * k10 + a1211 * k11), p, t + dt) - integrator.stats.nf += 11 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 11) kupdate = b1 * k1 + b6 * k6 + b7 * k7 + b8 * k8 + b9 * k9 + b10 * k10 + b11 * k11 + b12 * k12 u = uprev + dt * kupdate @@ -563,7 +563,7 @@ end end end k13 = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = k13 if integrator.opts.calck @unpack c14, c15, c16, a1401, a1407, a1408, a1409, a1410, a1411, a1412, a1413, a1501, a1506, a1507, a1508, a1511, a1512, a1513, a1514, a1601, a1606, a1607, a1608, a1609, a1613, a1614, a1615 = cache @@ -586,7 +586,7 @@ end a1613 * k13 + a1614 * k14 + a1615 * k15), p, t + c16 * dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) udiff = kupdate integrator.k[1] = udiff bspl = k1 - udiff @@ -623,7 +623,7 @@ function initialize!(integrator, cache::DP8Cache) integrator.fsalfirst = cache.k1 integrator.fsallast = cache.k13 integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::DP8Cache, repeat_step = false) @@ -694,7 +694,7 @@ end @.. broadcast=false thread=thread u=uprev + dt * kupdate stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 12 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 12) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=dt * (k1 * er1 + k6 * er6 + k7 * er7 + @@ -721,7 +721,7 @@ end end end f(k13, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.calck @unpack c14, c15, c16, a1401, a1407, a1408, a1409, a1410, a1411, a1412, a1413, a1501, a1506, a1507, a1508, a1511, a1512, a1513, a1514, a1601, a1606, a1607, a1608, a1609, a1613, a1614, a1615 = cache.tab @unpack d401, d406, d407, d408, d409, d410, d411, d412, d413, d414, d415, d416, d501, d506, d507, d508, d509, d510, d511, d512, d513, d514, d515, d516, d601, d606, d607, d608, d609, d610, d611, d612, d613, d614, d615, d616, d701, d706, d707, d708, d709, d710, d711, d712, d713, d714, d715, d716 = cache.tab @@ -743,7 +743,7 @@ end a1609 * k9 + a1613 * k13 + a1614 * k14 + a1615 * k15) f(k16, tmp, p, t + c16 * dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) @.. broadcast=false thread=thread udiff=kupdate @.. broadcast=false thread=thread bspl=k1 - udiff @.. broadcast=false thread=thread integrator.k[3]=udiff - k13 - bspl @@ -834,7 +834,7 @@ end @inbounds kupdate[i] = b1*k1[i]+b6*k6[i]+b7*k7[i]+b8*k8[i]+b9*k9[i]+b10*k10[i]+b11*k11[i]+b12*k12[i] @inbounds u[i] = uprev[i] + dt*kupdate[i] end - integrator.stats.nf += 12 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 12) if integrator.opts.adaptive @tight_loop_macros for i in uidx @inbounds utilde[i] = dt*(k1[i]*er1 + k6[i]*er6 + k7[i]*er7 + k8[i]*er8 + k9[i]*er9 + k10[i]*er10 + k11[i]*er11 + k12[i]*er12) @@ -854,7 +854,7 @@ end end end f(k13, u, p, t+dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.calck @unpack c14,c15,c16,a1401,a1407,a1408,a1409,a1410,a1411,a1412,a1413,a1501,a1506,a1507,a1508,a1511,a1512,a1513,a1514,a1601,a1606,a1607,a1608,a1609,a1613,a1614,a1615 = cache.tab @unpack d401,d406,d407,d408,d409,d410,d411,d412,d413,d414,d415,d416,d501,d506,d507,d508,d509,d510,d511,d512,d513,d514,d515,d516,d601,d606,d607,d608,d609,d610,d611,d612,d613,d614,d615,d616,d701,d706,d707,d708,d709,d710,d711,d712,d713,d714,d715,d716 = cache.tab @@ -870,7 +870,7 @@ end @inbounds tmp[i] = uprev[i]+dt*(a1601*k1[i]+a1606*k6[i]+a1607*k7[i]+a1608*k8[i]+a1609*k9[i]+a1613*k13[i]+a1614*k14[i]+a1615*k15[i]) end f(k16, tmp, p, t + c16*dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) @tight_loop_macros for i in uidx @inbounds udiff[i]= kupdate[i] @inbounds bspl[i] = k1[i] - udiff[i] @@ -886,7 +886,7 @@ end function initialize!(integrator, cache::PFRK87ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -986,7 +986,7 @@ end α1309 * k9 + α1310 * k10 + α1311 * k11), p, t + c13 * dt) - integrator.stats.nf += 12 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 12) u = uprev + dt * (β1 * k1 + β6 * k6 + β7 * k7 + β8 * k8 + β9 * k9 + β10 * k10 + β11 * k11 + β12 * k12 + β13 * k13) @@ -999,7 +999,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -1013,7 +1013,7 @@ function initialize!(integrator, cache::PFRK87Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::PFRK87Cache, repeat_step = false) @@ -1135,7 +1135,7 @@ end β11 * k11 + β12 * k12 + β13 * k13) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 13 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 13) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=dt * (β1tilde * k1 + β6tilde * k6 + β7tilde * k7 + @@ -1148,6 +1148,6 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return nothing end diff --git a/lib/OrdinaryDiffEqIMEXMultistep/Project.toml b/lib/OrdinaryDiffEqIMEXMultistep/Project.toml index 7ae0574146..2630b04224 100644 --- a/lib/OrdinaryDiffEqIMEXMultistep/Project.toml +++ b/lib/OrdinaryDiffEqIMEXMultistep/Project.toml @@ -15,7 +15,7 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69" DiffEqBase = "6.152.2" DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqDifferentiation = "<0.0.1, 1" OrdinaryDiffEqNonlinearSolve = "<0.0.1, 1" Random = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqIMEXMultistep/src/OrdinaryDiffEqIMEXMultistep.jl b/lib/OrdinaryDiffEqIMEXMultistep/src/OrdinaryDiffEqIMEXMultistep.jl index dc1bbc310f..7a8327c6f7 100644 --- a/lib/OrdinaryDiffEqIMEXMultistep/src/OrdinaryDiffEqIMEXMultistep.jl +++ b/lib/OrdinaryDiffEqIMEXMultistep/src/OrdinaryDiffEqIMEXMultistep.jl @@ -7,7 +7,7 @@ import OrdinaryDiffEqCore: alg_order, issplit, OrdinaryDiffEqNewtonAlgorithm, _u full_cache using FastBroadcast - +import OrdinaryDiffEqCore using OrdinaryDiffEqDifferentiation: dolinsolve using OrdinaryDiffEqNonlinearSolve: NLNewton, build_nlsolver, markfirststage!, nlsolve!, nlsolvefail, du_alias_or_new diff --git a/lib/OrdinaryDiffEqIMEXMultistep/src/imex_multistep_perform_step.jl b/lib/OrdinaryDiffEqIMEXMultistep/src/imex_multistep_perform_step.jl index 0e71c5be16..eb3e820509 100644 --- a/lib/OrdinaryDiffEqIMEXMultistep/src/imex_multistep_perform_step.jl +++ b/lib/OrdinaryDiffEqIMEXMultistep/src/imex_multistep_perform_step.jl @@ -5,7 +5,7 @@ function initialize!(integrator, cache::CNAB2ConstantCache) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f.f1(integrator.uprev, integrator.p, integrator.t) + integrator.f.f2(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 # Avoid undefined entries if k is an array of arrays @@ -21,7 +21,7 @@ function perform_step!(integrator, cache::CNAB2ConstantCache, repeat_step = fals f1 = integrator.f.f1 f2 = integrator.f.f2 du₁ = f1(uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) k1 = integrator.fsalfirst - du₁ # Explicit part if cnt == 1 @@ -47,7 +47,7 @@ function perform_step!(integrator, cache::CNAB2ConstantCache, repeat_step = fals cache.k2 = k1 integrator.fsallast = f1(u, p, t + dt) + f2(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -62,7 +62,7 @@ function initialize!(integrator, cache::CNAB2Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::CNAB2Cache, repeat_step = false) @@ -73,7 +73,7 @@ function perform_step!(integrator, cache::CNAB2Cache, repeat_step = false) cnt = integrator.iter f1(du₁, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false k1=integrator.fsalfirst - du₁ # Explicit part if cnt == 1 @@ -96,7 +96,7 @@ function perform_step!(integrator, cache::CNAB2Cache, repeat_step = false) cache.k2 .= k1 f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # CNLF2 @@ -106,7 +106,7 @@ function initialize!(integrator, cache::CNLF2ConstantCache) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f.f1(integrator.uprev, integrator.p, integrator.t) + integrator.f.f2(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 # Avoid undefined entries if k is an array of arrays @@ -122,7 +122,7 @@ function perform_step!(integrator, cache::CNLF2ConstantCache, repeat_step = fals f1 = integrator.f.f1 f2 = integrator.f.f2 du₁ = f1(uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Explicit part if cnt == 1 tmp = uprev + dt * (integrator.fsalfirst - du₁) @@ -150,7 +150,7 @@ function perform_step!(integrator, cache::CNLF2ConstantCache, repeat_step = fals cache.uprev2 = uprev cache.k2 = du₁ integrator.fsallast = f1(u, p, t + dt) + f2(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -165,7 +165,7 @@ function initialize!(integrator, cache::CNLF2Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::CNLF2Cache, repeat_step = false) @@ -176,7 +176,7 @@ function perform_step!(integrator, cache::CNLF2Cache, repeat_step = false) cnt = integrator.iter f1(du₁, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Explicit part if cnt == 1 @.. broadcast=false tmp=uprev + dt * (integrator.fsalfirst - du₁) @@ -201,5 +201,5 @@ function perform_step!(integrator, cache::CNLF2Cache, repeat_step = false) cache.uprev2 .= uprev cache.k2 .= du₁ f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end diff --git a/lib/OrdinaryDiffEqLinear/Project.toml b/lib/OrdinaryDiffEqLinear/Project.toml index c96fcad0fd..97e550b764 100644 --- a/lib/OrdinaryDiffEqLinear/Project.toml +++ b/lib/OrdinaryDiffEqLinear/Project.toml @@ -20,7 +20,7 @@ DiffEqBase = "6.152.2" DiffEqDevTools = "2.44.4" ExponentialUtilities = "1.26.1" LinearAlgebra = "<0.0.1, 1" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqRosenbrock = "<0.0.1, 1" OrdinaryDiffEqTsit5 = "<0.0.1, 1" OrdinaryDiffEqVerner = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqLinear/src/OrdinaryDiffEqLinear.jl b/lib/OrdinaryDiffEqLinear/src/OrdinaryDiffEqLinear.jl index d2117cbd55..02b839cb32 100644 --- a/lib/OrdinaryDiffEqLinear/src/OrdinaryDiffEqLinear.jl +++ b/lib/OrdinaryDiffEqLinear/src/OrdinaryDiffEqLinear.jl @@ -13,6 +13,7 @@ using LinearAlgebra: mul!, I using SciMLOperators: AbstractSciMLOperator using ExponentialUtilities using RecursiveArrayTools +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqLinear/src/linear_perform_step.jl b/lib/OrdinaryDiffEqLinear/src/linear_perform_step.jl index fed2fa658f..98fa7e400e 100644 --- a/lib/OrdinaryDiffEqLinear/src/linear_perform_step.jl +++ b/lib/OrdinaryDiffEqLinear/src/linear_perform_step.jl @@ -6,7 +6,7 @@ function initialize!(integrator, cache::MagnusMidpointCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MagnusMidpointCache, repeat_step = false) @@ -28,7 +28,7 @@ function perform_step!(integrator, cache::MagnusMidpointCache, repeat_step = fal end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::LieRK4Cache) integrator.kshortsize = 2 @@ -38,7 +38,7 @@ function initialize!(integrator, cache::LieRK4Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::LieRK4Cache, repeat_step = false) @@ -80,7 +80,7 @@ function perform_step!(integrator, cache::LieRK4Cache, repeat_step = false) end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::RKMK4Cache) @@ -91,7 +91,7 @@ function initialize!(integrator, cache::RKMK4Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::RKMK4Cache, repeat_step = false) @@ -124,7 +124,7 @@ function perform_step!(integrator, cache::RKMK4Cache, repeat_step = false) end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::RKMK2Cache) @@ -135,7 +135,7 @@ function initialize!(integrator, cache::RKMK2Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::RKMK2Cache, repeat_step = false) @@ -158,7 +158,7 @@ function perform_step!(integrator, cache::RKMK2Cache, repeat_step = false) end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::CG3Cache) @@ -169,7 +169,7 @@ function initialize!(integrator, cache::CG3Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::CG3Cache, repeat_step = false) @@ -194,7 +194,7 @@ function perform_step!(integrator, cache::CG3Cache, repeat_step = false) uprev integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::CG2Cache) @@ -205,7 +205,7 @@ function initialize!(integrator, cache::CG2Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::CG2Cache, repeat_step = false) @@ -223,7 +223,7 @@ function perform_step!(integrator, cache::CG2Cache, repeat_step = false) (exponential!((1 / 2) * k2, exp_method, exp_cache))) * uprev integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::CG4aCache) @@ -234,7 +234,7 @@ function initialize!(integrator, cache::CG4aCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::CG4aCache, repeat_step = false) @@ -271,7 +271,7 @@ function perform_step!(integrator, cache::CG4aCache, repeat_step = false) exponential!(dt * (0.1370831520630755) * A, exp_method, exp_cache)) * uprev integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::MagnusAdapt4Cache) @@ -282,7 +282,7 @@ function initialize!(integrator, cache::MagnusAdapt4Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MagnusAdapt4Cache, repeat_step = false) @@ -334,7 +334,7 @@ function perform_step!(integrator, cache::MagnusAdapt4Cache, repeat_step = false u .= exponential!(v4, exp_method, exp_cache) * uprev integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive utilde = u - exponential!(y6, exp_method, exp_cache) * uprev calculate_residuals!(atmp, utilde, uprev, u, integrator.opts.abstol, @@ -351,7 +351,7 @@ function initialize!(integrator, cache::MagnusNC8Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MagnusNC8Cache, repeat_step = false) @@ -416,7 +416,7 @@ function perform_step!(integrator, cache::MagnusNC8Cache, repeat_step = false) u .= exponential!(Ω1 + Ω2 + Ω3_4_5_6, exp_method, exp_cache) * uprev end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::MagnusGL4Cache) @@ -427,7 +427,7 @@ function initialize!(integrator, cache::MagnusGL4Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MagnusGL4Cache, repeat_step = false) @@ -452,7 +452,7 @@ function perform_step!(integrator, cache::MagnusGL4Cache, repeat_step = false) u .= exponential!(Ω, exp_method, exp_cache) * uprev end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::MagnusGL8Cache) @@ -463,7 +463,7 @@ function initialize!(integrator, cache::MagnusGL8Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MagnusGL8Cache, repeat_step = false) @@ -520,7 +520,7 @@ function perform_step!(integrator, cache::MagnusGL8Cache, repeat_step = false) u .= exponential!(Ω1 + Ω2 + Ω3_4_5_6, exp_method, exp_cache) * uprev end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::MagnusNC6Cache) @@ -531,7 +531,7 @@ function initialize!(integrator, cache::MagnusNC6Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MagnusNC6Cache, repeat_step = false) @@ -568,7 +568,7 @@ function perform_step!(integrator, cache::MagnusNC6Cache, repeat_step = false) u .= exponential!(Ω1 + Ω2 + Ω3_4, exp_method, exp_cache) * uprev end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::MagnusGL6Cache) @@ -579,7 +579,7 @@ function initialize!(integrator, cache::MagnusGL6Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MagnusGL6Cache, repeat_step = false) @@ -612,7 +612,7 @@ function perform_step!(integrator, cache::MagnusGL6Cache, repeat_step = false) u .= exponential!(Ω1 + Ω2 + Ω3_4, exp_method, exp_cache) * uprev end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::MagnusGauss4Cache) @@ -623,7 +623,7 @@ function initialize!(integrator, cache::MagnusGauss4Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MagnusGauss4Cache, repeat_step = false) @@ -650,7 +650,7 @@ function perform_step!(integrator, cache::MagnusGauss4Cache, repeat_step = false exp_cache) * uprev end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::LieEulerCache) @@ -661,7 +661,7 @@ function initialize!(integrator, cache::LieEulerCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::LieEulerCache, repeat_step = false) @@ -682,7 +682,7 @@ function perform_step!(integrator, cache::LieEulerCache, repeat_step = false) end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::MagnusLeapfrogCache) @@ -693,7 +693,7 @@ function initialize!(integrator, cache::MagnusLeapfrogCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MagnusLeapfrogCache, repeat_step = false, @@ -716,7 +716,7 @@ function perform_step!(integrator, cache::MagnusLeapfrogCache, repeat_step = fal end integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) iter += 1 else L = integrator.f.f @@ -730,14 +730,14 @@ function perform_step!(integrator, cache::MagnusLeapfrogCache, repeat_step = fal end uprev = u integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end end function initialize!(integrator, cache::LinearExponentialConstantCache) # Pre-start fsal integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) # Initialize interpolation derivatives @@ -766,7 +766,7 @@ function perform_step!(integrator, cache::LinearExponentialConstantCache, # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -776,7 +776,7 @@ function initialize!(integrator, cache::LinearExponentialCache) # Pre-start fsal integrator.fsalfirst = zero(cache.rtmp) integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) # Initialize interpolation derivatives @@ -811,7 +811,7 @@ function perform_step!(integrator, cache::LinearExponentialCache, repeat_step = # Update integrator state u .= tmp f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # integrator.k is automatically set due to aliasing end @@ -822,7 +822,7 @@ cay(A) = inv(I - 1 / 2 * A) * (I + 1 / 2 * A) function initialize!(integrator, cache::CayleyEulerConstantCache) # Pre-start fsal integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) # Initialize interpolation derivatives @@ -849,7 +849,7 @@ function perform_step!(integrator, cache::CayleyEulerConstantCache, repeat_step # Update integrator state integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -863,7 +863,7 @@ function initialize!(integrator, cache::CayleyEulerCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::CayleyEulerCache, repeat_step = false) @@ -886,5 +886,5 @@ function perform_step!(integrator, cache::CayleyEulerCache, repeat_step = false) # Update integrator state integrator.f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end diff --git a/lib/OrdinaryDiffEqLowOrderRK/Project.toml b/lib/OrdinaryDiffEqLowOrderRK/Project.toml index abe5cd293e..9e0653e46a 100644 --- a/lib/OrdinaryDiffEqLowOrderRK/Project.toml +++ b/lib/OrdinaryDiffEqLowOrderRK/Project.toml @@ -21,7 +21,7 @@ FastBroadcast = "0.3.5" LinearAlgebra = "<0.0.1, 1" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" Random = "<0.0.1, 1" RecursiveArrayTools = "3.27.0" Reexport = "1.2.2" diff --git a/lib/OrdinaryDiffEqLowOrderRK/src/OrdinaryDiffEqLowOrderRK.jl b/lib/OrdinaryDiffEqLowOrderRK/src/OrdinaryDiffEqLowOrderRK.jl index 79cace5764..d8c194df93 100644 --- a/lib/OrdinaryDiffEqLowOrderRK/src/OrdinaryDiffEqLowOrderRK.jl +++ b/lib/OrdinaryDiffEqLowOrderRK/src/OrdinaryDiffEqLowOrderRK.jl @@ -24,6 +24,7 @@ import LinearAlgebra: norm import RecursiveArrayTools: recursivefill!, recursive_unitless_bottom_eltype import Static: False using DiffEqBase: @def, @tight_loop_macros +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqLowOrderRK/src/fixed_timestep_perform_step.jl b/lib/OrdinaryDiffEqLowOrderRK/src/fixed_timestep_perform_step.jl index 8639a951ee..e3f510e405 100644 --- a/lib/OrdinaryDiffEqLowOrderRK/src/fixed_timestep_perform_step.jl +++ b/lib/OrdinaryDiffEqLowOrderRK/src/fixed_timestep_perform_step.jl @@ -2,7 +2,7 @@ function initialize!(integrator, cache::EulerConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -14,7 +14,7 @@ function perform_step!(integrator, cache::EulerConstantCache, repeat_step = fals @unpack t, dt, uprev, f, p = integrator @muladd u = @.. broadcast=false uprev+dt * integrator.fsalfirst k = f(u, p, t + dt) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = k integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -30,21 +30,21 @@ function initialize!(integrator, cache::EulerCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::EulerCache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator @muladd @.. broadcast=false u=uprev + dt * integrator.fsalfirst f(integrator.fsallast, u, p, t + dt) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::Union{HeunConstantCache, RalstonConstantCache}) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -69,7 +69,7 @@ end tmp = @.. broadcast=false uprev+a₁ * fsalfirst k2 = f(tmp, p, t + a₁) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if cache isa HeunConstantCache u = @.. broadcast=false uprev+a₂ * (fsalfirst + k2) @@ -89,7 +89,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end k = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = k integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -105,7 +105,7 @@ function initialize!(integrator, cache::Union{HeunCache, RalstonCache}) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::Union{HeunCache, RalstonCache}, @@ -126,7 +126,7 @@ end @.. broadcast=false thread=thread tmp=uprev + a₁ * fsalfirst stage_limiter!(tmp, integrator, p, t + a₁) f(k, tmp, p, t + a₁) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if cache isa HeunCache @.. broadcast=false thread=thread u=uprev + a₂ * (fsalfirst + k) @@ -151,12 +151,12 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end f(integrator.fsallast, u, p, t + dt) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::MidpointConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -172,10 +172,10 @@ end halfdt = dt / 2 tmp = @.. broadcast=false uprev+halfdt * integrator.fsalfirst k = f(tmp, p, t + halfdt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u = @.. broadcast=false uprev+dt * k integrator.fsallast = f(u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive utilde = @.. broadcast=false dt*(integrator.fsalfirst - k) atmp = calculate_residuals(utilde, uprev, u, integrator.opts.abstol, @@ -196,7 +196,7 @@ function initialize!(integrator, cache::MidpointCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # FSAL for interpolation - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::MidpointCache, repeat_step = false) @@ -206,7 +206,7 @@ end @.. broadcast=false thread=thread tmp=uprev + halfdt * fsalfirst stage_limiter!(k, tmp, p, t + halfdt) f(k, tmp, p, t + halfdt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false thread=thread u=uprev + dt * k stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) @@ -218,12 +218,12 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::RK4ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -243,7 +243,7 @@ end k₄ = f(uprev + dt * k₃, p, t + dt) u = uprev + (dt / 6) * (2 * (k₂ + k₃) + (k₁ + k₄)) integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) if integrator.opts.adaptive # Shampine Solving ODEs and DDEs with Residual Control Estimate k₅ = integrator.fsallast @@ -277,7 +277,7 @@ end integrator.opts.internalnorm, t), t) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) integrator.EEst = convert(typeof(one(t)), 2.1342) * max(e1, e2) end integrator.k[1] = integrator.fsalfirst @@ -294,7 +294,7 @@ function initialize!(integrator, cache::RK4Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # pre-start FSAL - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::RK4Cache, repeat_step = false) @@ -316,7 +316,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k, u, p, t + dt) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) if integrator.opts.adaptive # Shampine Solving ODEs and DDEs with Residual Control Estimate k₅ = k @@ -362,7 +362,7 @@ end thread) e2 = integrator.opts.internalnorm(atmp, t) integrator.EEst = convert(typeof(one(t)), 2.1342) * max(e1, e2) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) end end @@ -370,7 +370,7 @@ function initialize!(integrator, cache::Anas5ConstantCache) integrator.kshortsize = 7 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -405,7 +405,7 @@ end u = uprev + dt * (b1 * k1 + b3 * k3 + b4 * k4 + b5 * k5 + b6 * k6) k7 = f(u, p, t + dt) integrator.fsallast = k7 - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.k[1] = k1 integrator.k[2] = k2 integrator.k[3] = k3 @@ -429,7 +429,7 @@ function initialize!(integrator, cache::Anas5Cache) integrator.fsalfirst = cache.k1 integrator.fsallast = cache.k7 # setup pointers integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::Anas5Cache, repeat_step = false) @@ -483,5 +483,5 @@ end stage_limiter!(tmp, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k7, u, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) end diff --git a/lib/OrdinaryDiffEqLowOrderRK/src/low_order_rk_perform_step.jl b/lib/OrdinaryDiffEqLowOrderRK/src/low_order_rk_perform_step.jl index d3423f3d24..c9f662ce04 100644 --- a/lib/OrdinaryDiffEqLowOrderRK/src/low_order_rk_perform_step.jl +++ b/lib/OrdinaryDiffEqLowOrderRK/src/low_order_rk_perform_step.jl @@ -2,7 +2,7 @@ function initialize!(integrator, cache::BS3ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -21,7 +21,7 @@ end u = uprev + dt * (a41 * k1 + a42 * k2 + a43 * k3) k4 = f(u, p, t + dt) integrator.fsallast = k4 - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) if integrator.opts.adaptive utilde = dt * (btilde1 * k1 + btilde2 * k2 + btilde3 * k3 + btilde4 * k4) atmp = calculate_residuals(utilde, uprev, u, integrator.opts.abstol, @@ -41,7 +41,7 @@ function initialize!(integrator, cache::BS3Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::BS3Cache, repeat_step = false) @@ -62,7 +62,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k4, u, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=dt * (btilde1 * k1 + btilde2 * k2 + btilde3 * k3 + btilde4 * k4) @@ -77,7 +77,7 @@ function initialize!(integrator, cache::OwrenZen3ConstantCache) integrator.kshortsize = 4 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -100,7 +100,7 @@ end u = uprev + dt * (a41 * k1 + a42 * k2 + a43 * k3) k4 = f(u, p, t + dt) integrator.fsallast = k4 - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) if integrator.opts.adaptive utilde = dt * (btilde1 * k1 + btilde2 * k2 + btilde3 * k3) atmp = calculate_residuals(utilde, uprev, u, integrator.opts.abstol, @@ -124,7 +124,7 @@ function initialize!(integrator, cache::OwrenZen3Cache) integrator.fsalfirst = cache.k1 integrator.fsallast = cache.k4 # setup pointers integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::OwrenZen3Cache, repeat_step = false) @@ -142,7 +142,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k4, u, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=dt * (btilde1 * k1 + btilde2 * k2 + btilde3 * k3) @@ -157,7 +157,7 @@ function initialize!(integrator, cache::OwrenZen4ConstantCache) integrator.kshortsize = 6 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -181,7 +181,7 @@ end u = uprev + dt * (a61 * k1 + a63 * k3 + a64 * k4 + a65 * k5) k6 = f(u, p, t + dt) integrator.fsallast = k6 - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) if integrator.opts.adaptive utilde = dt * (btilde1 * k1 + btilde3 * k3 + btilde4 * k4 + btilde5 * k5) atmp = calculate_residuals(utilde, uprev, u, integrator.opts.abstol, @@ -209,7 +209,7 @@ function initialize!(integrator, cache::OwrenZen4Cache) integrator.fsalfirst = cache.k1 integrator.fsallast = cache.k6 # setup pointers integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::OwrenZen4Cache, repeat_step = false) @@ -235,7 +235,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k6, u, p, t + dt) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=dt * (btilde1 * k1 + btilde3 * k3 + btilde4 * k4 + @@ -275,7 +275,7 @@ end @inbounds u[i] = uprev[i]+dt*(a61*k1[i]+a63*k3[i]+a64*k4[i]+a65*k5[i]) end f(k6, u, p, t+dt) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) if integrator.opts.adaptive @tight_loop_macros for i in uidx @inbounds utilde[i] = dt*(btilde1*k1[i] + btilde3*k3[i] + btilde4*k4[i] + btilde5*k5[i]) @@ -290,7 +290,7 @@ function initialize!(integrator, cache::OwrenZen5ConstantCache) integrator.kshortsize = 8 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -318,7 +318,7 @@ end u = uprev + dt * (a81 * k1 + a83 * k3 + a84 * k4 + a85 * k5 + a86 * k6 + a87 * k7) k8 = f(u, p, t + dt) integrator.fsallast = k8 - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) if integrator.opts.adaptive utilde = dt * (btilde1 * k1 + btilde3 * k3 + btilde4 * k4 + btilde5 * k5 + btilde6 * k6 + @@ -352,7 +352,7 @@ function initialize!(integrator, cache::OwrenZen5Cache) integrator.fsalfirst = cache.k1 integrator.fsallast = cache.k8 # setup pointers integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::OwrenZen5Cache, repeat_step = false) @@ -391,7 +391,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k8, u, p, t + dt) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=dt * (btilde1 * k1 + btilde3 * k3 + btilde4 * k4 + @@ -440,7 +440,7 @@ end @inbounds u[i] = uprev[i]+dt*(a81*k1[i]+a83*k3[i]+a84*k4[i]+a85*k5[i]+a86*k6[i]+a87*k7[i]) end f(k8, u, p, t+dt) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) if integrator.opts.adaptive @tight_loop_macros for i in uidx @inbounds utilde[i] = dt*(btilde1*k1[i] + btilde3*k3[i] + btilde4*k4[i] + btilde5*k5[i] + btilde6*k6[i] + btilde7*k7[i]) @@ -456,7 +456,7 @@ function initialize!(integrator, cache::BS5ConstantCache) alg.lazy ? (integrator.kshortsize = 8) : (integrator.kshortsize = 11) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -486,11 +486,11 @@ end t + c5 * dt) k7 = f(uprev + dt * (a71 * k1 + a72 * k2 + a73 * k3 + a74 * k4 + a75 * k5 + a76 * k6), p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) u = uprev + dt * (a81 * k1 + a83 * k3 + a84 * k4 + a85 * k5 + a86 * k6 + a87 * k7) integrator.fsallast = f(u, p, t + dt) k8 = integrator.fsallast - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive uhat = dt * (bhat1 * k1 + bhat3 * k3 + bhat4 * k4 + bhat5 * k5 + bhat6 * k6) utilde = dt * @@ -538,7 +538,7 @@ end (a111 * k[1] + a112 * k[2] + a113 * k[3] + a114 * k[4] + a115 * k[5] + a116 * k[6] + a117 * k[7] + a118 * k[8] + a119 * k[9] + a1110 * k[10]), p, t + c8 * dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) end end @@ -564,7 +564,7 @@ function initialize!(integrator, cache::BS5Cache) integrator.fsalfirst = cache.k1 integrator.fsallast = cache.k8 # setup pointers integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::BS5Cache, repeat_step = false) @@ -603,7 +603,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k8, u, p, t + dt) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=dt * (bhat1 * k1 + bhat3 * k3 + bhat4 * k4 + @@ -651,7 +651,7 @@ end a118 * k[8] + a119 * k[9] + a1110 * k[10]) f(k[11], tmp, p, t + c8 * dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) end return nothing end @@ -691,7 +691,7 @@ end @inbounds u[i] = uprev[i]+dt*(a81*k1[i]+a83*k3[i]+a84*k4[i]+a85*k5[i]+a86*k6[i]+a87*k7[i]) end f(k8, u, p, t+dt) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) if integrator.opts.adaptive @tight_loop_macros for i in uidx @inbounds utilde[i] = dt*(bhat1*k1[i] + bhat3*k3[i] + bhat4*k4[i] + bhat5*k5[i] + bhat6*k6[i]) @@ -722,7 +722,7 @@ end @inbounds tmp[i] = uprev[i]+dt*(a111*k[1][i]+a112*k[2][i]+a113*k[3][i]+a114*k[4][i]+a115*k[5][i]+a116*k[6][i]+a117*k[7][i]+a118*k[8][i]+a119*k[9][i]+a1110*k[10][i]) end f(k[11],tmp,p,t+c8*dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) end end =# @@ -731,7 +731,7 @@ function initialize!(integrator, cache::DP5ConstantCache) integrator.kshortsize = 4 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -757,7 +757,7 @@ end u = uprev + dt * update integrator.fsallast = f(u, p, t + dt) k7 = integrator.fsallast - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) if integrator.alg isa CompositeAlgorithm g7 = u # Hairer II, page 22 modified to use the Inf norm @@ -790,7 +790,7 @@ function initialize!(integrator, cache::DP5Cache) integrator.fsalfirst = cache.k1 integrator.fsallast = cache.k7 integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::DP5Cache, repeat_step = false) @@ -824,7 +824,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k7, u, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) if integrator.alg isa CompositeAlgorithm g6 = tmp g7 = u @@ -860,7 +860,7 @@ function initialize!(integrator, cache::RKO65ConstantCache) integrator.kshortsize = 6 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -888,7 +888,7 @@ end integrator.fsallast = f(u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.k[1] = k1 integrator.k[2] = k2 integrator.k[3] = k3 @@ -918,7 +918,7 @@ function initialize!(integrator, cache::RKO65Cache) integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::RKO65Cache, repeat_step = false) @@ -955,7 +955,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) #println("L238: tmp/u", tmp, u) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) #return nothing end @@ -964,7 +964,7 @@ function initialize!(integrator, cache::FRK65ConstantCache) integrator.kshortsize = 9 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -1017,7 +1017,7 @@ end integrator.opts.reltol, integrator.opts.internalnorm, t) integrator.EEst = integrator.opts.internalnorm(atmp, t) end - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) integrator.k[1] = k1 integrator.k[2] = k2 integrator.k[3] = k3 @@ -1048,7 +1048,7 @@ function initialize!(integrator, cache::FRK65Cache) integrator.k[9] = cache.k9 integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::FRK65Cache, repeat_step = false) @@ -1103,7 +1103,7 @@ end step_limiter!(u, integrator, p, t + dt) f(k9, u, p, t + dt) - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=dt * (β1tilde * k1 + β4tilde * k4 + β5tilde * k5 + @@ -1122,7 +1122,7 @@ function initialize!(integrator, cache::RKMConstantCache) integrator.kshortsize = 6 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -1147,7 +1147,7 @@ end u = uprev + dt * (β1 * k1 + β2 * k2 + β3 * k3 + β4 * k4 + β6 * k6) integrator.fsallast = f(u, p, t + dt) #interpolation then FSAL'd - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.k[1] = k1 integrator.k[2] = k2 integrator.k[3] = k3 @@ -1175,7 +1175,7 @@ function initialize!(integrator, cache::RKMCache) integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::RKMCache, repeat_step = false) @@ -1204,7 +1204,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) return nothing end @@ -1212,7 +1212,7 @@ function initialize!(integrator, cache::PSRK4p7q6ConstantCache) integrator.kshortsize = 6 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) integrator.k[1] = integrator.fsalfirst integrator.k[2] = zero(integrator.fsalfirst) @@ -1239,7 +1239,7 @@ function perform_step!(integrator, cache::PSRK4p7q6ConstantCache, repeat_step = k6 = f(tmp, p, t + dt * c6) u = uprev + dt * (b1 * k1 + b2 * k2 + b3 * k3 + b4 * k4 + b5 * k5 + b6 * k6) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.fsallast = k6 integrator.k[1] = k1 @@ -1296,7 +1296,7 @@ function perform_step!(integrator, cache::PSRK4p7q6Cache, repeat_step = false) b6 * k6) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.fsallast = k6 return nothing end @@ -1305,7 +1305,7 @@ function initialize!(integrator, cache::PSRK3p6q5ConstantCache) integrator.kshortsize = 5 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) integrator.k[1] = integrator.fsalfirst integrator.k[2] = zero(integrator.fsalfirst) @@ -1329,7 +1329,7 @@ function perform_step!(integrator, cache::PSRK3p6q5ConstantCache, repeat_step = k5 = f(tmp, p, t + dt * c5) u = uprev + dt * (b1 * k1 + b2 * k2 + b3 * k3 + b4 * k4 + b5 * k5) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.fsallast = k5 integrator.k[1] = k1 @@ -1378,7 +1378,7 @@ function perform_step!(integrator, cache::PSRK3p6q5Cache, repeat_step = false) (b1 * k1 + b2 * k2 + b3 * k3 + b4 * k4 + b5 * k5) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.fsallast = k5 return nothing end @@ -1387,7 +1387,7 @@ function initialize!(integrator, cache::PSRK3p5q4ConstantCache) integrator.kshortsize = 4 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) integrator.k[1] = integrator.fsalfirst integrator.k[2] = zero(integrator.fsalfirst) @@ -1409,7 +1409,7 @@ function perform_step!(integrator, cache::PSRK3p5q4ConstantCache, repeat_step = u = uprev + dt * (b1 * k1 + b2 * k2 + b3 * k3 + b4 * k4) integrator.fsallast = k4 - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.k[1] = k1 integrator.k[2] = k2 @@ -1452,7 +1452,7 @@ function perform_step!(integrator, cache::PSRK3p5q4Cache, repeat_step = false) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.fsallast = k4 return nothing end @@ -1462,7 +1462,7 @@ function initialize!(integrator, cache::MSRK5ConstantCache) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) integrator.fsallast = zero(integrator.fsalfirst) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst @inbounds for i in 2:(integrator.kshortsize - 1) integrator.k[i] = zero(integrator.fsalfirst) @@ -1492,7 +1492,7 @@ function perform_step!(integrator, cache::MSRK5ConstantCache, repeat_step = fals u = uprev + dt * (b1 * k1 + b4 * k4 + b5 * k5 + b6 * k6 + b7 * k7 + b8 * k8) k9 = f(u, p, t + dt) integrator.fsallast = k9 - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) integrator.k[1] = k1 integrator.k[2] = k2 @@ -1524,7 +1524,7 @@ function initialize!(integrator, cache::MSRK5Cache) integrator.fsallast = cache.k9 f(integrator.fsalfirst, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MSRK5Cache, repeat_step = false) @@ -1567,7 +1567,7 @@ function perform_step!(integrator, cache::MSRK5Cache, repeat_step = false) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k9, u, p, t + dt) - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) integrator.fsallast = k9 return nothing @@ -1578,7 +1578,7 @@ function initialize!(integrator, cache::MSRK6ConstantCache) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) integrator.fsallast = zero(integrator.fsalfirst) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst @inbounds for i in 2:(integrator.kshortsize - 1) integrator.k[i] = zero(integrator.fsalfirst) @@ -1608,7 +1608,7 @@ function perform_step!(integrator, cache::MSRK6ConstantCache, repeat_step = fals u = uprev + dt * (b1 * k1 + b4 * k4 + b5 * k5 + b6 * k6 + b7 * k7 + b8 * k8) k9 = f(u, p, t + dt) integrator.fsallast = k9 - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) integrator.k[1] = k1 integrator.k[2] = k2 @@ -1640,7 +1640,7 @@ function initialize!(integrator, cache::MSRK6Cache) integrator.fsallast = cache.k9 f(integrator.fsalfirst, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::MSRK6Cache, repeat_step = false) @@ -1682,7 +1682,7 @@ function perform_step!(integrator, cache::MSRK6Cache, repeat_step = false) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k9, u, p, t + dt) - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) integrator.fsallast = k9 return nothing @@ -1693,7 +1693,7 @@ function initialize!(integrator, cache::Stepanov5ConstantCache) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) integrator.fsallast = zero(integrator.fsalfirst) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst @inbounds for i in 2:(integrator.kshortsize - 1) integrator.k[i] = zero(integrator.fsalfirst) @@ -1719,7 +1719,7 @@ function perform_step!(integrator, cache::Stepanov5ConstantCache, repeat_step = u = uprev + dt * (b1 * k1 + b3 * k3 + b4 * k4 + b5 * k5 + b6 * k6) k7 = f(u, p, t + dt) integrator.fsallast = k7 - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) if integrator.opts.adaptive @.. broadcast=false utilde=dt * (btilde1 * k1 + btilde2 * k2 + @@ -1757,7 +1757,7 @@ function initialize!(integrator, cache::Stepanov5Cache) integrator.fsallast = cache.k7 f(integrator.fsalfirst, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::Stepanov5Cache, repeat_step = false) @@ -1789,7 +1789,7 @@ function perform_step!(integrator, cache::Stepanov5Cache, repeat_step = false) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k7, u, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.fsallast = k7 if integrator.opts.adaptive @@ -1810,7 +1810,7 @@ function initialize!(integrator, cache::SIR54ConstantCache) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) integrator.fsallast = zero(integrator.fsalfirst) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst @inbounds for i in 2:(integrator.kshortsize - 1) integrator.k[i] = zero(integrator.fsalfirst) @@ -1838,7 +1838,7 @@ function perform_step!(integrator, cache::SIR54ConstantCache, repeat_step = fals u = uprev + dt * (b1 * k1 + b2 * k2 + b3 * k3 + b4 * k4 + b5 * k5 + b6 * k6) k8 = f(u, p, t + dt) integrator.fsallast = k8 - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) if integrator.opts.adaptive utilde = dt * (btilde1 * k1 + btilde2 * k2 + btilde3 * k3 + @@ -1878,7 +1878,7 @@ function initialize!(integrator, cache::SIR54Cache) integrator.fsallast = cache.k8 f(integrator.fsalfirst, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::SIR54Cache, repeat_step = false) @@ -1916,7 +1916,7 @@ function perform_step!(integrator, cache::SIR54Cache, repeat_step = false) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k8, u, p, t + dt) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) integrator.fsallast = k8 if integrator.opts.adaptive @@ -1938,7 +1938,7 @@ function initialize!(integrator, cache::Alshina2ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -1960,7 +1960,7 @@ function perform_step!(integrator, cache::Alshina2ConstantCache, repeat_step = f integrator.EEst = integrator.opts.internalnorm(atmp, t) end - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) integrator.fsallast = k2 integrator.k[1] = k1 @@ -1979,7 +1979,7 @@ function initialize!(integrator, cache::Alshina2Cache) integrator.fsallast = cache.k2 f(integrator.fsalfirst, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::Alshina2Cache, repeat_step = false) @@ -2004,7 +2004,7 @@ function perform_step!(integrator, cache::Alshina2Cache, repeat_step = false) thread) integrator.EEst = integrator.opts.internalnorm(atmp, t) end - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) integrator.fsallast = k2 return nothing @@ -2014,7 +2014,7 @@ function initialize!(integrator, cache::Alshina3ConstantCache) integrator.kshortsize = 3 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) integrator.k[1] = integrator.fsalfirst integrator.k[2] = zero(integrator.fsalfirst) @@ -2039,7 +2039,7 @@ function perform_step!(integrator, cache::Alshina3ConstantCache, repeat_step = f integrator.EEst = integrator.opts.internalnorm(atmp, t) end - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) integrator.fsallast = k3 integrator.k[1] = k1 @@ -2060,7 +2060,7 @@ function initialize!(integrator, cache::Alshina3Cache) integrator.fsallast = cache.k3 f(integrator.fsalfirst, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function perform_step!(integrator, cache::Alshina3Cache, repeat_step = false) @@ -2087,7 +2087,7 @@ function perform_step!(integrator, cache::Alshina3Cache, repeat_step = false) integrator.EEst = integrator.opts.internalnorm(atmp, t) end - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) integrator.fsallast = k3 return nothing @@ -2097,7 +2097,7 @@ function initialize!(integrator, cache::Alshina6ConstantCache) integrator.kshortsize = 7 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast = zero(integrator.fsalfirst) integrator.k[1] = integrator.fsalfirst integrator.k[2] = zero(integrator.fsalfirst) @@ -2131,7 +2131,7 @@ function perform_step!(integrator, cache::Alshina6ConstantCache, repeat_step = f u = uprev + dt * (b1 * k1 + b5 * k5 + b6 * k6 + b7 * k7) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) integrator.k[1] = k1 integrator.k[2] = k2 @@ -2194,7 +2194,7 @@ function perform_step!(integrator, cache::Alshina6Cache, repeat_step = false) (b1 * k1 + b5 * k5 + b6 * k6 + b7 * k7) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) integrator.fsallast = k7 return nothing end diff --git a/lib/OrdinaryDiffEqLowOrderRK/src/split_perform_step.jl b/lib/OrdinaryDiffEqLowOrderRK/src/split_perform_step.jl index 80f7a906d7..9b766cb6d0 100644 --- a/lib/OrdinaryDiffEqLowOrderRK/src/split_perform_step.jl +++ b/lib/OrdinaryDiffEqLowOrderRK/src/split_perform_step.jl @@ -3,7 +3,7 @@ function initialize!(integrator, cache::SplitEulerConstantCache) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f.f1(integrator.uprev, integrator.p, integrator.t) + integrator.f.f2(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 # Avoid undefined entries if k is an array of arrays @@ -17,7 +17,7 @@ end @unpack t, dt, uprev, u, f, p = integrator u = @.. broadcast=false uprev+dt * integrator.fsalfirst integrator.fsallast = f.f1(u, p, t + dt) + f.f2(u, p, t + dt) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -34,7 +34,7 @@ function initialize!(integrator, cache::SplitEulerCache) integrator.k[2] = integrator.fsallast integrator.f.f1(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point integrator.f.f2(cache.tmp, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.fsalfirst .+= cache.tmp end @@ -45,6 +45,6 @@ end f.f1(integrator.fsallast, u, p, t + dt) # For the interpolation, needs k at the updated point f.f2(cache.tmp, u, p, t + dt) # For the interpolation, needs k at the updated point integrator.stats.nf2 += 1 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.fsallast .+= cache.tmp end diff --git a/lib/OrdinaryDiffEqLowStorageRK/Project.toml b/lib/OrdinaryDiffEqLowStorageRK/Project.toml index f4d3444218..9805d351fd 100644 --- a/lib/OrdinaryDiffEqLowStorageRK/Project.toml +++ b/lib/OrdinaryDiffEqLowStorageRK/Project.toml @@ -24,7 +24,7 @@ DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" Polyester = "0.7.16" PrecompileTools = "1.2.1" Preferences = "1.4.3" diff --git a/lib/OrdinaryDiffEqLowStorageRK/src/low_storage_rk_perform_step.jl b/lib/OrdinaryDiffEqLowStorageRK/src/low_storage_rk_perform_step.jl index b04660be84..f3c2fb53c3 100644 --- a/lib/OrdinaryDiffEqLowStorageRK/src/low_storage_rk_perform_step.jl +++ b/lib/OrdinaryDiffEqLowStorageRK/src/low_storage_rk_perform_step.jl @@ -1,7 +1,7 @@ # 2N low storage methods function initialize!(integrator, cache::LowStorageRK2NConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -22,12 +22,12 @@ end # other stages for i in eachindex(A2end) k = f(u, p, t + c2end[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) tmp = A2end[i] * tmp + dt * k u = u + B2end[i] * tmp end - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.fsalfirst = f(u, p, t + dt) # For interpolation, then FSAL'd integrator.u = u @@ -41,7 +41,7 @@ function initialize!(integrator, cache::LowStorageRK2NCache) integrator.fsalfirst = k # used for get_du integrator.fsallast = k integrator.f(k, integrator.uprev, integrator.p, integrator.t) # FSAL for interpolation - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::LowStorageRK2NCache, repeat_step = false) @@ -51,7 +51,7 @@ end # u1 f(k, u, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false thread=thread tmp=dt * k @.. broadcast=false thread=thread u=u + B1 * tmp # other stages @@ -65,7 +65,7 @@ end @.. broadcast=false thread=thread tmp=tmp + dt * k @.. broadcast=false thread=thread u=u + B2end[i] * tmp end - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) @@ -74,7 +74,7 @@ end # 2C low storage methods function initialize!(integrator, cache::LowStorageRK2CConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -91,14 +91,14 @@ end # u1 k = integrator.fsalfirst = f(u, p, t) integrator.k[1] = integrator.fsalfirst - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u = u + B1 * dt * k # other stages for i in eachindex(A2end) tmp = u + A2end[i] * dt * k k = f(tmp, p, t + c2end[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u = u + B2end[i] * dt * k end @@ -113,7 +113,7 @@ function initialize!(integrator, cache::LowStorageRK2CCache) resize!(integrator.k, integrator.kshortsize) integrator.k[1] = integrator.fsalfirst integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # FSAL for interpolation - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::LowStorageRK2CCache, repeat_step = false) @@ -129,18 +129,18 @@ end for i in eachindex(A2end) @.. broadcast=false thread=thread tmp=u + A2end[i] * dt * k f(k, tmp, p, t + c2end[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false thread=thread u=u + B2end[i] * dt * k end step_limiter!(u, integrator, p, t + dt) f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # 3S low storage methods function initialize!(integrator, cache::LowStorageRK3SConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -161,13 +161,13 @@ end # other stages for i in eachindex(γ12end) k = f(u, p, t + c2end[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) tmp = tmp + δ2end[i] * u u = γ12end[i] * u + γ22end[i] * tmp + γ32end[i] * uprev + β2end[i] * dt * k end integrator.fsallast = f(u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.u = u end @@ -180,7 +180,7 @@ function initialize!(integrator, cache::LowStorageRK3SCache) resize!(integrator.k, integrator.kshortsize) integrator.k[1] = integrator.fsalfirst integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # FSAL for interpolation - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::LowStorageRK3SCache, repeat_step = false) @@ -195,7 +195,7 @@ end # other stages for i in eachindex(γ12end) f(k, u, p, t + c2end[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false thread=thread tmp=tmp + δ2end[i] * u @.. broadcast=false thread=thread u=γ12end[i] * u + γ22end[i] * tmp + γ32end[i] * uprev + @@ -204,13 +204,13 @@ end step_limiter!(u, integrator, p, t + dt) f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # 3S+ low storage methods: 3S methods adding another memory location for the embedded method (non-FSAL version) function initialize!(integrator, cache::LowStorageRK3SpConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -226,7 +226,7 @@ end # u1 integrator.fsalfirst = f(uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst tmp = uprev u = tmp + β1 * dt * integrator.fsalfirst @@ -237,7 +237,7 @@ end # other stages for i in eachindex(γ12end) k = f(u, p, t + c2end[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) tmp = tmp + δ2end[i] * u u = γ12end[i] * u + γ22end[i] * tmp + γ32end[i] * uprev + β2end[i] * dt * k if integrator.opts.adaptive @@ -270,7 +270,7 @@ end # u1 f(integrator.fsalfirst, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false thread=thread tmp=uprev @.. broadcast=false thread=thread u=tmp + β1 * dt * integrator.fsalfirst if integrator.opts.adaptive @@ -281,7 +281,7 @@ end for i in eachindex(γ12end) stage_limiter!(u, integrator, p, t + c2end[i] * dt) f(k, u, p, t + c2end[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false thread=thread tmp=tmp + δ2end[i] * u @.. broadcast=false thread=thread u=γ12end[i] * u + γ22end[i] * tmp + γ32end[i] * uprev + β2end[i] * dt * k @@ -304,7 +304,7 @@ end # 3S+ FSAL low storage methods: 3S methods adding another memory location for the embedded method (FSAL version) function initialize!(integrator, cache::LowStorageRK3SpFSALConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -329,7 +329,7 @@ end # other stages for i in eachindex(γ12end) k = f(u, p, t + c2end[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) tmp = tmp + δ2end[i] * u u = γ12end[i] * u + γ22end[i] * tmp + γ32end[i] * uprev + β2end[i] * dt * k if integrator.opts.adaptive @@ -339,7 +339,7 @@ end # FSAL integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive utilde = utilde + bhatfsal * dt * integrator.fsallast @@ -362,7 +362,7 @@ function initialize!(integrator, cache::LowStorageRK3SpFSALCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # FSAL for interpolation - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::LowStorageRK3SpFSALCache, @@ -382,7 +382,7 @@ end for i in eachindex(γ12end) stage_limiter!(u, integrator, p, t + c2end[i] * dt) f(k, u, p, t + c2end[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false thread=thread tmp=tmp + δ2end[i] * u @.. broadcast=false thread=thread u=γ12end[i] * u + γ22end[i] * tmp + γ32end[i] * uprev + β2end[i] * dt * k @@ -396,7 +396,7 @@ end # FSAL f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=utilde + bhatfsal * dt * k @@ -410,7 +410,7 @@ end # 2R+ low storage methods function initialize!(integrator, cache::LowStorageRK2RPConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -433,7 +433,7 @@ end gprev = u + Aᵢ[i] * dt * k u = u + Bᵢ[i] * dt * k k = f(gprev, p, t + Cᵢ[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #last stage @@ -449,7 +449,7 @@ end integrator.k[1] = integrator.fsalfirst integrator.fsallast = f(u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.u = u end @@ -461,7 +461,7 @@ function initialize!(integrator, cache::LowStorageRK2RPCache) resize!(integrator.k, integrator.kshortsize) integrator.k[1] = integrator.fsalfirst integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::LowStorageRK2RPCache, repeat_step = false) @@ -479,7 +479,7 @@ end @.. broadcast=false thread=thread gprev=u + Aᵢ[i] * dt * k @.. broadcast=false thread=thread u=u + Bᵢ[i] * dt * k f(k, gprev, p, t + Cᵢ[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #last stage @@ -497,13 +497,13 @@ end step_limiter!(u, integrator, p, t + dt) f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # 3R+ low storage methods function initialize!(integrator, cache::LowStorageRK3RPConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -532,7 +532,7 @@ end uᵢ₋₂ = uᵢ₋₁ uᵢ₋₁ = u k = f(gprev, p, t + Cᵢ[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #last stage @@ -548,7 +548,7 @@ end integrator.k[1] = integrator.fsalfirst integrator.fsallast = f(u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.u = u end @@ -560,7 +560,7 @@ function initialize!(integrator, cache::LowStorageRK3RPCache) resize!(integrator.k, integrator.kshortsize) integrator.k[1] = integrator.fsalfirst integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::LowStorageRK3RPCache, repeat_step = false) @@ -584,7 +584,7 @@ end @.. broadcast=false thread=thread uᵢ₋₂=uᵢ₋₁ @.. broadcast=false thread=thread uᵢ₋₁=u f(k, gprev, p, t + Cᵢ[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #last stage @@ -603,13 +603,13 @@ end end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # 4R+ low storage methods function initialize!(integrator, cache::LowStorageRK4RPConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -642,7 +642,7 @@ end uᵢ₋₂ = uᵢ₋₁ uᵢ₋₁ = u k = f(gprev, p, t + Cᵢ[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #last stage @@ -658,7 +658,7 @@ end integrator.k[1] = integrator.fsalfirst integrator.fsallast = f(u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.u = u end @@ -670,7 +670,7 @@ function initialize!(integrator, cache::LowStorageRK4RPCache) resize!(integrator.k, integrator.kshortsize) integrator.k[1] = integrator.fsalfirst integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::LowStorageRK4RPCache, repeat_step = false) @@ -701,7 +701,7 @@ end @.. broadcast=false thread=thread uᵢ₋₂=uᵢ₋₁ @.. broadcast=false thread=thread uᵢ₋₁=u f(k, gprev, p, t + Cᵢ[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #last stage @@ -720,13 +720,13 @@ end end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # 5R+ low storage methods function initialize!(integrator, cache::LowStorageRK5RPConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -763,7 +763,7 @@ end uᵢ₋₂ = uᵢ₋₁ uᵢ₋₁ = u k = f(gprev, p, t + Cᵢ[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #last stage @@ -779,7 +779,7 @@ end integrator.k[1] = integrator.fsalfirst integrator.fsallast = f(u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.u = u end @@ -791,7 +791,7 @@ function initialize!(integrator, cache::LowStorageRK5RPCache) resize!(integrator.k, integrator.kshortsize) integrator.k[1] = integrator.fsalfirst integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::LowStorageRK5RPCache, repeat_step = false) @@ -826,7 +826,7 @@ end @.. broadcast=false thread=thread uᵢ₋₂=uᵢ₋₁ @.. broadcast=false thread=thread uᵢ₋₁=u f(k, gprev, p, t + Cᵢ[i] * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end #last stage @@ -845,7 +845,7 @@ end end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, cache::RK46NLCache) @@ -856,7 +856,7 @@ function initialize!(integrator, cache::RK46NLCache) resize!(integrator.k, integrator.kshortsize) integrator.k[1] = integrator.fsalfirst integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # FSAL for interpolation - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::RK46NLCache, repeat_step = false) @@ -896,12 +896,12 @@ end step_limiter!(u, integrator, p, t + dt) f(k, u, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) end function initialize!(integrator, cache::RK46NLConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -934,14 +934,14 @@ end u = u + β6 * tmp integrator.fsallast = f(u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.k[1] = integrator.fsalfirst integrator.u = u end function initialize!(integrator, cache::KYK2014DGSSPRK_3S2_ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -961,7 +961,7 @@ end α_32 * u_2 + dt * β_32 * f(u_2, p, t + c_2 * dt)) integrator.k[1] = integrator.fsalfirst integrator.k[2] = f(integrator.u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) integrator.fsallast = integrator.k[2] return nothing end @@ -975,7 +975,7 @@ function initialize!(integrator, cache::KYK2014DGSSPRK_3S2_Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # FSAL for interpolation - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return nothing end @@ -998,6 +998,6 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(integrator.k[2], u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) return nothing end diff --git a/lib/OrdinaryDiffEqNonlinearSolve/Project.toml b/lib/OrdinaryDiffEqNonlinearSolve/Project.toml index 983362d14a..cba61bf922 100644 --- a/lib/OrdinaryDiffEqNonlinearSolve/Project.toml +++ b/lib/OrdinaryDiffEqNonlinearSolve/Project.toml @@ -36,7 +36,7 @@ LinearAlgebra = "<0.0.1, 1" LinearSolve = "2.32.0" MuladdMacro = "0.2.4" NonlinearSolve = "3.14.0" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqDifferentiation = "<0.0.1, 1" PreallocationTools = "0.4.23" Random = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqNonlinearSolve/src/OrdinaryDiffEqNonlinearSolve.jl b/lib/OrdinaryDiffEqNonlinearSolve/src/OrdinaryDiffEqNonlinearSolve.jl index a8e06ca692..c00ac00848 100644 --- a/lib/OrdinaryDiffEqNonlinearSolve/src/OrdinaryDiffEqNonlinearSolve.jl +++ b/lib/OrdinaryDiffEqNonlinearSolve/src/OrdinaryDiffEqNonlinearSolve.jl @@ -22,6 +22,7 @@ using ForwardDiff: Dual using LinearSolve: I, rmul!, norm, mul!, ldiv! using RecursiveArrayTools: recursivecopy! import SciMLStructures: canonicalize, Tunable, isscimlstructure +import OrdinaryDiffEqCore import SciMLOperators: islinear import OrdinaryDiffEqCore: nlsolve_f, set_new_W!, set_W_γdt! diff --git a/lib/OrdinaryDiffEqNonlinearSolve/src/functional.jl b/lib/OrdinaryDiffEqNonlinearSolve/src/functional.jl index d6e9898215..377e9c12a5 100644 --- a/lib/OrdinaryDiffEqNonlinearSolve/src/functional.jl +++ b/lib/OrdinaryDiffEqNonlinearSolve/src/functional.jl @@ -135,7 +135,7 @@ end end end if DiffEqBase.has_stats(integrator) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # compute norm of residuals @@ -201,7 +201,7 @@ end end if DiffEqBase.has_stats(integrator) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # compute norm of residuals diff --git a/lib/OrdinaryDiffEqNonlinearSolve/src/newton.jl b/lib/OrdinaryDiffEqNonlinearSolve/src/newton.jl index 8757fc362e..c1c8f67db7 100644 --- a/lib/OrdinaryDiffEqNonlinearSolve/src/newton.jl +++ b/lib/OrdinaryDiffEqNonlinearSolve/src/newton.jl @@ -156,7 +156,7 @@ Equations II, Springer Series in Computational Mathematics. ISBN end if DiffEqBase.has_stats(integrator) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # update W @@ -195,7 +195,7 @@ end isdae = f isa DAEFunction if DiffEqBase.has_stats(integrator) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end if isdae diff --git a/lib/OrdinaryDiffEqNordsieck/Project.toml b/lib/OrdinaryDiffEqNordsieck/Project.toml index b5d6e1e924..e663aeccd9 100644 --- a/lib/OrdinaryDiffEqNordsieck/Project.toml +++ b/lib/OrdinaryDiffEqNordsieck/Project.toml @@ -22,7 +22,7 @@ FastBroadcast = "0.3.5" LinearAlgebra = "<0.0.1, 1" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqTsit5 = "<0.0.1, 1" Polyester = "0.7.16" Random = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqNordsieck/src/OrdinaryDiffEqNordsieck.jl b/lib/OrdinaryDiffEqNordsieck/src/OrdinaryDiffEqNordsieck.jl index 20c7d37c00..17a340ae54 100644 --- a/lib/OrdinaryDiffEqNordsieck/src/OrdinaryDiffEqNordsieck.jl +++ b/lib/OrdinaryDiffEqNordsieck/src/OrdinaryDiffEqNordsieck.jl @@ -15,6 +15,7 @@ using MuladdMacro, FastBroadcast, RecursiveArrayTools import LinearAlgebra: rmul! import Static: False using OrdinaryDiffEqTsit5: Tsit5ConstantCache, Tsit5Cache +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqNordsieck/src/nordsieck_perform_step.jl b/lib/OrdinaryDiffEqNordsieck/src/nordsieck_perform_step.jl index 0575a4db5f..23fbca5039 100644 --- a/lib/OrdinaryDiffEqNordsieck/src/nordsieck_perform_step.jl +++ b/lib/OrdinaryDiffEqNordsieck/src/nordsieck_perform_step.jl @@ -2,7 +2,7 @@ function initialize!(integrator, cache::AN5ConstantCache) integrator.kshortsize = 7 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -102,7 +102,7 @@ function initialize!(integrator, cache::AN5Cache) integrator.k[6] = cache.tsit5cache.k6 integrator.k[7] = cache.tsit5cache.k7 integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::AN5Cache, repeat_step = false) @@ -188,7 +188,7 @@ function initialize!(integrator, cache::JVODEConstantCache) integrator.kshortsize = 7 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -207,7 +207,7 @@ end cache.order = 1 z[1] = integrator.uprev z[2] = f(uprev, p, t) * dt - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) dts[1] = dt end # Reset time @@ -263,7 +263,7 @@ function initialize!(integrator, cache::JVODECache) integrator.k[6] = cache.tsit5cache.k6 integrator.k[7] = cache.tsit5cache.k7 integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::JVODECache, repeat_step = false) @@ -274,7 +274,7 @@ end cache.order = 1 @.. broadcast=false z[1]=integrator.uprev f(z[2], uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false z[2]=z[2] * dt dts[1] = dt end diff --git a/lib/OrdinaryDiffEqNordsieck/src/nordsieck_utils.jl b/lib/OrdinaryDiffEqNordsieck/src/nordsieck_utils.jl index 4d5df48685..ec844ed975 100644 --- a/lib/OrdinaryDiffEqNordsieck/src/nordsieck_utils.jl +++ b/lib/OrdinaryDiffEqNordsieck/src/nordsieck_utils.jl @@ -214,7 +214,7 @@ function nlsolve_functional!(integrator, cache::T) where {T} @unpack ratetmp = cache integrator.f(ratetmp, z[1], p, dt + t) end - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) maxiters = 3 div_rate = 2 # Zero out the difference vector @@ -254,7 +254,7 @@ function nlsolve_functional!(integrator, cache::T) where {T} return false end δ_prev = δ - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) isconstcache ? (ratetmp = integrator.f(integrator.u, p, dt + t)) : integrator.f(ratetmp, integrator.u, p, dt + t) end diff --git a/lib/OrdinaryDiffEqPDIRK/Project.toml b/lib/OrdinaryDiffEqPDIRK/Project.toml index 934fdf6e95..e48807d200 100644 --- a/lib/OrdinaryDiffEqPDIRK/Project.toml +++ b/lib/OrdinaryDiffEqPDIRK/Project.toml @@ -19,7 +19,7 @@ DiffEqBase = "6.152.2" DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqDifferentiation = "<0.0.1, 1" OrdinaryDiffEqNonlinearSolve = "<0.0.1, 1" Polyester = "0.7.16" diff --git a/lib/OrdinaryDiffEqPRK/Project.toml b/lib/OrdinaryDiffEqPRK/Project.toml index 558f4ba96c..0c2a6dc582 100644 --- a/lib/OrdinaryDiffEqPRK/Project.toml +++ b/lib/OrdinaryDiffEqPRK/Project.toml @@ -16,7 +16,7 @@ DiffEqBase = "6.152.2" DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" Polyester = "0.7.16" Random = "<0.0.1, 1" Reexport = "1.2.2" diff --git a/lib/OrdinaryDiffEqQPRK/Project.toml b/lib/OrdinaryDiffEqQPRK/Project.toml index d846f141d3..24b2fe7910 100644 --- a/lib/OrdinaryDiffEqQPRK/Project.toml +++ b/lib/OrdinaryDiffEqQPRK/Project.toml @@ -18,7 +18,7 @@ DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" Random = "<0.0.1, 1" RecursiveArrayTools = "3.27.0" Reexport = "1.2.2" diff --git a/lib/OrdinaryDiffEqQPRK/src/OrdinaryDiffEqQPRK.jl b/lib/OrdinaryDiffEqQPRK/src/OrdinaryDiffEqQPRK.jl index ff9c44761b..52d279452f 100644 --- a/lib/OrdinaryDiffEqQPRK/src/OrdinaryDiffEqQPRK.jl +++ b/lib/OrdinaryDiffEqQPRK/src/OrdinaryDiffEqQPRK.jl @@ -11,6 +11,7 @@ import OrdinaryDiffEqCore: OrdinaryDiffEqAdaptiveAlgorithm, OrdinaryDiffEqConsta using Static: False using MuladdMacro, FastBroadcast using RecursiveArrayTools: recursive_unitless_bottom_eltype, recursivefill! +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqQPRK/src/qprk_perform_step.jl b/lib/OrdinaryDiffEqQPRK/src/qprk_perform_step.jl index 0461a3cf65..a61abfe452 100644 --- a/lib/OrdinaryDiffEqQPRK/src/qprk_perform_step.jl +++ b/lib/OrdinaryDiffEqQPRK/src/qprk_perform_step.jl @@ -1,6 +1,6 @@ function initialize!(integrator, ::QPRK98ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -61,7 +61,7 @@ end dt * (b16_1 * k1 + b16_6 * k6 + b16_7 * k7 + b16_8 * k8 + b16_9 * k9 + b16_10 * k10 + b16_11 * k11 + b16_12 * k12 + b16_13 * k13 + b16_14 * k14), p, t + dt) - integrator.stats.nf += 15 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 15) u = uprev + dt * (w1 * k1 + w8 * k8 + w9 * k9 + w10 * k10 + w11 * k11 + w12 * k12 + w13 * k13 + w14 * k14 + w15 * k15 + w16 * k16) @@ -74,7 +74,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -88,7 +88,7 @@ function initialize!(integrator, cache::QPRK98Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::QPRK98Cache, repeat_step = false) @@ -173,7 +173,7 @@ end stage_limiter!(u, integrator, p, t + dt) f(k16, tmp, p, t + dt) - integrator.stats.nf += 16 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 16) @.. broadcast=false thread=thread u=uprev + dt * (w1 * k1 + w8 * k8 + w9 * k9 @@ -195,6 +195,6 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return nothing end diff --git a/lib/OrdinaryDiffEqRKN/Project.toml b/lib/OrdinaryDiffEqRKN/Project.toml index 35904fa591..ae198f596e 100644 --- a/lib/OrdinaryDiffEqRKN/Project.toml +++ b/lib/OrdinaryDiffEqRKN/Project.toml @@ -17,7 +17,7 @@ DiffEqBase = "6.152.2" DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" Polyester = "0.7.16" Random = "<0.0.1, 1" RecursiveArrayTools = "3.27.0" diff --git a/lib/OrdinaryDiffEqRKN/src/OrdinaryDiffEqRKN.jl b/lib/OrdinaryDiffEqRKN/src/OrdinaryDiffEqRKN.jl index f1ee815891..fd7f206b74 100644 --- a/lib/OrdinaryDiffEqRKN/src/OrdinaryDiffEqRKN.jl +++ b/lib/OrdinaryDiffEqRKN/src/OrdinaryDiffEqRKN.jl @@ -13,6 +13,7 @@ import OrdinaryDiffEqCore: alg_order, calculate_residuals!, trivial_limiter!, _ode_interpolant!, _ode_addsteps! using FastBroadcast, Polyester, MuladdMacro, RecursiveArrayTools using DiffEqBase: @def, @tight_loop_macros +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqRKN/src/rkn_perform_step.jl b/lib/OrdinaryDiffEqRKN/src/rkn_perform_step.jl index 70077f9268..008ec1c5d4 100644 --- a/lib/OrdinaryDiffEqRKN/src/rkn_perform_step.jl +++ b/lib/OrdinaryDiffEqRKN/src/rkn_perform_step.jl @@ -21,7 +21,7 @@ function initialize!(integrator, cache::NystromCCDefaultInitialization) duprev, uprev = integrator.uprev.x kdu = integrator.f.f1(duprev, uprev, integrator.p, integrator.t) ku = integrator.f.f2(duprev, uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.fsalfirst = ArrayPartition((kdu, ku)) end @@ -47,7 +47,7 @@ function initialize!(integrator, cache::NystromDefaultInitialization) integrator.k[2] = integrator.fsallast integrator.f.f1(integrator.k[1].x[1], duprev, uprev, integrator.p, integrator.t) integrator.f.f2(integrator.k[1].x[2], duprev, uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 end @@ -81,7 +81,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -119,7 +119,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 end @@ -155,7 +155,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -213,7 +213,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -274,7 +274,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -346,7 +346,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -388,7 +388,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -420,7 +420,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) integrator.stats.nf2 += 1 end @@ -437,7 +437,7 @@ end k1cache = ArrayPartition((k.x[1], f.f1(duprev, uprev, p, t + c1 * dt))) kdu = uprev + dt * (c1 * duprev + dt * a21 * k1cache.x[1]) k₂.x[1] = f.f1(duprev, kdu, p, t + c1 * dt) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) else kdu = uprev2 + dt * (c1 * duprev2 + dt * a21 * k1cache.x[1]) ku = uprev + dt * (c1 * duprev + dt * a21 * k1cache.x[2]) @@ -450,7 +450,7 @@ end integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) integrator.stats.nf2 += 1 copyto!(k₂.x[1], k₂.x[2]) k1cache = ArrayPartition((k1cache.x[1], k.x[2])) @@ -475,7 +475,7 @@ end f.f1(k1cache.x[2], duprev, uprev, p, t + c1 * dt) @.. broadcast=false kdu=uprev + dt * (c1 * duprev + dt * a21 * k1cache.x[2]) f.f1(k₂.x[1], duprev, kdu, p, t + c1 * dt) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) else @.. broadcast=false kdu=uprev2 + dt * (c1 * duprev2 + dt * a21 * k1cache.x[1]) @.. broadcast=false ku=uprev + dt * (c1 * duprev + dt * a21 * k1cache.x[2]) @@ -491,7 +491,7 @@ end end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) integrator.stats.nf2 += 1 copyto!(k₂.x[1], k₂.x[2]) copyto!(k1cache.x[2], k1cache.x[1]) @@ -519,7 +519,7 @@ end f.f1(k₂.x[1], duprev, kdu, p, t + c1 * dt) @.. broadcast=false kdu=uprev + dt * (c2 * duprev + dt * a32 * k1cache.x[2]) f.f1(k₃.x[1], duprev, kdu, p, t + c1 * dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) else @.. broadcast=false ku=uprev + dt * (c1 * duprev + dt * a21 * k1cache.x[1]) @.. broadcast=false kdu=uprev2 + dt * (c1 * duprev2 + dt * a21 * k1cache.x[2]) @@ -541,7 +541,7 @@ end end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 copyto!(k₂.x[1], k₂.x[2]) copyto!(k₃.x[1], k₃.x[2]) @@ -571,7 +571,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -609,7 +609,7 @@ end @.. broadcast=false du=duprev + dt * (b1 * k₁ + b2 * k₂ + b3 * k₃ + b4 * k₄) f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 return nothing end @@ -635,7 +635,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -682,7 +682,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -731,7 +731,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -794,7 +794,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -821,7 +821,7 @@ function initialize!(integrator, cache::DPRKN6ConstantCache) kdu = integrator.f.f1(duprev, uprev, integrator.p, integrator.t) ku = integrator.f.f2(duprev, uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.fsalfirst = ArrayPartition((kdu, ku)) integrator.fsallast = zero(integrator.fsalfirst) @@ -869,7 +869,7 @@ end integrator.k[1] = ArrayPartition(integrator.fsalfirst.x[1], k2) integrator.k[2] = ArrayPartition(k3, k4) integrator.k[3] = ArrayPartition(k5, k6) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.stats.nf2 += 1 if integrator.opts.adaptive @@ -899,7 +899,7 @@ function initialize!(integrator, cache::DPRKN6Cache) integrator.k[3] = ArrayPartition(cache.k5, cache.k6) integrator.f.f1(integrator.fsallast.x[1], duprev, uprev, integrator.p, integrator.t) integrator.f.f2(integrator.fsallast.x[2], duprev, uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 end @@ -948,7 +948,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -994,7 +994,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -1060,7 +1060,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -1124,7 +1124,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 9 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 9) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -1216,7 +1216,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 9 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 9) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -1333,7 +1333,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 17 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 17) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -1509,7 +1509,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 17 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 17) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -1555,7 +1555,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -1602,7 +1602,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -1642,7 +1642,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -1686,7 +1686,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -1734,7 +1734,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -1800,7 +1800,7 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 1 if integrator.opts.adaptive duhat, uhat = utilde.x @@ -1831,7 +1831,7 @@ function initialize!(integrator, cache::RKN4Cache) integrator.k[2] = integrator.fsallast integrator.f.f1(integrator.k[1].x[1], duprev, uprev, integrator.p, integrator.t) integrator.f.f2(integrator.k[1].x[2], duprev, uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 end @@ -1865,7 +1865,7 @@ end integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((f.f1(du, u, p, t + dt), f.f2(du, u, p, t + dt))) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) integrator.stats.nf2 += 1 integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -1905,6 +1905,6 @@ end f.f1(k.x[1], du, u, p, t + dt) f.f2(k.x[2], du, u, p, t + dt) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) integrator.stats.nf2 += 1 end diff --git a/lib/OrdinaryDiffEqRosenbrock/Project.toml b/lib/OrdinaryDiffEqRosenbrock/Project.toml index a6beaa8c5e..d0dec8acf2 100644 --- a/lib/OrdinaryDiffEqRosenbrock/Project.toml +++ b/lib/OrdinaryDiffEqRosenbrock/Project.toml @@ -35,7 +35,7 @@ LinearSolve = "2.32.0" MacroTools = "0.5.13" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqDifferentiation = "<0.0.1, 1" OrdinaryDiffEqNonlinearSolve = "<0.0.1, 1" Polyester = "0.7.16" diff --git a/lib/OrdinaryDiffEqRosenbrock/src/OrdinaryDiffEqRosenbrock.jl b/lib/OrdinaryDiffEqRosenbrock/src/OrdinaryDiffEqRosenbrock.jl index 4c4d4a9f34..d86694bba0 100644 --- a/lib/OrdinaryDiffEqRosenbrock/src/OrdinaryDiffEqRosenbrock.jl +++ b/lib/OrdinaryDiffEqRosenbrock/src/OrdinaryDiffEqRosenbrock.jl @@ -23,6 +23,8 @@ import ForwardDiff using FiniteDiff using LinearAlgebra: mul!, diag, diagm, I, Diagonal, norm import ADTypes: AutoForwardDiff +import OrdinaryDiffEqCore + using OrdinaryDiffEqDifferentiation: TimeDerivativeWrapper, TimeGradientWrapper, UDerivativeWrapper, UJacobianWrapper, wrapprecs, calc_tderivative, build_grad_config, diff --git a/lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl b/lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl index 32330c27e1..5600b1bc27 100644 --- a/lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl +++ b/lib/OrdinaryDiffEqRosenbrock/src/generic_rosenbrock.jl @@ -270,7 +270,7 @@ function gen_initialize(cachename::Symbol,constcachename::Symbol) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -286,7 +286,7 @@ function gen_initialize(cachename::Symbol,constcachename::Symbol) resize!(integrator.k, integrator.kshortsize) integrator.k .= [fsalfirst,fsallast] integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end end end @@ -314,7 +314,7 @@ function gen_constant_perform_step(tabmask::RosenbrockTableau{Bool,Bool},cachena integrator.stats.nsolve += 1 u=+(uprev,$(aijkj...)) du = f(u, p, t+$(Symbol(:c,i+1))*dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp=+(du,$(Symbol(:dtd,i+1))*dT,$(Cijkj...)) else @@ -366,7 +366,7 @@ function gen_constant_perform_step(tabmask::RosenbrockTableau{Bool,Bool},cachena $(iterexprs...) integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast @@ -417,7 +417,7 @@ function gen_perform_step(tabmask::RosenbrockTableau{Bool,Bool},cachename::Symbo integrator.stats.nsolve += 1 @.. broadcast=false u = +(uprev,$(aijkj...)) f( du, u, p, t+$(Symbol(:c,i+1))*dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp = +(du,$dtdj*dT,$(dtCijkj...)) else @@ -483,7 +483,7 @@ function gen_perform_step(tabmask::RosenbrockTableau{Bool,Bool},cachename::Symbo $(iterexprs...) f( fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) $(adaptiveexpr...) end diff --git a/lib/OrdinaryDiffEqRosenbrock/src/rosenbrock_perform_step.jl b/lib/OrdinaryDiffEqRosenbrock/src/rosenbrock_perform_step.jl index c476601573..e9028661bf 100644 --- a/lib/OrdinaryDiffEqRosenbrock/src/rosenbrock_perform_step.jl +++ b/lib/OrdinaryDiffEqRosenbrock/src/rosenbrock_perform_step.jl @@ -8,7 +8,7 @@ function initialize!(integrator, cache::Union{Rosenbrock23Cache, integrator.k[1] = k₁ integrator.k[2] = k₂ integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end function initialize!(integrator, @@ -17,7 +17,7 @@ function initialize!(integrator, integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -41,7 +41,7 @@ end if repeat_step f(integrator.fsalfirst, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end calc_rosenbrock_differentiation!(integrator, cache, γ, γ, repeat_step, false) @@ -70,7 +70,7 @@ end @.. broadcast=false u=uprev + dto2 * k₁ stage_limiter!(u, integrator, p, t + dto2) f(f₁, u, p, t + dto2) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I copyto!(tmp, k₁) @@ -94,7 +94,7 @@ end if integrator.opts.adaptive f(fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=fsallast - c₃₂ * (k₂ - f₁) - @@ -153,7 +153,7 @@ end if repeat_step f(integrator.fsalfirst, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end calc_rosenbrock_differentiation!(integrator, cache, γ, γ, repeat_step, false) @@ -182,7 +182,7 @@ end @.. broadcast=false u=uprev + dto2 * k₁ stage_limiter!(u, integrator, p, t + dto2) f(f₁, u, p, t + dto2) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I tmp .= k₁ @@ -203,7 +203,7 @@ end @.. broadcast=false tmp=uprev + dt * k₂ stage_limiter!(u, integrator, p, t + dt) f(fsallast, tmp, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=fsallast - c₃₂ * (k₂ - f₁) - 2(k₁ - fsalfirst) + @@ -252,7 +252,7 @@ end if repeat_step integrator.fsalfirst = f(uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end mass_matrix = integrator.f.mass_matrix @@ -269,7 +269,7 @@ end k₁ = _reshape(W \ -_vec((integrator.fsalfirst + γ * dT)), axes(uprev)) integrator.stats.nsolve += 1 f₁ = f(uprev + dto2 * k₁, p, t + dto2) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I k₂ = _reshape(W \ -_vec(f₁ - k₁), axes(uprev)) + k₁ @@ -281,7 +281,7 @@ end if integrator.opts.adaptive integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I k₃ = _reshape( @@ -331,7 +331,7 @@ end if repeat_step integrator.fsalfirst = f(uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # Time derivative @@ -346,7 +346,7 @@ end k₁ = _reshape(W \ -_vec((integrator.fsalfirst + γ * dT)), axes(uprev)) integrator.stats.nsolve += 1 f₁ = f(uprev + dto2 * k₁, p, t + dto2) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I k₂ = _reshape(W \ -_vec(f₁ - k₁), axes(uprev)) + k₁ @@ -358,7 +358,7 @@ end integrator.stats.nsolve += 1 tmp = uprev + dt * k₂ integrator.fsallast = f(tmp, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I k₃ = _reshape( @@ -400,7 +400,7 @@ function initialize!(integrator, integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -420,7 +420,7 @@ function initialize!(integrator, integrator.k[1] = fsalfirst integrator.k[2] = fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::Rosenbrock33ConstantCache, @@ -456,7 +456,7 @@ end integrator.stats.nsolve += 1 u = uprev + a21 * k1 du = f(u, p, t + c2 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd2 * dT + dtC21 * k1 @@ -468,7 +468,7 @@ end integrator.stats.nsolve += 1 u = uprev + a31 * k1 + a32 * k2 du = f(u, p, t + c3 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd3 * dT + dtC31 * k1 + dtC32 * k2 @@ -480,7 +480,7 @@ end integrator.stats.nsolve += 1 u = uprev + b1 * k1 + b2 * k2 + b3 * k3 integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive utilde = btilde1 * k1 + btilde2 * k2 + btilde3 * k3 @@ -541,7 +541,7 @@ end @.. broadcast=false u=uprev + a21 * k1 stage_limiter!(u, integrator, p, t + c2 * dt) f(du, u, p, t + c2 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd2 * dT + dtC21 * k1 @@ -562,7 +562,7 @@ end @.. broadcast=false u=uprev + a31 * k1 + a32 * k2 stage_limiter!(u, integrator, p, t + c3 * dt) f(du, u, p, t + c3 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd3 * dT + dtC31 * k1 + dtC32 * k2 @@ -585,7 +585,7 @@ end step_limiter!(u, integrator, p, t + dt) f(fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive @.. broadcast=false utilde=btilde1 * k1 + btilde2 * k2 + btilde3 * k3 @@ -646,7 +646,7 @@ end integrator.stats.nsolve += 1 u = uprev + a31 * k1 + a32 * k2 du = f(u, p, t + c3 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd3 * dT + dtC31 * k1 + dtC32 * k2 @@ -658,7 +658,7 @@ end integrator.stats.nsolve += 1 u = uprev + a41 * k1 + a42 * k2 + a43 * k3 du = f(u, p, t + dt) #-- c4 = 1 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd4 * dT + dtC41 * k1 + dtC42 * k2 + dtC43 * k3 @@ -670,7 +670,7 @@ end integrator.stats.nsolve += 1 u = uprev + b1 * k1 + b2 * k2 + b3 * k3 + b4 * k4 integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive utilde = btilde1 * k1 + btilde2 * k2 + btilde3 * k3 + btilde4 * k4 @@ -757,7 +757,7 @@ end @.. broadcast=false u=uprev + a31 * k1 + a32 * k2 stage_limiter!(u, integrator, p, t + c3 * dt) f(du, u, p, t + c3 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd3 * dT + dtC31 * k1 + dtC32 * k2 @@ -774,7 +774,7 @@ end @.. broadcast=false u=uprev + a41 * k1 + a42 * k2 + a43 * k3 stage_limiter!(u, integrator, p, t + dt) f(du, u, p, t + dt) #-- c4 = 1 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd4 * dT + dtC41 * k1 + dtC42 * k2 + @@ -795,7 +795,7 @@ end step_limiter!(u, integrator, p, t + dt) f(fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive @.. broadcast=false utilde=btilde1 * k1 + btilde2 * k2 + btilde3 * k3 + btilde4 * k4 @@ -883,7 +883,7 @@ end end du = f(uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) k3 = copy(du) #-- save for stage 3 linsolve_tmp = du + dtd1 * dT @@ -892,7 +892,7 @@ end integrator.stats.nsolve += 1 u = uprev + a21 * k1 du = f(u, p, t + c2 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd2 * dT + dtC21 * k1 @@ -913,7 +913,7 @@ end integrator.stats.nsolve += 1 u = uprev + a41 * k1 + a42 * k2 + a43 * k3 du = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + (dtC41 * k1 + dtC42 * k2 + dtC43 * k3) @@ -1016,7 +1016,7 @@ end dtgamma = dt * gamma f(cache.fsalfirst, uprev, p, t) # used in calc_rosenbrock_differentiation! - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) calc_rosenbrock_differentiation!(integrator, cache, dtd1, dtgamma, repeat_step, true) @@ -1042,7 +1042,7 @@ end @.. broadcast=false u=uprev + a21 * k1 stage_limiter!(u, integrator, p, t + c2 * dt) f(du, u, p, t + c2 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd2 * dT + dtC21 * k1 @@ -1072,7 +1072,7 @@ end @.. broadcast=false u=uprev + a41 * k1 + a42 * k2 + a43 * k3 stage_limiter!(u, integrator, p, t + c2 * dt) f(du, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + @@ -1251,7 +1251,7 @@ end end du = f(uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) linsolve_tmp = du + dtd1 * dT @@ -1259,7 +1259,7 @@ end integrator.stats.nsolve += 1 u = uprev + a21 * k1 du = f(u, p, t + c2 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd2 * dT + dtC21 * k1 @@ -1271,7 +1271,7 @@ end integrator.stats.nsolve += 1 u = uprev + a31 * k1 + a32 * k2 du = f(u, p, t + c3 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd3 * dT + (dtC31 * k1 + dtC32 * k2) @@ -1283,7 +1283,7 @@ end integrator.stats.nsolve += 1 u = uprev + a41 * k1 + a42 * k2 + a43 * k3 du = f(u, p, t + c4 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd4 * dT + (dtC41 * k1 + dtC42 * k2 + dtC43 * k3) @@ -1295,7 +1295,7 @@ end integrator.stats.nsolve += 1 u = uprev + a51 * k1 + a52 * k2 + a53 * k3 + a54 * k4 du = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + (dtC52 * k2 + dtC54 * k4 + dtC51 * k1 + dtC53 * k3) @@ -1308,7 +1308,7 @@ end integrator.stats.nsolve += 1 u = u + k5 du = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + (dtC61 * k1 + dtC62 * k2 + dtC65 * k5 + dtC64 * k4 + dtC63 * k3) @@ -1379,7 +1379,7 @@ end dtgamma = dt * gamma f(cache.fsalfirst, uprev, p, t) # used in calc_rosenbrock_differentiation! - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) calc_rosenbrock_differentiation!(integrator, cache, dtd1, dtgamma, repeat_step, true) @@ -1405,7 +1405,7 @@ end @.. broadcast=false u=uprev + a21 * k1 stage_limiter!(u, integrator, p, t + c2 * dt) f(du, u, p, t + c2 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd2 * dT + dtC21 * k1 @@ -1422,7 +1422,7 @@ end @.. broadcast=false u=uprev + a31 * k1 + a32 * k2 stage_limiter!(u, integrator, p, t + c3 * dt) f(du, u, p, t + c3 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd3 * dT + (dtC31 * k1 + dtC32 * k2) @@ -1439,7 +1439,7 @@ end @.. broadcast=false u=uprev + a41 * k1 + a42 * k2 + a43 * k3 stage_limiter!(u, integrator, p, t + c4 * dt) f(du, u, p, t + c4 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd4 * dT + @@ -1457,7 +1457,7 @@ end @.. broadcast=false u=uprev + a51 * k1 + a52 * k2 + a53 * k3 + a54 * k4 stage_limiter!(u, integrator, p, t + dt) f(du, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + @@ -1474,7 +1474,7 @@ end u .+= k5 f(du, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + (dtC61 * k1 + dtC62 * k2 + dtC65 * k5 + @@ -1578,7 +1578,7 @@ end end du1 = f(uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) linsolve_tmp = du1 + dtd1 * dT @@ -1586,7 +1586,7 @@ end integrator.stats.nsolve += 1 u = uprev + a21 * k1 du = f(u, p, t + c2 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd2 * dT + dtC21 * k1 @@ -1598,7 +1598,7 @@ end integrator.stats.nsolve += 1 u = uprev + a31 * k1 + a32 * k2 du = f(u, p, t + c3 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd3 * dT + (dtC31 * k1 + dtC32 * k2) @@ -1610,7 +1610,7 @@ end integrator.stats.nsolve += 1 u = uprev + a41 * k1 + a42 * k2 + a43 * k3 du = f(u, p, t + c4 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd4 * dT + (dtC41 * k1 + dtC42 * k2 + dtC43 * k3) @@ -1622,7 +1622,7 @@ end integrator.stats.nsolve += 1 u = uprev + a51 * k1 + a52 * k2 + a53 * k3 + a54 * k4 du = f(u, p, t + c5 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + dtd5 * dT + (dtC52 * k2 + dtC54 * k4 + dtC51 * k1 + dtC53 * k3) @@ -1635,7 +1635,7 @@ end integrator.stats.nsolve += 1 u = uprev + a61 * k1 + a62 * k2 + a63 * k3 + a64 * k4 + a65 * k5 du = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + (dtC61 * k1 + dtC62 * k2 + dtC63 * k3 + dtC64 * k4 + dtC65 * k5) @@ -1649,7 +1649,7 @@ end integrator.stats.nsolve += 1 u = u + k6 du = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + @@ -1666,7 +1666,7 @@ end integrator.stats.nsolve += 1 u = u + k7 du = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I linsolve_tmp = du + @@ -1710,7 +1710,7 @@ end 0.5 * (integrator.k[1] + 0.5 * (integrator.k[2] + 0.5 * integrator.k[3]))) du1 = (0.25 * (integrator.k[2] + integrator.k[3]) - uprev + u) / dt du = f(k2, p, t + dt / 2) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I du2 = du1 - du else @@ -1782,7 +1782,7 @@ end dtgamma = dt * gamma f(cache.fsalfirst, uprev, p, t) # used in calc_rosenbrock_differentiation! - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) calc_rosenbrock_differentiation!(integrator, cache, dtd1, dtgamma, repeat_step, true) @@ -1810,7 +1810,7 @@ end @.. broadcast=false u=uprev + a21 * k1 stage_limiter!(u, integrator, p, t + c2 * dt) f(du, u, p, t + c2 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd2 * dT + dtC21 * k1 @@ -1828,7 +1828,7 @@ end @.. broadcast=false u=uprev + a31 * k1 + a32 * k2 stage_limiter!(u, integrator, p, t + c3 * dt) f(du, u, p, t + c3 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd3 * dT + (dtC31 * k1 + dtC32 * k2) @@ -1846,7 +1846,7 @@ end @.. broadcast=false u=uprev + a41 * k1 + a42 * k2 + a43 * k3 stage_limiter!(u, integrator, p, t + c4 * dt) f(du, u, p, t + c4 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd4 * dT + @@ -1865,7 +1865,7 @@ end @.. broadcast=false u=uprev + a51 * k1 + a52 * k2 + a53 * k3 + a54 * k4 stage_limiter!(u, integrator, p, t + c5 * dt) f(du, u, p, t + c5 * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + dtd5 * dT + @@ -1884,7 +1884,7 @@ end @.. broadcast=false u=uprev + a61 * k1 + a62 * k2 + a63 * k3 + a64 * k4 + a65 * k5 stage_limiter!(u, integrator, p, t + dt) f(du, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + (dtC61 * k1 + dtC62 * k2 + dtC63 * k3 + @@ -1904,7 +1904,7 @@ end u .+= k6 stage_limiter!(u, integrator, p, t + dt) f(du, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + (dtC71 * k1 + dtC72 * k2 + dtC73 * k3 + @@ -1923,7 +1923,7 @@ end u .+= k7 f(du, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I @.. broadcast=false linsolve_tmp=du + (dtC81 * k1 + dtC82 * k2 + dtC83 * k3 + @@ -1971,7 +1971,7 @@ end 0.5 * (integrator.k[1] + 0.5 * (integrator.k[2] + 0.5 * integrator.k[3]))) du1 = (0.25 * (integrator.k[2] + integrator.k[3]) - uprev + u) / dt f(du, k2, p, t + dt / 2) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if mass_matrix === I du2 = du1 - du else diff --git a/lib/OrdinaryDiffEqSDIRK/Project.toml b/lib/OrdinaryDiffEqSDIRK/Project.toml index 2634167fc5..29ee9c1562 100644 --- a/lib/OrdinaryDiffEqSDIRK/Project.toml +++ b/lib/OrdinaryDiffEqSDIRK/Project.toml @@ -24,7 +24,7 @@ FastBroadcast = "0.3.5" LinearAlgebra = "<0.0.1, 1" MacroTools = "0.5.13" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqDifferentiation = "<0.0.1, 1" OrdinaryDiffEqNonlinearSolve = "<0.0.1, 1" Random = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqSDIRK/src/OrdinaryDiffEqSDIRK.jl b/lib/OrdinaryDiffEqSDIRK/src/OrdinaryDiffEqSDIRK.jl index be54cf8d48..75d94d5677 100644 --- a/lib/OrdinaryDiffEqSDIRK/src/OrdinaryDiffEqSDIRK.jl +++ b/lib/OrdinaryDiffEqSDIRK/src/OrdinaryDiffEqSDIRK.jl @@ -17,6 +17,7 @@ import OrdinaryDiffEqCore: alg_order, calculate_residuals!, using TruncatedStacktraces, MuladdMacro, MacroTools, FastBroadcast, RecursiveArrayTools using SciMLBase: SplitFunction using LinearAlgebra: mul!, I +import OrdinaryDiffEqCore using OrdinaryDiffEqDifferentiation: UJacobianWrapper, dolinsolve using OrdinaryDiffEqNonlinearSolve: du_alias_or_new, markfirststage!, build_nlsolver, diff --git a/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_perform_step.jl b/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_perform_step.jl index 1b3d6f1a7b..9c2df93493 100644 --- a/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_perform_step.jl +++ b/lib/OrdinaryDiffEqSDIRK/src/kencarp_kvaerno_perform_step.jl @@ -12,7 +12,7 @@ function initialize!(integrator, integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -38,7 +38,7 @@ function initialize!(integrator, integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::Kvaerno3ConstantCache, @@ -1782,7 +1782,7 @@ end if integrator.f isa SplitFunction f2(k8, u, p, t + dt) k8 .*= dt - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=uprev + a81 * z₁ + a84 * z₄ + a85 * z₅ + a86 * z₆ + a87 * z₇ + γ * z₈ + eb1 * k1 + eb4 * k4 + eb5 * k5 + eb6 * k6 + eb7 * k7 + eb8 * k8 @@ -2180,7 +2180,7 @@ end if integrator.f isa SplitFunction f2(k7, u, p, t + dt) k7 .*= dt - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=uprev + a73 * z₃ + a74 * z₄ + a75 * z₅ + a76 * z₆ + γ * z₇ + eb3 * k3 + eb4 * k4 + eb5 * k5 + eb6 * k6 + eb7 * k7 end @@ -2623,7 +2623,7 @@ end if integrator.f isa SplitFunction f2(k8, u, p, t + dt) k8 .*= dt - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=uprev + a83 * z₃ + a84 * z₄ + a85 * z₅ + a86 * z₆ + a87 * z₇ + γ * z₈ + eb3 * k3 + eb4 * k4 + eb5 * k5 + eb6 * k6 + eb7 * k7 + eb8 * k8 diff --git a/lib/OrdinaryDiffEqSDIRK/src/sdirk_perform_step.jl b/lib/OrdinaryDiffEqSDIRK/src/sdirk_perform_step.jl index d94bf0085f..1e9aa802bb 100644 --- a/lib/OrdinaryDiffEqSDIRK/src/sdirk_perform_step.jl +++ b/lib/OrdinaryDiffEqSDIRK/src/sdirk_perform_step.jl @@ -21,7 +21,7 @@ function initialize!(integrator, integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -56,7 +56,7 @@ function initialize!(integrator, integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # For the interpolation, needs k at the updated point - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::ImplicitEulerConstantCache, @@ -109,7 +109,7 @@ end integrator.EEst += integrator.opts.internalnorm(atmp, t) end - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -159,7 +159,7 @@ end else integrator.EEst = 1 end - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) f(integrator.fsallast, u, p, t + dt) if integrator.opts.adaptive && integrator.differential_vars !== nothing @@ -190,7 +190,7 @@ end u = nlsolver.tmp + z integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -220,7 +220,7 @@ end step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) f(integrator.fsallast, u, p, t + dt) end @@ -289,7 +289,7 @@ end end integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -370,7 +370,7 @@ end end end - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) f(integrator.fsallast, u, p, t + dt) end @@ -606,7 +606,7 @@ end end integrator.fsallast = f(u, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -669,7 +669,7 @@ end integrator.EEst = integrator.opts.internalnorm(atmp, t) end - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) f(integrator.fsallast, u, p, t) end @@ -742,7 +742,7 @@ end end end - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -819,7 +819,7 @@ end end end - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) f(integrator.fsallast, u, p, t + dt) end @@ -872,7 +872,7 @@ end ################################### Finalize integrator.fsallast = f(u, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.u = u @@ -921,7 +921,7 @@ end ################################### Finalize - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) f(integrator.fsallast, u, p, t) end diff --git a/lib/OrdinaryDiffEqSSPRK/Project.toml b/lib/OrdinaryDiffEqSSPRK/Project.toml index 716273ee14..d8a784019b 100644 --- a/lib/OrdinaryDiffEqSSPRK/Project.toml +++ b/lib/OrdinaryDiffEqSSPRK/Project.toml @@ -22,7 +22,7 @@ DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqLowStorageRK = "<0.0.1, 1" Polyester = "0.7.16" PrecompileTools = "1.2.1" diff --git a/lib/OrdinaryDiffEqSSPRK/src/ssprk_perform_step.jl b/lib/OrdinaryDiffEqSSPRK/src/ssprk_perform_step.jl index 4f39c2e83c..d0a26349f2 100644 --- a/lib/OrdinaryDiffEqSSPRK/src/ssprk_perform_step.jl +++ b/lib/OrdinaryDiffEqSSPRK/src/ssprk_perform_step.jl @@ -1,6 +1,6 @@ function initialize!(integrator, cache::SSPRK22ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -20,7 +20,7 @@ end # u u = (uprev + u + dt * k) / 2 - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) integrator.u = u end @@ -46,7 +46,7 @@ end @.. broadcast=false thread=thread u=(uprev + u + dt * k) / 2 stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) end function initialize!(integrator, cache::KYKSSPRK42Cache) @@ -122,7 +122,7 @@ function initialize!(integrator, cache::SHLDDRK52ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -206,7 +206,7 @@ function initialize!(integrator, cache::SHLDDRK_2NConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -355,7 +355,7 @@ end function initialize!(integrator, cache::SSPRK33ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -378,7 +378,7 @@ end # u u = (uprev + 2 * u + 2 * dt * k) / 3 - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) integrator.u = u end @@ -408,12 +408,12 @@ end @.. broadcast=false thread=thread u=(uprev + 2 * u + 2 * dt * k) / 3 stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) end function initialize!(integrator, cache::SSPRK53ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -443,7 +443,7 @@ end # u u = α52 * u + α54 * tmp + β54 * dt * k - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.u = u end @@ -482,12 +482,12 @@ end @.. broadcast=false thread=thread u=α52 * u + α54 * tmp + β54 * dt * k stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) end function initialize!(integrator, cache::SSPRK53_2N1ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -518,7 +518,7 @@ end # u u = u + β54 * dt * k - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.u = u end @@ -558,12 +558,12 @@ end @.. broadcast=false thread=thread u=u + β54 * dt * k stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) end function initialize!(integrator, cache::SSPRK53_2N2ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -594,7 +594,7 @@ end # u u = α50 * uprev + α54 * u + β54 * dt * k - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.u = u end @@ -633,7 +633,7 @@ end @.. broadcast=false thread=thread u=α50 * uprev + α54 * u + β54 * dt * k stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) end function initialize!(integrator, cache::SSPRK53_HConstantCache) @@ -668,7 +668,7 @@ end # u u = u + β54 * dt * k - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.u = u end @@ -707,12 +707,12 @@ end @.. broadcast=false thread=thread u=u + β54 * dt * k stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) end function initialize!(integrator, cache::SSPRK63ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -745,7 +745,7 @@ end # u u = α62 * u₂ + α65 * tmp + β65 * dt * k - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) integrator.u = u end @@ -788,12 +788,12 @@ end @.. broadcast=false thread=thread u=α62 * u₂ + α65 * tmp + β65 * dt * k stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) end function initialize!(integrator, cache::SSPRK73ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -829,7 +829,7 @@ end # u u = α73 * u + α76 * tmp + β76 * dt * k - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) integrator.u = u end @@ -876,12 +876,12 @@ end @.. broadcast=false thread=thread u=α73 * u + α76 * tmp + β76 * dt * k stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) end function initialize!(integrator, cache::SSPRK83ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -920,7 +920,7 @@ end # u u = tmp + β87 * dt * k - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) integrator.u = u end @@ -971,14 +971,14 @@ end @.. broadcast=false thread=thread u=tmp + β87 * dt * k stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) end function initialize!(integrator, cache::SSPRK43ConstantCache) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -1008,7 +1008,7 @@ end # u u = u + dt_2 * k # corresponds to b = (1/6, 1/6, 1/6, 1/2) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) if integrator.opts.adaptive utilde = half_u * (utilde - u) # corresponds to bhat = (1/4, 1/4, 1/4, 1/4) atmp = calculate_residuals(utilde, uprev, u, integrator.opts.abstol, @@ -1063,14 +1063,14 @@ end thread) integrator.EEst = integrator.opts.internalnorm(atmp, t) end - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) end function initialize!(integrator, cache::SSPRK432ConstantCache) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -1100,7 +1100,7 @@ end # u u = u + dt_2 * k - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) if integrator.opts.adaptive utilde = utilde - u atmp = calculate_residuals(utilde, uprev, u, integrator.opts.abstol, @@ -1154,14 +1154,14 @@ end thread) integrator.EEst = integrator.opts.internalnorm(atmp, t) end - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) end function initialize!(integrator, cache::SSPRKMSVS32ConstantCache) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -1185,7 +1185,7 @@ end k = f(u, p, t + dt) u = uprev + dt * k k = f(u, p, t + dt) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) u = (uprev + u + dt * k) / 2 if cache.step == 1 u_2 = uprev @@ -1227,12 +1227,12 @@ end end if accpt == true integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.u = u else integrator.fsallast = f(uprev, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.u = uprev end @@ -1250,7 +1250,7 @@ function initialize!(integrator, cache::SSPRKMSVS32Cache) integrator.fsallast = cache.k integrator.k[1] = integrator.fsalfirst integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::SSPRKMSVS32Cache, repeat_step = false) @@ -1261,7 +1261,7 @@ end @.. broadcast=false thread=thread u=uprev + dt * fsalfirst stage_limiter!(u, integrator, p, t + dt) f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false thread=thread u=(uprev + u + dt * k) / 2 stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) @@ -1282,7 +1282,7 @@ end step_limiter!(u, integrator, p, t + dt) end cache.step += 1 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) f(k, u, p, t + dt) end @@ -1290,7 +1290,7 @@ function initialize!(integrator, cache::SSPRKMSVS43ConstantCache) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -1309,17 +1309,17 @@ end if cache.step == 1 u_3 = uprev cache.k3 = f(u_3, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end if cache.step == 2 u_2 = uprev cache.k2 = f(u_2, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end if cache.step == 3 u_1 = uprev cache.k1 = f(u_1, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # u else @@ -1333,7 +1333,7 @@ end u_1 = uprev end integrator.fsallast = f(u, p, t + dt) # For interpolation, then FSAL'd - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[1] = integrator.fsalfirst integrator.u = u cache.step += 1 @@ -1349,7 +1349,7 @@ function initialize!(integrator, cache::SSPRKMSVS43Cache) integrator.fsallast = cache.k integrator.k[1] = integrator.fsalfirst integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::SSPRKMSVS43Cache, repeat_step = false) @@ -1360,24 +1360,24 @@ end @.. broadcast=false thread=thread u=uprev + dt * fsalfirst stage_limiter!(u, integrator, p, t + dt) f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false thread=thread u=(uprev + u + dt * k) / 2 stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) if cache.step == 1 cache.u_3 .= uprev f(k3, u_3, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end if cache.step == 2 cache.u_2 .= uprev f(k2, u_2, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end if cache.step == 3 cache.u_1 .= uprev f(k1, u_1, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end # u else @@ -1393,7 +1393,7 @@ end cache.u_1 .= uprev end cache.step += 1 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) f(k, u, p, t + dt) end @@ -1401,7 +1401,7 @@ function initialize!(integrator, cache::SSPRK932ConstantCache) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -1432,12 +1432,12 @@ end # u5 u = u + dt_6 * k k = f(u, p, t + 5 * dt_6) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) # u6 u = u + dt_6 * k if integrator.opts.adaptive k = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) utilde = (uprev + 6 * u + 6 * dt * k) / 7 end # u6* @@ -1452,7 +1452,7 @@ end # u u = u + dt_6 * k - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) if integrator.opts.adaptive utilde = utilde - u atmp = calculate_residuals(utilde, uprev, u, integrator.opts.abstol, @@ -1499,13 +1499,13 @@ end @.. broadcast=false thread=thread u=u + dt_6 * k stage_limiter!(u, integrator, p, t + 5 * dt_6) f(k, u, p, t + 5 * dt_6) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) # u6 @.. broadcast=false thread=thread u=u + dt_6 * k if integrator.opts.adaptive stage_limiter!(u, integrator, p, t + dt) f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false thread=thread utilde=(uprev + 6 * u + 6 * dt * k) / 7 end # u6* @@ -1525,7 +1525,7 @@ end @.. broadcast=false thread=thread u=u + dt_6 * k stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) if integrator.opts.adaptive @.. broadcast=false thread=thread utilde=utilde - u @@ -1538,7 +1538,7 @@ end function initialize!(integrator, cache::SSPRK54ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -1568,7 +1568,7 @@ end # u u = α52 * u₂ + α53 * u₃ + β53 * dt * k₃ + α54 * tmp + β54 * dt * k - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.u = u end @@ -1608,12 +1608,12 @@ end β54 * dt * k stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) end function initialize!(integrator, cache::SSPRK104ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.kshortsize = 1 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -1651,7 +1651,7 @@ end k = f(tmp, p, t + dt) u = (uprev + 9 * (u + dt_6 * k₄) + 15 * (tmp + dt_6 * k)) / 25 - integrator.stats.nf += 10 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 10) integrator.u = u end @@ -1703,5 +1703,5 @@ end 15 * (tmp + dt_6 * k)) / 25 stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 10 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 10) end diff --git a/lib/OrdinaryDiffEqStabilizedIRK/Project.toml b/lib/OrdinaryDiffEqStabilizedIRK/Project.toml index 4c7db7ca66..11b8ece1fa 100644 --- a/lib/OrdinaryDiffEqStabilizedIRK/Project.toml +++ b/lib/OrdinaryDiffEqStabilizedIRK/Project.toml @@ -20,7 +20,7 @@ DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" LinearAlgebra = "<0.0.1, 1" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqDifferentiation = "<0.0.1, 1" OrdinaryDiffEqNonlinearSolve = "<0.0.1, 1" Random = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqStabilizedIRK/src/OrdinaryDiffEqStabilizedIRK.jl b/lib/OrdinaryDiffEqStabilizedIRK/src/OrdinaryDiffEqStabilizedIRK.jl index 5071e559d1..bc816a0275 100644 --- a/lib/OrdinaryDiffEqStabilizedIRK/src/OrdinaryDiffEqStabilizedIRK.jl +++ b/lib/OrdinaryDiffEqStabilizedIRK/src/OrdinaryDiffEqStabilizedIRK.jl @@ -17,6 +17,7 @@ using OrdinaryDiffEqNonlinearSolve: NLNewton, nlsolve!, isnewton, build_nlsolver markfirststage!, du_alias_or_new, get_W using FastBroadcast, MuladdMacro, RecursiveArrayTools import StaticArrays: SArray, MVector, SVector, @SVector, StaticArray, MMatrix, SA +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqStabilizedIRK/src/irkc_perform_step.jl b/lib/OrdinaryDiffEqStabilizedIRK/src/irkc_perform_step.jl index 4ddfaaa63b..b79139d3bd 100644 --- a/lib/OrdinaryDiffEqStabilizedIRK/src/irkc_perform_step.jl +++ b/lib/OrdinaryDiffEqStabilizedIRK/src/irkc_perform_step.jl @@ -5,7 +5,7 @@ function initialize!(integrator, cache::IRKCConstantCache) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) cache.du₁ = f1(uprev, p, t) cache.du₂ = f2(uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.fsalfirst = cache.du₁ + cache.du₂ @@ -82,7 +82,7 @@ function perform_step!(integrator, cache::IRKCConstantCache, repeat_step = false f1ⱼ₋₁ = f1(gprev, p, t + Cⱼ₋₁ * dt) f2ⱼ₋₁ = f2(gprev, p, t + Cⱼ₋₁ * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 nlsolver.tmp = (1 - μ - ν) * uprev + μ * gprev + ν * gprev2 + dt * μs * f2ⱼ₋₁ + dt * νs * du₂ + (νs - (1 - μ - ν) * μs₁) * dt * du₁ - @@ -112,7 +112,7 @@ function perform_step!(integrator, cache::IRKCConstantCache, repeat_step = false cache.du₁ = f1(u, p, t + dt) cache.du₂ = f2(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 # error estimate if isnewton(nlsolver) && integrator.opts.adaptive @@ -141,7 +141,7 @@ function initialize!(integrator, cache::IRKCCache) integrator.k[2] = integrator.fsallast f1(cache.du₁, uprev, p, t) f2(cache.du₂, uprev, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 @.. broadcast=false integrator.fsalfirst=cache.du₁ + cache.du₂ end @@ -216,7 +216,7 @@ function perform_step!(integrator, cache::IRKCCache, repeat_step = false) f1(f1ⱼ₋₁, gprev, p, t + Cⱼ₋₁ * dt) f2(f2ⱼ₋₁, gprev, p, t + Cⱼ₋₁ * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 @.. broadcast=false nlsolver.tmp=(1 - μ - ν) * uprev + μ * gprev + ν * gprev2 + dt * μs * f2ⱼ₋₁ + dt * νs * du₂ + @@ -249,7 +249,7 @@ function perform_step!(integrator, cache::IRKCCache, repeat_step = false) @.. broadcast=false f2ⱼ₋₁=du₂ f1(du₁, u, p, t + dt) f2(du₂, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 # error estimate if isnewton(nlsolver) && integrator.opts.adaptive diff --git a/lib/OrdinaryDiffEqStabilizedIRK/src/irkc_utils.jl b/lib/OrdinaryDiffEqStabilizedIRK/src/irkc_utils.jl index 4edcebe0e5..ec854aa330 100644 --- a/lib/OrdinaryDiffEqStabilizedIRK/src/irkc_utils.jl +++ b/lib/OrdinaryDiffEqStabilizedIRK/src/irkc_utils.jl @@ -19,7 +19,7 @@ function maxeig!(integrator, cache::OrdinaryDiffEqConstantCache) else fz = fsalfirst z = f(fz, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end else z = cache.zprev @@ -56,7 +56,7 @@ function maxeig!(integrator, cache::OrdinaryDiffEqConstantCache) tmp = fz - cache.du₂ else fz = f(z, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) tmp = fz - fsalfirst end Δ = integrator.opts.internalnorm(tmp, t) @@ -122,7 +122,7 @@ function maxeig!(integrator, cache::OrdinaryDiffEqMutableCache) else @.. broadcast=false fz=fsalfirst f(z, fz, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end else @.. broadcast=false z=ccache.zprev @@ -159,7 +159,7 @@ function maxeig!(integrator, cache::OrdinaryDiffEqMutableCache) @.. broadcast=false atmp=fz - cache.du₂ else f(fz, z, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false atmp=fz - fsalfirst end Δ = integrator.opts.internalnorm(atmp, t) diff --git a/lib/OrdinaryDiffEqStabilizedRK/Project.toml b/lib/OrdinaryDiffEqStabilizedRK/Project.toml index d8de539f80..b9e75f2f8b 100644 --- a/lib/OrdinaryDiffEqStabilizedRK/Project.toml +++ b/lib/OrdinaryDiffEqStabilizedRK/Project.toml @@ -19,7 +19,7 @@ FastBroadcast = "0.3.5" LinearAlgebra = "<0.0.1, 1" MuladdMacro = "0.2.4" ODEProblemLibrary = "0.1.8" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" Random = "<0.0.1, 1" RecursiveArrayTools = "3.27.0" Reexport = "1.2.2" diff --git a/lib/OrdinaryDiffEqStabilizedRK/src/OrdinaryDiffEqStabilizedRK.jl b/lib/OrdinaryDiffEqStabilizedRK/src/OrdinaryDiffEqStabilizedRK.jl index 3728f78cec..6cddba3664 100644 --- a/lib/OrdinaryDiffEqStabilizedRK/src/OrdinaryDiffEqStabilizedRK.jl +++ b/lib/OrdinaryDiffEqStabilizedRK/src/OrdinaryDiffEqStabilizedRK.jl @@ -12,6 +12,7 @@ import OrdinaryDiffEqCore: alg_order, alg_adaptive_order, calculate_residuals!, constvalue, _unwrap_val, full_cache using FastBroadcast, MuladdMacro, RecursiveArrayTools import StaticArrays: SArray, MVector, SVector, @SVector, StaticArray, MMatrix, SA +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqStabilizedRK/src/rkc_perform_step.jl b/lib/OrdinaryDiffEqStabilizedRK/src/rkc_perform_step.jl index 15188ea209..68149a4e19 100644 --- a/lib/OrdinaryDiffEqStabilizedRK/src/rkc_perform_step.jl +++ b/lib/OrdinaryDiffEqStabilizedRK/src/rkc_perform_step.jl @@ -2,7 +2,7 @@ function initialize!(integrator, cache::ROCK2ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) alg = unwrap_alg(integrator, true) cache.max_stage = (alg.max_stages < 1 || alg.max_stages > 200) ? 200 : alg.max_stages cache.min_stage = (alg.min_stages > cache.max_stage) ? cache.max_stage : alg.min_stages @@ -46,11 +46,11 @@ end δt₁ = dt * fp1[cache.deg_index] δt₂ = dt * fp2[cache.deg_index] uᵢ₋₂ = f(u, p, tᵢ₋₁) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) uᵢ₋₁ = u + δt₁ * uᵢ₋₂ tᵢ₋₁ += δt₁ u = f(uᵢ₋₁, p, tᵢ₋₁) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive tmp = δt₂ * (u - uᵢ₋₂) @@ -66,7 +66,7 @@ end end integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.u = u end @@ -84,7 +84,7 @@ function initialize!(integrator, cache::ROCK2Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::ROCK2Cache, repeat_step = false) @@ -125,7 +125,7 @@ end δt₁ = dt * fp1[ccache.deg_index] δt₂ = dt * fp2[ccache.deg_index] f(k, u, p, tᵢ₋₁) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false uᵢ₋₁=u + δt₁ * k if integrator.opts.adaptive @.. broadcast=false tmp=-δt₂ * k @@ -135,7 +135,7 @@ end c = DiffEqBase.value(sign(δt₁)) * integrator.opts.internalnorm(δt₁, t) tᵢ₋₁ += c f(k, uᵢ₋₁, p, tᵢ₋₁) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive @.. broadcast=false tmp+=δt₂ * k @@ -152,7 +152,7 @@ end end integrator.k[1] = integrator.fsalfirst f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[2] = integrator.fsallast integrator.u = u end @@ -161,7 +161,7 @@ function initialize!(integrator, cache::ROCK4ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) alg = unwrap_alg(integrator, true) cache.max_stage = (alg.max_stages < 1 || alg.max_stages > 152) ? 152 : alg.max_stages cache.min_stage = (alg.min_stages > cache.max_stage) ? cache.max_stage : alg.min_stages @@ -223,7 +223,7 @@ end # 4-stage finishing procedure. # Stage-1 uᵢ₋₁ = f(u, p, tᵢ₋₁) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) uᵢ₋₂ = u + a₃₁ * uᵢ₋₁ uᵢ₋₃ = u + a₄₁ * uᵢ₋₁ u += B₁ * uᵢ₋₁ @@ -235,7 +235,7 @@ end _c₂ = DiffEqBase.value(sign(c₂)) * integrator.opts.internalnorm(c₂, t) tᵢ₋₂ = tᵢ₋₁ + _c₂ uᵢ₋₁ = f(uᵢ₋₁, p, tᵢ₋₂) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) uᵢ₋₂ += a₃₂ * uᵢ₋₁ uᵢ₋₃ += a₄₂ * uᵢ₋₁ u += B₂ * uᵢ₋₁ @@ -246,7 +246,7 @@ end _c₃ = DiffEqBase.value(sign(c₃)) * integrator.opts.internalnorm(c₃, t) tᵢ₋₂ = tᵢ₋₁ + _c₃ uᵢ₋₂ = f(uᵢ₋₂, p, tᵢ₋₂) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) uᵢ₋₃ += a₄₃ * uᵢ₋₂ u += B₃ * uᵢ₋₂ integrator.opts.adaptive && (tmp += B̂₃ * uᵢ₋₂) @@ -256,12 +256,12 @@ end _c₄ = DiffEqBase.value(sign(c₄)) * integrator.opts.internalnorm(c₄, t) tᵢ₋₂ = tᵢ₋₁ + _c₄ uᵢ₋₃ = f(uᵢ₋₃, p, tᵢ₋₂) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u += B₄ * uᵢ₋₃ integrator.opts.adaptive && (tmp += B̂₄ * uᵢ₋₃) uᵢ₋₁ = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) #Error estimate (embedded method of order 3) if integrator.opts.adaptive @@ -289,7 +289,7 @@ function initialize!(integrator, cache::ROCK4Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::ROCK4Cache, repeat_step = false) @@ -349,7 +349,7 @@ end # Stage-1 f(k, u, p, tᵢ₋₁) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false uᵢ₋₂=u + a₃₁ * k @.. broadcast=false uᵢ₋₃=u + a₄₁ * k @.. broadcast=false uᵢ₋₁=u + a₂₁ * k @@ -361,7 +361,7 @@ end _c₂ = DiffEqBase.value(sign(c₂)) * integrator.opts.internalnorm(c₂, t) tᵢ₋₂ = tᵢ₋₁ + _c₂ f(k, uᵢ₋₁, p, tᵢ₋₂) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false uᵢ₋₂+=a₃₂ * k @.. broadcast=false uᵢ₋₃+=a₄₂ * k @.. broadcast=false u+=B₂ * k @@ -372,7 +372,7 @@ end _c₃ = DiffEqBase.value(sign(c₃)) * integrator.opts.internalnorm(c₃, t) tᵢ₋₂ = tᵢ₋₁ + _c₃ f(k, uᵢ₋₂, p, tᵢ₋₂) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false uᵢ₋₃+=a₄₃ * k @.. broadcast=false u+=B₃ * k integrator.opts.adaptive && (@.. broadcast=false tmp+=B̂₃ * k) @@ -382,12 +382,12 @@ end _c₄ = DiffEqBase.value(sign(c₄)) * integrator.opts.internalnorm(c₄, t) tᵢ₋₂ = tᵢ₋₁ + _c₄ f(k, uᵢ₋₃, p, tᵢ₋₂) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u+=B₄ * k integrator.opts.adaptive && (tmp += B̂₄ * k) f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) #Error estimate (embedded method of order 3) if integrator.opts.adaptive @@ -406,7 +406,7 @@ function initialize!(integrator, cache::RKCConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -457,7 +457,7 @@ end μs = μ * w1 / w0 #using u as temporary storage u = f(gprev, p, t + dt * th1) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u = μ * gprev + ν * gprev2 + (1 - μ - ν) * uprev + dt * μs * (u - νs * fsalfirst) th = μ * th1 + ν * th2 + μs * (1 - νs) if (iter < mdeg) @@ -484,7 +484,7 @@ end end integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.u = u end @@ -496,7 +496,7 @@ function initialize!(integrator, cache::RKCCache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::RKCCache, repeat_step = false) @@ -542,7 +542,7 @@ end ν = -b / b2 μs = μ * w1 / w0 f(k, gprev, p, t + dt * th1) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=μ * gprev + ν * gprev2 + (1 - μ - ν) * uprev + dt * μs * (k - νs * fsalfirst) th = μ * th1 + ν * th2 + μs * (1 - νs) @@ -570,7 +570,7 @@ end end integrator.k[1] = integrator.fsalfirst f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[2] = integrator.fsallast integrator.u = u end @@ -579,7 +579,7 @@ function initialize!(integrator, cache::ESERK4ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) integrator.k[1] = integrator.fsalfirst @@ -615,7 +615,7 @@ end Sᵢ = (cache.Bᵢ[start]) * uᵢ₋₁ for st in 1:mdeg k = f(uᵢ₋₁, p, r) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if st % internal_deg == 1 uᵢ = uᵢ₋₁ + α * hᵢ * k @@ -650,7 +650,7 @@ end end integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.u = u end @@ -662,7 +662,7 @@ function initialize!(integrator, cache::ESERK4Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::ESERK4Cache, repeat_step = false) @@ -695,7 +695,7 @@ end @.. broadcast=false Sᵢ=(cache.constantcache.Bᵢ[start]) * uᵢ₋₁ for st in 1:mdeg f(k, uᵢ₋₁, p, r) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if st % internal_deg == 1 @.. broadcast=false uᵢ=uᵢ₋₁ + α * hᵢ * k @@ -731,7 +731,7 @@ end end integrator.k[1] = integrator.fsalfirst f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[2] = integrator.fsallast integrator.u = u end @@ -740,7 +740,7 @@ function initialize!(integrator, cache::ESERK5ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) integrator.k[1] = integrator.fsalfirst @@ -775,7 +775,7 @@ end Sᵢ = (Bᵢ[start]) * uᵢ₋₁ for st in 1:mdeg k = f(uᵢ₋₁, p, r) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if st % internal_deg == 1 uᵢ = uᵢ₋₁ + α * hᵢ * k @@ -810,7 +810,7 @@ end end integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.u = u end @@ -822,7 +822,7 @@ function initialize!(integrator, cache::ESERK5Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::ESERK5Cache, repeat_step = false) @@ -855,7 +855,7 @@ end @.. broadcast=false Sᵢ=(Bᵢ[start]) * uᵢ₋₁ for st in 1:mdeg f(k, uᵢ₋₁, p, r) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if st % internal_deg == 1 @.. broadcast=false uᵢ=uᵢ₋₁ + α * hᵢ * k @@ -891,7 +891,7 @@ end end integrator.k[1] = integrator.fsalfirst f(integrator.fsallast, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.k[2] = integrator.fsallast integrator.u = u end @@ -900,7 +900,7 @@ function initialize!(integrator, cache::SERK2ConstantCache) integrator.kshortsize = 2 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) integrator.k[1] = integrator.fsalfirst @@ -927,14 +927,14 @@ end Sᵢ = Bᵢ[start] * uprev for i in 1:10 k = f(uᵢ₋₁, p, t + (1 + (i - 1) * internal_deg^2) * α * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u = uᵢ₋₁ + α * dt * k Sᵢ = Sᵢ + Bᵢ[start + (i - 1) * internal_deg + 1] * u uᵢ₋₂ = uᵢ₋₁ uᵢ₋₁ = u for j in 2:internal_deg k = f(uᵢ₋₁, p, t + (j^2 + (i - 1) * internal_deg^2) * α * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) u = 2 * uᵢ₋₁ - uᵢ₋₂ + 2 * α * dt * k Sᵢ = Sᵢ + Bᵢ[start + j + (i - 1) * internal_deg] * u if j * i < mdeg @@ -945,7 +945,7 @@ end end u = Sᵢ k = f(u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive tmp = u - uprev - dt * k @@ -966,7 +966,7 @@ function initialize!(integrator, cache::SERK2Cache) integrator.k[1] = integrator.fsalfirst integrator.k[2] = integrator.fsallast integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::SERK2Cache, repeat_step = false) @@ -991,14 +991,14 @@ end @.. broadcast=false Sᵢ=Bᵢ[start] * uprev for i in 1:10 f(k, uᵢ₋₁, p, t + (1 + (i - 1) * internal_deg^2) * α * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=uᵢ₋₁ + α * dt * k @.. broadcast=false Sᵢ=Sᵢ + Bᵢ[start + (i - 1) * internal_deg + 1] * u @.. broadcast=false uᵢ₋₂=uᵢ₋₁ @.. broadcast=false uᵢ₋₁=u for j in 2:internal_deg f(k, uᵢ₋₂, p, t + (j^2 + (i - 1) * internal_deg^2) * α * dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false u=2 * uᵢ₋₁ - uᵢ₋₂ + 2 * α * dt * k @.. broadcast=false Sᵢ=Sᵢ + Bᵢ[start + j + (i - 1) * internal_deg] * u if j < mdeg @@ -1009,7 +1009,7 @@ end end @.. broadcast=false u=Sᵢ f(k, u, p, t + dt) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) if integrator.opts.adaptive @.. broadcast=false tmp=u - uprev - dt * k diff --git a/lib/OrdinaryDiffEqStabilizedRK/src/rkc_utils.jl b/lib/OrdinaryDiffEqStabilizedRK/src/rkc_utils.jl index 91b89ac73a..9fda5070e5 100644 --- a/lib/OrdinaryDiffEqStabilizedRK/src/rkc_utils.jl +++ b/lib/OrdinaryDiffEqStabilizedRK/src/rkc_utils.jl @@ -15,7 +15,7 @@ function maxeig!(integrator, cache::OrdinaryDiffEqConstantCache) else fz = fsalfirst z = f(fz, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end else z = cache.zprev @@ -47,7 +47,7 @@ function maxeig!(integrator, cache::OrdinaryDiffEqConstantCache) integrator.eigen_est = 0 for iter in 1:maxiter fz = f(z, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) tmp = fz - fsalfirst Δ = integrator.opts.internalnorm(tmp, t) eig_prev = integrator.eigen_est @@ -104,7 +104,7 @@ function maxeig!(integrator, cache::OrdinaryDiffEqMutableCache) else @.. broadcast=false fz=fsalfirst f(z, fz, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end else @.. broadcast=false z=ccache.zprev @@ -136,7 +136,7 @@ function maxeig!(integrator, cache::OrdinaryDiffEqMutableCache) integrator.eigen_est = 0 for iter in 1:maxiter f(fz, z, p, t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) @.. broadcast=false atmp=fz - fsalfirst Δ = integrator.opts.internalnorm(atmp, t) eig_prev = integrator.eigen_est diff --git a/lib/OrdinaryDiffEqSymplecticRK/Project.toml b/lib/OrdinaryDiffEqSymplecticRK/Project.toml index 79a947a99f..5c04b31fe7 100644 --- a/lib/OrdinaryDiffEqSymplecticRK/Project.toml +++ b/lib/OrdinaryDiffEqSymplecticRK/Project.toml @@ -18,7 +18,7 @@ DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" LinearAlgebra = "<0.0.1, 1" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" OrdinaryDiffEqRKN = "<0.0.1, 1" OrdinaryDiffEqTsit5 = "<0.0.1, 1" Polyester = "0.7.16" diff --git a/lib/OrdinaryDiffEqSymplecticRK/src/OrdinaryDiffEqSymplecticRK.jl b/lib/OrdinaryDiffEqSymplecticRK/src/OrdinaryDiffEqSymplecticRK.jl index 864460c3d6..e395152161 100644 --- a/lib/OrdinaryDiffEqSymplecticRK/src/OrdinaryDiffEqSymplecticRK.jl +++ b/lib/OrdinaryDiffEqSymplecticRK/src/OrdinaryDiffEqSymplecticRK.jl @@ -13,6 +13,7 @@ import OrdinaryDiffEqCore: alg_order, calculate_residuals!, explicit_rk_docstring, trivial_limiter!, _ode_interpolant!, _ode_addsteps! using FastBroadcast, Polyester, MuladdMacro, RecursiveArrayTools +import OrdinaryDiffEqCore using Reexport @reexport using DiffEqBase diff --git a/lib/OrdinaryDiffEqSymplecticRK/src/symplectic_perform_step.jl b/lib/OrdinaryDiffEqSymplecticRK/src/symplectic_perform_step.jl index 413f1882a2..c03b2a277e 100644 --- a/lib/OrdinaryDiffEqSymplecticRK/src/symplectic_perform_step.jl +++ b/lib/OrdinaryDiffEqSymplecticRK/src/symplectic_perform_step.jl @@ -12,7 +12,7 @@ function initialize!(integrator, cache::SymplecticEulerConstantCache) @muladd du = duprev + integrator.dt * kdu ku = integrator.f.f2(du, uprev, integrator.p, integrator.t) integrator.stats.nf2 += 1 - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) integrator.fsalfirst = ArrayPartition((kdu, kuprev)) integrator.fsallast = ArrayPartition((zero(kdu), ku)) end @@ -30,7 +30,7 @@ end ku = f.f2(du, u, p, t) integrator.stats.nf2 += 1 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.u = ArrayPartition((du, u)) integrator.fsallast = ArrayPartition((kdu, ku)) @@ -56,7 +56,7 @@ function initialize!(integrator, cache::SymplecticEulerCache) integrator.f.f2(kuprev, duprev, uprev, integrator.p, integrator.t) @muladd @.. broadcast=false du=duprev + integrator.dt * kdu integrator.f.f2(ku, du, uprev, integrator.p, integrator.t) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 2 end @@ -70,7 +70,7 @@ end # Now actually compute the step # Do it at the end for interpolations! integrator.stats.nf2 += 1 - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) f.f1(kdu, duprev, u, p, t) @.. broadcast=false du=duprev + dt * kdu f.f2(ku, du, u, p, t) @@ -155,7 +155,7 @@ function initialize!(integrator, integrator.f.f1(integrator.k[2].x[1], duprev, uprev, integrator.p, integrator.t) verify_f2(integrator.f.f2, integrator.k[2].x[2], duprev, uprev, integrator.p, integrator.t, integrator, cache) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 end @@ -170,7 +170,7 @@ function initialize!(integrator, kdu = integrator.f.f1(duprev, uprev, integrator.p, integrator.t) ku = verify_f2(integrator.f.f2, duprev, uprev, integrator.p, integrator.t, integrator, cache) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) integrator.stats.nf2 += 1 integrator.fsallast = ArrayPartition((kdu, ku)) integrator.k[2] = integrator.fsallast @@ -191,7 +191,7 @@ end # v(t+Δt) = v(t) + 1/2*(a(t)+a(t+Δt))*Δt du = duprev + dt * (half * ku + half * kdu) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) store_symp_state!(integrator, cache, du, u, kdu, du) end @@ -206,7 +206,7 @@ end half = cache.half @.. broadcast=false u=uprev + dt * duprev + dtsq * (half * ku) f.f1(kdu, duprev, u, p, t + dt) - integrator.stats.nf += 2 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 2) # v(t+Δt) = v(t) + 1/2*(a(t)+a(t+Δt))*Δt @.. broadcast=false du=duprev + dt * (half * ku + half * kdu) @@ -234,7 +234,7 @@ end kdu = f.f1(du, u, p, tnew) ku = f.f2(du, u, p, tnew) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) integrator.stats.nf2 += 2 store_symp_state!(integrator, cache, du, u, kdu, ku) end @@ -260,7 +260,7 @@ end f.f1(kdu, du, u, p, tnew) f.f2(ku, du, u, p, tnew) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) integrator.stats.nf2 += 2 store_symp_state!(integrator, cache, kdu, ku) end @@ -294,7 +294,7 @@ end kdu = f.f1(du, u, p, tnew) ku = f.f2(du, u, p, tnew) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 3 store_symp_state!(integrator, cache, du, u, kdu, ku) end @@ -328,7 +328,7 @@ end f.f1(kdu, du, u, p, tnew) f.f2(ku, du, u, p, tnew) - integrator.stats.nf += 4 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 4) integrator.stats.nf2 += 3 store_symp_state!(integrator, cache, kdu, ku) end @@ -370,7 +370,7 @@ end kdu = f.f1(du, u, p, tnew) ku = f.f2(du, u, p, tnew) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.stats.nf2 += 4 store_symp_state!(integrator, cache, du, u, kdu, ku) end @@ -412,7 +412,7 @@ end f.f1(kdu, du, u, p, tnew) f.f2(ku, du, u, p, tnew) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.stats.nf2 += 4 store_symp_state!(integrator, cache, kdu, ku) end @@ -462,11 +462,11 @@ end if alg isa McAte42 du = du + dt * a5 * kdu kdu = f.f1(du, u, p, tnew) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end ku = f.f2(du, u, p, tnew) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.stats.nf2 += 5 store_symp_state!(integrator, cache, du, u, kdu, ku) end @@ -516,11 +516,11 @@ end if alg isa McAte42 @.. broadcast=false du=du + dt * a5 * kdu f.f1(kdu, du, u, p, tnew) - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end f.f2(ku, du, u, p, tnew) - integrator.stats.nf += 5 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 5) integrator.stats.nf2 += 5 store_symp_state!(integrator, cache, kdu, ku) end @@ -577,7 +577,7 @@ end kdu = f.f1(du, u, p, tnew) ku = f.f2(du, u, p, tnew) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) integrator.stats.nf2 += 6 store_symp_state!(integrator, cache, du, u, kdu, ku) end @@ -634,7 +634,7 @@ end f.f1(kdu, du, u, p, tnew) f.f2(ku, du, u, p, tnew) - integrator.stats.nf += 7 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 7) integrator.stats.nf2 += 6 store_symp_state!(integrator, cache, kdu, ku) end @@ -704,7 +704,7 @@ end # @.. broadcast=false du = du + dt*a8*kdu ku = f.f2(du, u, p, tnew) - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) integrator.stats.nf2 += 8 store_symp_state!(integrator, cache, du, u, kdu, ku) end @@ -774,7 +774,7 @@ end # @.. broadcast=false du = du + dt*a8*kdu f.f2(ku, du, u, p, tnew) - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) integrator.stats.nf2 += 8 store_symp_state!(integrator, cache, kdu, ku) end @@ -858,7 +858,7 @@ end # @.. broadcast=false du = du + dt*a10*kdu ku = f.f2(du, u, p, tnew) - integrator.stats.nf += 10 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 10) integrator.stats.nf2 += 10 store_symp_state!(integrator, cache, du, u, kdu, ku) end @@ -942,7 +942,7 @@ end # @.. broadcast=false du = du + dt*a10*kdu f.f2(ku, du, u, p, tnew) - integrator.stats.nf += 10 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 10) integrator.stats.nf2 += 10 store_symp_state!(integrator, cache, kdu, ku) end @@ -1068,7 +1068,7 @@ end # @.. broadcast=false du = du + dt*a16*kdu ku = f.f2(du, u, p, tnew) - integrator.stats.nf += 16 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 16) integrator.stats.nf2 += 16 store_symp_state!(integrator, cache, du, u, kdu, ku) end @@ -1195,7 +1195,7 @@ end # @.. broadcast=false du = du + dt*a16*kdu f.f2(ku, du, u, p, tnew) - integrator.stats.nf += 16 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 16) integrator.stats.nf2 += 16 store_symp_state!(integrator, cache, kdu, ku) end @@ -1336,7 +1336,7 @@ end # @.. broadcast=false du = du + dt*a18*kdu ku = f.f2(du, u, p, tnew) - integrator.stats.nf += 18 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 18) integrator.stats.nf2 += 18 store_symp_state!(integrator, cache, du, u, kdu, ku) end @@ -1477,7 +1477,7 @@ end # @.. broadcast=false du = du + dt*a18*kdu f.f2(ku, du, u, p, tnew) - integrator.stats.nf += 18 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 18) integrator.stats.nf2 += 18 store_symp_state!(integrator, cache, kdu, ku) end @@ -1748,7 +1748,7 @@ end # @.. broadcast=false du = du + dt*a30*kdu ku = f.f2(du, u, p, tnew) - integrator.stats.nf += 36 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 36) integrator.stats.nf2 += 36 store_symp_state!(integrator, cache, du, u, kdu, ku) end @@ -2019,7 +2019,7 @@ end # @.. broadcast=false du = du + dt*a30*kdu f.f2(ku, du, u, p, tnew) - integrator.stats.nf += 36 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 36) integrator.stats.nf2 += 36 store_symp_state!(integrator, cache, kdu, ku) end diff --git a/lib/OrdinaryDiffEqTsit5/Project.toml b/lib/OrdinaryDiffEqTsit5/Project.toml index 7f03587a92..bb6e57e416 100644 --- a/lib/OrdinaryDiffEqTsit5/Project.toml +++ b/lib/OrdinaryDiffEqTsit5/Project.toml @@ -22,7 +22,7 @@ DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" LinearAlgebra = "<0.0.1, 1" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" PrecompileTools = "1.2.1" Preferences = "1.4.3" Random = "<0.0.1, 1" diff --git a/lib/OrdinaryDiffEqTsit5/src/tsit_perform_step.jl b/lib/OrdinaryDiffEqTsit5/src/tsit_perform_step.jl index a17c23a618..dd702ce5e9 100644 --- a/lib/OrdinaryDiffEqTsit5/src/tsit_perform_step.jl +++ b/lib/OrdinaryDiffEqTsit5/src/tsit_perform_step.jl @@ -109,7 +109,7 @@ function initialize!(integrator, cache::Tsit5ConstantCache) integrator.kshortsize = 7 integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) # Avoid undefined entries if k is an array of arrays integrator.fsallast = zero(integrator.fsalfirst) @@ -136,7 +136,7 @@ end u = uprev + dt * (a71 * k1 + a72 * k2 + a73 * k3 + a74 * k4 + a75 * k5 + a76 * k6) integrator.fsallast = f(u, p, t + dt) k7 = integrator.fsallast - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) if integrator.alg isa CompositeAlgorithm g7 = u # Hairer II, page 22 modified to use the Inf norm @@ -175,7 +175,7 @@ function initialize!(integrator, cache::Tsit5Cache) integrator.k[6] = cache.k6 integrator.k[7] = cache.k7 integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) return nothing end @@ -210,7 +210,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k7, u, p, t + dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) if integrator.alg isa CompositeAlgorithm g7 = u g6 = tmp diff --git a/lib/OrdinaryDiffEqVerner/Project.toml b/lib/OrdinaryDiffEqVerner/Project.toml index 4055334d39..4dc9e39f19 100644 --- a/lib/OrdinaryDiffEqVerner/Project.toml +++ b/lib/OrdinaryDiffEqVerner/Project.toml @@ -23,7 +23,7 @@ DiffEqDevTools = "2.44.4" FastBroadcast = "0.3.5" LinearAlgebra = "<0.0.1, 1" MuladdMacro = "0.2.4" -OrdinaryDiffEqCore = "<0.0.1, 1" +OrdinaryDiffEqCore = "1.1" Polyester = "0.7.16" PrecompileTools = "1.2.1" Preferences = "1.4.3" diff --git a/lib/OrdinaryDiffEqVerner/src/verner_rk_perform_step.jl b/lib/OrdinaryDiffEqVerner/src/verner_rk_perform_step.jl index 75704ce69e..73e3fa9718 100644 --- a/lib/OrdinaryDiffEqVerner/src/verner_rk_perform_step.jl +++ b/lib/OrdinaryDiffEqVerner/src/verner_rk_perform_step.jl @@ -1,6 +1,6 @@ function initialize!(integrator, cache::Vern6ConstantCache) integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) alg = unwrap_alg(integrator, false) cache.lazy ? (integrator.kshortsize = 9) : (integrator.kshortsize = 12) integrator.k = typeof(integrator.k)(undef, integrator.kshortsize) @@ -37,7 +37,7 @@ end u = uprev + dt * (a91 * k1 + a94 * k4 + a95 * k5 + a96 * k6 + a97 * k7 + a98 * k8) integrator.fsallast = f(u, p, t + dt) k9 = integrator.fsallast - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) if integrator.alg isa CompositeAlgorithm g9 = u integrator.eigen_est = integrator.opts.internalnorm( @@ -85,7 +85,7 @@ end a1211 * k[11]), p, t + c12 * dt) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) end integrator.u = u @@ -115,7 +115,7 @@ function initialize!(integrator, cache::Vern6Cache) end integrator.f(integrator.fsalfirst, integrator.uprev, integrator.p, integrator.t) # Pre-start fsal - integrator.stats.nf += 1 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) end @muladd function perform_step!(integrator, cache::Vern6Cache, repeat_step = false) @@ -158,7 +158,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k9, u, p, t + dt) - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) if integrator.alg isa CompositeAlgorithm g9 = u g8 = tmp @@ -202,7 +202,7 @@ end a1206 * k[6] + a1207 * k[7] + a1208 * k[8] + a1209 * k[9] + a1210 * k[10] + a1211 * k[11]) - integrator.stats.nf += 3 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) f(k[12], tmp, p, t + c12 * dt) end return nothing @@ -245,7 +245,7 @@ end dt * (a101 * k1 + a103 * k3 + a104 * k4 + a105 * k5 + a106 * k6 + a107 * k7) k9 = f(g9, p, t + dt) k10 = f(g10, p, t + dt) - integrator.stats.nf += 10 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 10) u = uprev + dt * (b1 * k1 + b4 * k4 + b5 * k5 + b6 * k6 + b7 * k7 + b8 * k8 + b9 * k9) if integrator.alg isa CompositeAlgorithm integrator.eigen_est = integrator.opts.internalnorm( @@ -316,7 +316,7 @@ end a1612 * k[12] + a1613 * k[13]), p, t + c16 * dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) end end @@ -406,7 +406,7 @@ end b9 * k9) stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) - integrator.stats.nf += 10 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 10) if integrator.alg isa CompositeAlgorithm g10 = u g9 = tmp @@ -474,7 +474,7 @@ end a1611 * k[11] + a1612 * k[12] + a1613 * k[13]) f(k[16], tmp, p, t + c16 * dt) - integrator.stats.nf += 6 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 6) end return nothing end @@ -534,7 +534,7 @@ end a1309 * k9 + a1310 * k10) k12 = f(g12, p, t + dt) k13 = f(g13, p, t + dt) - integrator.stats.nf += 13 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 13) u = uprev + dt * (b1 * k1 + b6 * k6 + b7 * k7 + b8 * k8 + b9 * k9 + b10 * k10 + b11 * k11 + b12 * k12) @@ -625,7 +625,7 @@ end a2114 * k[14] + a2115 * k[15] + a2116 * k[16] + a2117 * k[17]), p, t + c21 * dt) - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) end end @@ -726,7 +726,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k13, u, p, t + dt) - integrator.stats.nf += 13 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 13) if integrator.alg isa CompositeAlgorithm g13 = u g12 = tmp @@ -831,7 +831,7 @@ end a2112 * k[12] + a2114 * k[14] + a2115 * k[15] + a2116 * k[16] + a2117 * k[17]) - integrator.stats.nf += 8 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 8) f(k[21], tmp, p, t + c21 * dt) end return nothing @@ -901,7 +901,7 @@ end a1611 * k11 + a1612 * k12 + a1613 * k13) k15 = f(g15, p, t + dt) k16 = f(g16, p, t + dt) - integrator.stats.nf += 16 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 16) u = uprev + dt * (b1 * k1 + b8 * k8 + b9 * k9 + b10 * k10 + b11 * k11 + b12 * k12 + b13 * k13 + b14 * k14 + b15 * k15) @@ -1011,7 +1011,7 @@ end a2620 * k[14] + a2621 * k[15]), p, t + c26 * dt) - integrator.stats.nf += 10 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 10) end end @@ -1131,7 +1131,7 @@ end stage_limiter!(u, integrator, p, t + dt) step_limiter!(u, integrator, p, t + dt) f(k16, u, p, t + dt) - integrator.stats.nf += 16 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 16) if integrator.alg isa CompositeAlgorithm g16 = u g15 = tmp @@ -1261,7 +1261,7 @@ end a2618 * k[12] + a2619 * k[13] + a2620 * k[14] + a2621 * k[15]) - integrator.stats.nf += 10 + OrdinaryDiffEqCore.increment_nf!(integrator.stats, 10) f(k[20], tmp, p, t + c26 * dt) end return nothing