Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Aug 31, 2024
1 parent f0b8470 commit bbfdae2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/src/implicit/PDIRK.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ these matrices can be factorized and the underlying steps can be computed in par
which is why these are the parallel DIRK methods.

!!! warning "Experimental"

`OrdinaryDiffEqPDIRK` is experimental,
as there are no parallel DIRK tableaus that achieve good performance in the literature.

Expand Down
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqCore/src/caches/basic_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mutable struct CompositeCache{T, F} <: OrdinaryDiffEqCache
current::Int
end

function get_fsalfirstlast(cache::CompositeCache, u)
function get_fsalfirstlast(cache::CompositeCache, u)
_x = get_fsalfirstlast(cache.caches[1], u)
if first(_x) !== nothing
return _x
Expand Down
4 changes: 2 additions & 2 deletions lib/OrdinaryDiffEqCore/src/interp_func.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function SciMLBase.strip_interpolation(id::InterpolationData)
end

function strip_cache(cache)
if hasfield(typeof(cache), :jac_config) || hasfield(typeof(cache), :grad_config) || hasfield(typeof(cache), :nlsolver)
if hasfield(typeof(cache), :jac_config) || hasfield(typeof(cache), :grad_config) ||
hasfield(typeof(cache), :nlsolver)
fieldnums = length(fieldnames(typeof(cache)))
noth_list = fill(nothing, fieldnums)
cache_type_name = Base.typename(typeof(cache)).wrapper
Expand All @@ -84,4 +85,3 @@ function strip_cache(cache)
cache
end
end

4 changes: 3 additions & 1 deletion lib/OrdinaryDiffEqRosenbrock/src/rosenbrock_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ abstract type RosenbrockConstantCache <: OrdinaryDiffEqConstantCache end

# Fake values since non-FSAL
get_fsalfirstlast(cache::RosenbrockMutableCache, u) = (nothing, nothing)
get_fsalfirstlast(cache::GenericRosenbrockMutableCache, u) = (cache.fsalfirst, cache.fsallast)
function get_fsalfirstlast(cache::GenericRosenbrockMutableCache, u)
(cache.fsalfirst, cache.fsallast)
end

################################################################################

Expand Down
18 changes: 11 additions & 7 deletions test/interface/get_du.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ function lorenz!(du, u, p, t)
end
u0 = [1.0; 0.0; 0.0]
tspan = (0.0, 3.0)
condition(u,t,integrator) = t == 0.2
condition(u, t, integrator) = t == 0.2
cache = zeros(3)
affect!(integrator) = cache .= get_du(integrator)
dusave = DiscreteCallback(condition, affect!)
affect2!(integrator) = get_du!(cache, integrator)
dusave_inplace = DiscreteCallback(condition, affect2!)

prob = ODEProblem(lorenz!, u0, tspan)
sol = solve(prob, Tsit5(), tstops = [0.2], callback = dusave, abstol=1e-12, reltol=1e-12)
sol = solve(
prob, Tsit5(), tstops = [0.2], callback = dusave, abstol = 1e-12, reltol = 1e-12)
res = copy(cache)

for alg in [Vern6(), Vern7(), Vern8(), Vern9(), Rodas4(), Rodas4P(), Rodas5(), Rodas5P(), TRBDF2(), KenCarp4(), FBDF(), QNDF()]
sol = solve(prob, alg, tstops = [0.2], callback = dusave, abstol=1e-12, reltol=1e-12)
@test res cache rtol=1e-5
for alg in [Vern6(), Vern7(), Vern8(), Vern9(), Rodas4(), Rodas4P(),
Rodas5(), Rodas5P(), TRBDF2(), KenCarp4(), FBDF(), QNDF()]
sol = solve(
prob, alg, tstops = [0.2], callback = dusave, abstol = 1e-12, reltol = 1e-12)
@test rescache rtol=1e-5

sol = solve(prob, alg, tstops = [0.2], callback = dusave_inplace, abstol=1e-12, reltol=1e-12)
@test res cache rtol=1e-5
sol = solve(prob, alg, tstops = [0.2], callback = dusave_inplace,
abstol = 1e-12, reltol = 1e-12)
@test rescache rtol=1e-5
end

0 comments on commit bbfdae2

Please sign in to comment.