Skip to content

Commit 42b98fc

Browse files
Refactor & Generalize: System for opting alg into linear interpolation
We haven't really needed this much before since most methods had a special interpolation or default Hermite, so we had a bespoke way of opting just a few algorithms out (FunctionMap and the DAE solvers for now). But there are cases which need to be able to opt into saying they only want a linear interpolation as the Hermite would take extra function evaluations or would not satisfy the right properties, and thus for these equations this gives them an overload they can use to opt out on a per-algorithm basis via a trait function.
1 parent 4b29bab commit 42b98fc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/OrdinaryDiffEqCore/src/alg_utils.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,6 @@ function Base.show(io::IO, ::MIME"text/plain", alg::OrdinaryDiffEqAlgorithm)
444444
end
445445
print(io, ")")
446446
end
447+
448+
# Defaults in the current system: currently opt out DAEAlgorithms until complete
449+
default_linear_interpolation(alg, prob) = alg isa DAEAlgorithm || prob isa DiscreteProblem

lib/OrdinaryDiffEqCore/src/solve.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ function DiffEqBase.__init(
2626
saveat isa Number || prob.tspan[1] in saveat,
2727
save_end = nothing,
2828
callback = nothing,
29-
dense = save_everystep &&
30-
!(alg isa DAEAlgorithm) && !(prob isa DiscreteProblem) &&
31-
isempty(saveat),
29+
dense = save_everystep && isempty(saveat) && !default_linear_interpolation(prob, alg),
3230
calck = (callback !== nothing && callback !== CallbackSet()) ||
3331
(dense) || !isempty(saveat), # and no dense output
3432
dt = isdiscretealg(alg) && isempty(tstops) ?

0 commit comments

Comments
 (0)