@@ -8,19 +8,19 @@ function loopheader!(integrator)
8
8
9
9
# Accept or reject the step
10
10
if integrator. iter > 0
11
- if ((integrator. opts. adaptive && integrator. accept_step) ||
12
- ! integrator. opts. adaptive) && ! integrator. force_stepfail
13
- integrator. success_iter += 1
14
- apply_step! (integrator)
15
- elseif integrator. opts. adaptive && ! integrator. accept_step
11
+ if (integrator. opts. adaptive && ! integrator. accept_step) || integrator. force_stepfail
16
12
if integrator. isout
17
13
integrator. dt = integrator. dt * integrator. opts. qmin
18
14
elseif ! integrator. force_stepfail
19
15
step_reject_controller! (integrator, integrator. alg)
20
16
end
17
+ else
18
+ integrator. success_iter += 1
19
+ apply_step! (integrator)
21
20
end
22
21
elseif integrator. u_modified # && integrator.iter == 0
23
22
update_uprev! (integrator)
23
+ update_fsal! (integrator)
24
24
end
25
25
26
26
integrator. iter += 1
@@ -31,6 +31,43 @@ function loopheader!(integrator)
31
31
return nothing
32
32
end
33
33
34
+
35
+ function apply_step! (integrator)
36
+ update_uprev! (integrator)
37
+
38
+ # Update dt if adaptive or if fixed and the dt is allowed to change
39
+ if integrator. opts. adaptive || integrator. dtchangeable
40
+ integrator. dt = integrator. dtpropose
41
+ elseif integrator. dt != integrator. dtpropose && ! integrator. dtchangeable
42
+ error (" The current setup does not allow for changing dt." )
43
+ end
44
+
45
+ update_fsal! (integrator)
46
+ return nothing
47
+ end
48
+
49
+ function update_fsal! (integrator)
50
+ if has_discontinuity (integrator) &&
51
+ first_discontinuity (integrator) == integrator. tdir * integrator. t
52
+ handle_discontinuities! (integrator)
53
+ get_current_isfsal (integrator. alg, integrator. cache) && reset_fsal! (integrator)
54
+ elseif all_fsal (integrator. alg, integrator. cache) ||
55
+ get_current_isfsal (integrator. alg, integrator. cache)
56
+ if integrator. reeval_fsal || integrator. u_modified ||
57
+ (isdp8 (integrator. alg) && ! integrator. opts. calck) ||
58
+ (only_diagonal_mass_matrix (integrator. alg) &&
59
+ ! integrator. opts. adaptive)
60
+ reset_fsal! (integrator)
61
+ else # Do not reeval_fsal, instead copyto! over
62
+ if isinplace (integrator. sol. prob)
63
+ recursivecopy! (integrator. fsalfirst, integrator. fsallast)
64
+ else
65
+ integrator. fsalfirst = integrator. fsallast
66
+ end
67
+ end
68
+ end
69
+ end
70
+
34
71
function last_step_failed (integrator:: ODEIntegrator )
35
72
integrator. last_stepfail && ! integrator. opts. adaptive
36
73
end
@@ -386,39 +423,6 @@ function update_uprev!(integrator)
386
423
nothing
387
424
end
388
425
389
- function apply_step! (integrator)
390
- update_uprev! (integrator)
391
-
392
- # Update dt if adaptive or if fixed and the dt is allowed to change
393
- if integrator. opts. adaptive || integrator. dtchangeable
394
- integrator. dt = integrator. dtpropose
395
- elseif integrator. dt != integrator. dtpropose && ! integrator. dtchangeable
396
- error (" The current setup does not allow for changing dt." )
397
- end
398
-
399
- # Update fsal if needed
400
- if has_discontinuity (integrator) &&
401
- first_discontinuity (integrator) == integrator. tdir * integrator. t
402
- handle_discontinuities! (integrator)
403
- get_current_isfsal (integrator. alg, integrator. cache) && reset_fsal! (integrator)
404
- elseif all_fsal (integrator. alg, integrator. cache) ||
405
- get_current_isfsal (integrator. alg, integrator. cache)
406
- if integrator. reeval_fsal || integrator. u_modified ||
407
- (isdp8 (integrator. alg) && ! integrator. opts. calck) ||
408
- (only_diagonal_mass_matrix (integrator. alg) &&
409
- ! integrator. opts. adaptive)
410
- reset_fsal! (integrator)
411
- else # Do not reeval_fsal, instead copyto! over
412
- if isinplace (integrator. sol. prob)
413
- recursivecopy! (integrator. fsalfirst, integrator. fsallast)
414
- else
415
- integrator. fsalfirst = integrator. fsallast
416
- end
417
- end
418
- end
419
- return nothing
420
- end
421
-
422
426
handle_discontinuities! (integrator) = pop_discontinuity! (integrator)
423
427
424
428
function calc_dt_propose! (integrator, dtnew)
0 commit comments