@@ -2257,9 +2257,13 @@ function initialize!(integrator, cache::GaussLegendreConstantCache)
22572257
22582258 # adaptive Richardson controller requires num_stages >= 2
22592259 if integrator. opts. adaptive && integrator. alg. num_stages < 2
2260- throw (ArgumentError (" GaussLegendre with num_stages = $(integrator. alg. num_stages) " *
2261- " does not support adaptive stepping (Richardson controller " *
2262- " requires num_stages ≥ 2). Use num_stages ≥ 2 or pass adaptive = false." ))
2260+ throw (
2261+ ArgumentError (
2262+ " GaussLegendre with num_stages = $(integrator. alg. num_stages) " *
2263+ " does not support adaptive stepping (Richardson controller " *
2264+ " requires num_stages ≥ 2). Use num_stages ≥ 2 or pass adaptive = false."
2265+ )
2266+ )
22632267 end
22642268 return nothing
22652269end
@@ -2276,9 +2280,13 @@ function initialize!(integrator, cache::GaussLegendreCache)
22762280 OrdinaryDiffEqCore. increment_nf! (integrator. stats, 1 )
22772281 if integrator. opts. adaptive
22782282 if cache. num_stages < 2
2279- throw (ArgumentError (" GaussLegendre with num_stages = $(cache. num_stages) " *
2280- " does not support adaptive stepping (Richardson controller " *
2281- " requires num_stages ≥ 2). Use num_stages ≥ 2 or pass adaptive = false." ))
2283+ throw (
2284+ ArgumentError (
2285+ " GaussLegendre with num_stages = $(cache. num_stages) " *
2286+ " does not support adaptive stepping (Richardson controller " *
2287+ " requires num_stages ≥ 2). Use num_stages ≥ 2 or pass adaptive = false."
2288+ )
2289+ )
22822290 end
22832291 (; abstol, reltol) = integrator. opts
22842292 if reltol isa Number
@@ -2346,10 +2354,13 @@ end
23462354 end
23472355
23482356 ndwprev = ndw
2349- ndw = sum (internalnorm (
2350- calculate_residuals (dw[i], uprev_local, uprev_local, atol, rtol, internalnorm, t_local),
2351- t_local)
2352- for i in 1 : num_stages)
2357+ ndw = sum (
2358+ internalnorm (
2359+ calculate_residuals (dw[i], uprev_local, uprev_local, atol, rtol, internalnorm, t_local),
2360+ t_local
2361+ )
2362+ for i in 1 : num_stages
2363+ )
23532364
23542365 if iter > 1
23552366 θ = ndw / ndwprev
@@ -2390,8 +2401,10 @@ end
23902401 return (u_out, z, true )
23912402end
23922403
2393- @muladd function perform_step! (integrator, cache:: GaussLegendreConstantCache ,
2394- repeat_step = false )
2404+ @muladd function perform_step! (
2405+ integrator, cache:: GaussLegendreConstantCache ,
2406+ repeat_step = false
2407+ )
23952408 (; t, dt, uprev, f, p) = integrator
23962409 (; num_stages) = cache
23972410 (; internalnorm, abstol, reltol, adaptive) = integrator. opts
@@ -2405,7 +2418,8 @@ end
24052418 if adaptive && num_stages >= 2
24062419 # Richardson step-doubling: one full step at dt, two successive half-steps.
24072420 u_H, z_full, ok1 = _gausslegendre_substep_constant (
2408- integrator, cache, alg, uprev, t, dt, J, atol, rtol)
2421+ integrator, cache, alg, uprev, t, dt, J, atol, rtol
2422+ )
24092423 if ! ok1
24102424 integrator. force_stepfail = true
24112425 integrator. stats. nnonlinconvfail += 1
@@ -2414,15 +2428,17 @@ end
24142428
24152429 half_dt = dt / 2
24162430 u_h1, _, ok2 = _gausslegendre_substep_constant (
2417- integrator, cache, alg, uprev, t, half_dt, J, atol, rtol)
2431+ integrator, cache, alg, uprev, t, half_dt, J, atol, rtol
2432+ )
24182433 if ! ok2
24192434 integrator. force_stepfail = true
24202435 integrator. stats. nnonlinconvfail += 1
24212436 return
24222437 end
24232438
24242439 u_h, _, ok3 = _gausslegendre_substep_constant (
2425- integrator, cache, alg, u_h1, t + half_dt, half_dt, J, atol, rtol)
2440+ integrator, cache, alg, u_h1, t + half_dt, half_dt, J, atol, rtol
2441+ )
24262442 if ! ok3
24272443 integrator. force_stepfail = true
24282444 integrator. stats. nnonlinconvfail += 1
@@ -2432,13 +2448,15 @@ end
24322448 p_order = 2 * num_stages
24332449 utilde = @. . (u_h - u_H) / (2 ^ p_order - 1 )
24342450 integrator. EEst = internalnorm (
2435- calculate_residuals (utilde, uprev, u_h, atol, rtol, internalnorm, t), t)
2451+ calculate_residuals (utilde, uprev, u_h, atol, rtol, internalnorm, t), t
2452+ )
24362453
24372454 u = u_h
24382455 z_for_fsal = z_full
24392456 else
24402457 u_out, z_out, ok = _gausslegendre_substep_constant (
2441- integrator, cache, alg, uprev, t, dt, J, atol, rtol)
2458+ integrator, cache, alg, uprev, t, dt, J, atol, rtol
2459+ )
24422460 if ! ok
24432461 integrator. force_stepfail = true
24442462 integrator. stats. nnonlinconvfail += 1
@@ -2471,8 +2489,10 @@ end
24712489 u_dest, uprev_local, t_local, dt_local, J_local,
24722490 cache:: GaussLegendreCache , integrator, alg
24732491 )
2474- (; tab, κ, z, dw, ks, W, ubuff, tmp, atmp, linsolve,
2475- rtol, atol, num_stages) = cache
2492+ (;
2493+ tab, κ, z, dw, ks, W, ubuff, tmp, atmp, linsolve,
2494+ rtol, atol, num_stages,
2495+ ) = cache
24762496 (; A, b, c) = tab
24772497 (; internalnorm) = integrator. opts
24782498 (; maxiters) = alg
@@ -2510,8 +2530,10 @@ end
25102530 end
25112531
25122532 needfactor = iter == 1
2513- linres = dolinsolve (integrator, linsolve;
2514- A = needfactor ? W : nothing , b = ubuff, linu = ubuff)
2533+ linres = dolinsolve (
2534+ integrator, linsolve;
2535+ A = needfactor ? W : nothing , b = ubuff, linu = ubuff
2536+ )
25152537 cache. linsolve = linres. cache
25162538 integrator. stats. nsolve += 1
25172539
@@ -2520,10 +2542,12 @@ end
25202542 end
25212543
25222544 ndwprev = ndw
2523- ndw = sum (begin
2524- calculate_residuals! (atmp, dw[i], uprev_local, uprev_local, atol, rtol, internalnorm, t_local)
2525- internalnorm (atmp, t_local)
2526- end for i in 1 : num_stages)
2545+ ndw = sum (
2546+ begin
2547+ calculate_residuals! (atmp, dw[i], uprev_local, uprev_local, atol, rtol, internalnorm, t_local)
2548+ internalnorm (atmp, t_local)
2549+ end for i in 1 : num_stages
2550+ )
25272551
25282552 if iter > 1
25292553 θ = ndw / ndwprev
@@ -2567,16 +2591,18 @@ end
25672591
25682592@muladd function perform_step! (integrator, cache:: GaussLegendreCache , repeat_step = false )
25692593 (; t, dt, uprev, u, f, p, fsallast) = integrator
2570- (; atmp, J, z, z_last, u_full, u_half, rtol, atol,
2571- step_limiter!, num_stages) = cache
2594+ (;
2595+ atmp, J, z, z_last, u_full, u_half, rtol, atol,
2596+ step_limiter!, num_stages,
2597+ ) = cache
25722598 (; internalnorm, adaptive) = integrator. opts
25732599 alg = unwrap_alg (integrator, true )
25742600
25752601 new_jac = do_newJ (integrator, alg, cache, repeat_step)
25762602 new_jac && (calc_J! (J, integrator, cache); cache. W_γdt = dt)
25772603
25782604 if adaptive && num_stages >= 2
2579- # fll step at dt
2605+ # fll step at dt
25802606 ok1 = _gausslegendre_substep! (u_full, uprev, t, dt, J, cache, integrator, alg)
25812607 if ! ok1
25822608 integrator. force_stepfail = true
@@ -2609,7 +2635,7 @@ end
26092635
26102636 p_order = 2 * num_stages
26112637 denom = 2 ^ p_order - 1
2612- @. . u_full = (u - u_full) / denom
2638+ @. . u_full = (u - u_full) / denom
26132639 calculate_residuals! (atmp, u_full, uprev, u, atol, rtol, internalnorm, t)
26142640 integrator. EEst = internalnorm (atmp, t)
26152641 else
@@ -2637,4 +2663,4 @@ end
26372663 f (fsallast, u, p, t + dt)
26382664 OrdinaryDiffEqCore. increment_nf! (integrator. stats, 1 )
26392665 return
2640- end
2666+ end
0 commit comments