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

Specify Callback Argument Type in init Functions in ODE solvers (2N, 3Sstar, PairedExplicitRK, SSP) #2026

Merged
6 changes: 2 additions & 4 deletions src/time_integration/methods_2N.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function Base.getproperty(integrator::SimpleIntegrator2N, field::Symbol)
end

function init(ode::ODEProblem, alg::SimpleAlgorithm2N;
dt, callback = nothing, kwargs...)
dt, callback::Union{CallbackSet, Nothing} = nothing, kwargs...)
u = copy(ode.u0)
du = similar(u)
u_tmp = similar(u)
Expand All @@ -119,13 +119,11 @@ function init(ode::ODEProblem, alg::SimpleAlgorithm2N;
# initialize callbacks
if callback isa CallbackSet
foreach(callback.continuous_callbacks) do cb
error("unsupported")
throw(ArgumentError("Continuous callbacks are unsupported with the 2N storage time integration methods."))
end
foreach(callback.discrete_callbacks) do cb
cb.initialize(cb, integrator.u, integrator.t, integrator)
end
elseif !isnothing(callback)
error("unsupported")
end

return integrator
Expand Down
6 changes: 2 additions & 4 deletions src/time_integration/methods_3Sstar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function Base.getproperty(integrator::SimpleIntegrator3Sstar, field::Symbol)
end

function init(ode::ODEProblem, alg::SimpleAlgorithm3Sstar;
dt, callback = nothing, kwargs...)
dt, callback::Union{CallbackSet, Nothing} = nothing, kwargs...)
u = copy(ode.u0)
du = similar(u)
u_tmp1 = similar(u)
Expand All @@ -189,13 +189,11 @@ function init(ode::ODEProblem, alg::SimpleAlgorithm3Sstar;
# initialize callbacks
if callback isa CallbackSet
foreach(callback.continuous_callbacks) do cb
error("unsupported")
throw(ArgumentError("Continuous callbacks are unsupported with the 3 star time integration methods."))
end
foreach(callback.discrete_callbacks) do cb
cb.initialize(cb, integrator.u, integrator.t, integrator)
end
elseif !isnothing(callback)
error("unsupported")
end

return integrator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function Base.getproperty(integrator::PairedExplicitRK, field::Symbol)
end

function init(ode::ODEProblem, alg::PairedExplicitRK2;
dt, callback = nothing, kwargs...)
dt, callback::Union{CallbackSet, Nothing} = nothing, kwargs...)
u0 = copy(ode.u0)
du = zero(u0)
u_tmp = zero(u0)
Expand All @@ -286,13 +286,11 @@ function init(ode::ODEProblem, alg::PairedExplicitRK2;
# initialize callbacks
if callback isa CallbackSet
for cb in callback.continuous_callbacks
error("unsupported")
throw(ArgumentError("Continuous callbacks are unsupported with paired explicit Runge-Kutta methods."))
end
for cb in callback.discrete_callbacks
cb.initialize(cb, integrator.u, integrator.t, integrator)
end
elseif !isnothing(callback)
error("unsupported")
end

return integrator
Expand Down
Loading