@@ -321,6 +321,8 @@ function terminate!(integrator::ODEIntegrator, retcode = ReturnCode.Terminated)
321
321
integrator. opts. tstops. valtree = typeof (integrator. opts. tstops. valtree)()
322
322
end
323
323
324
+ const EMPTY_ARRAY_OF_PAIRS = Pair[]
325
+
324
326
DiffEqBase. has_reinit (integrator:: ODEIntegrator ) = true
325
327
function DiffEqBase. reinit! (integrator:: ODEIntegrator , u0 = integrator. sol. prob. u0;
326
328
t0 = integrator. sol. prob. tspan[1 ],
@@ -335,6 +337,23 @@ function DiffEqBase.reinit!(integrator::ODEIntegrator, u0 = integrator.sol.prob.
335
337
reinit_callbacks = true , initialize_save = true ,
336
338
reinit_cache = true ,
337
339
reinit_retcode = true )
340
+ if reinit_dae && SciMLBase. has_initializeprob (integrator. sol. prob. f)
341
+ # This is `remake` infrastructure. `reinit!` is somewhat like `remake` for
342
+ # integrators, so we reuse some of the same pieces. If we pass `integrator.p`
343
+ # for `p`, it means we don't want to change it. If we pass `missing`, this
344
+ # function may (correctly) assume `newp` aliases `prob.p` and copy it, which we
345
+ # want to avoid. So we pass an empty array of pairs to make it think this is
346
+ # a symbolic `remake` and it can modify `newp` inplace. The array of pairs is a
347
+ # const global to avoid allocating every time this function is called.
348
+ u0, newp = SciMLBase. late_binding_update_u0_p (integrator. sol. prob, u0,
349
+ EMPTY_ARRAY_OF_PAIRS, t0, u0, integrator. p)
350
+ if newp != = integrator. p
351
+ integrator. p = newp
352
+ sol = integrator. sol
353
+ @reset sol. prob. p = newp
354
+ integrator. sol = sol
355
+ end
356
+ end
338
357
if isinplace (integrator. sol. prob)
339
358
recursivecopy! (integrator. u, u0)
340
359
recursivecopy! (integrator. uprev, integrator. u)
0 commit comments