Skip to content

Commit a983dbe

Browse files
committed
Add unstable_check for custom SSP method
1 parent 214cb71 commit a983dbe

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/time_integration/methods_SSP.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ function solve!(integrator::SimpleIntegratorSSP)
220220
end
221221
end
222222

223+
unstable_check(integrator.dt, integrator.u, integrator)
224+
223225
# respect maximum number of iterations
224226
if integrator.iter >= integrator.opts.maxiters && !integrator.finalstep
225227
@warn "Interrupted. Larger maxiters is needed."
@@ -258,6 +260,14 @@ function get_proposed_dt(integrator::SimpleIntegratorSSP)
258260
return ifelse(integrator.opts.adaptive, integrator.dt, integrator.dtcache)
259261
end
260262

263+
function unstable_check(dt, u_ode, integrator::SimpleIntegratorSSP)
264+
if !isfinite(dt) || isnan(dt) || !all(isfinite.(u_ode)) || any(isnan.(u_ode))
265+
@warn "Instability detected. Aborting"
266+
terminate!(integrator)
267+
end
268+
return nothing
269+
end
270+
261271
# stop the time integration
262272
function terminate!(integrator::SimpleIntegratorSSP)
263273
integrator.finalstep = true

0 commit comments

Comments
 (0)