Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark SubArrays as invalid outputs for IDAIntegrator(out, t) #434

Merged
merged 6 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/common_interface/integrator_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ function (integrator::IDAIntegrator)(out,
integrator.flag = @checkflag IDAGetDky(integrator.mem, t, Cint(T), vec(out))
return idxs === nothing ? out : @view out[idxs]
end
function (integrator::IDAIntegrator)(out::SubArray,
t::Number,
deriv::Type{Val{T}} = Val{0};
idxs = nothing) where {T}
throw(ArgumentError("Views are not supported with IDA!"))
end


### Error check (retcode)

Expand Down
7 changes: 7 additions & 0 deletions test/common_interface/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,10 @@ cb = ContinuousCallback(bvcond, bvaffect!)
prob = DAEProblem(fbv, du₀, u₀, tspan, p, differential_vars = differential_vars)
sol = solve(prob, IDA(), callback = cb, tstops = [50.0], abstol = 1e-12, reltol = 1e-12)
@test sol.t[end] ≈ 100.0

# Test that SubArrays are not allowed as outputs to the integrator
u_out = similar(u₀)
cb = DiscreteCallback(Returns(true), integ -> integ(@view(u_out), integ.t))
ChrisRackauckas marked this conversation as resolved.
Show resolved Hide resolved
prob = DAEProblem(fbv, du₀, u₀, tspan, p, differential_vars = differential_vars)
@test_throws ArgumentError solve(prob, IDA(), callback = cb)

Loading