Skip to content

Commit 4c603f4

Browse files
Fix FIRK boundary residual EvalSol AD storage
Construct the boundary-condition EvalSol from the current unflattened state so ForwardDiff dual values are not copied into Float64 solution storage during FIRK residual evaluation. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent fcc08ec commit 4c603f4

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

  • lib/BoundaryValueDiffEqFIRK/src

lib/BoundaryValueDiffEqFIRK/src/firk.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,25 +1395,25 @@ end
13951395

13961396
@views function __firk_loss!(
13971397
resid, u, p, y, pt::StandardBVProblem, bc!::BC, residual, mesh,
1398-
cache, eval_sol, trait::DiffCacheNeeded, constraint
1398+
cache, _, trait::DiffCacheNeeded, constraint
13991399
) where {BC}
14001400
y_ = recursive_unflatten!(y, u)
14011401
resids = [get_tmp(r, u) for r in residual]
14021402
Φ!(resids[2:end], cache, y_, u, trait, constraint)
1403-
eval_sol.u[1:end] .= y_
1403+
eval_sol = EvalSol(__restructure_sol(y_, cache.in_size), mesh, cache)
14041404
eval_bc_residual!(resids[1], pt, bc!, eval_sol, p, mesh)
14051405
recursive_flatten!(resid, resids)
14061406
return nothing
14071407
end
14081408

14091409
@views function __firk_loss!(
14101410
resid, u, p, y, pt::StandardBVProblem, bc!::BC, residual, mesh,
1411-
cache, eval_sol, trait::NoDiffCacheNeeded, constraint
1411+
cache, _, trait::NoDiffCacheNeeded, constraint
14121412
) where {BC}
14131413
y_ = recursive_unflatten!(y, u)
14141414
resids = [r for r in residual]
14151415
Φ!(resids[2:end], cache, y_, u, trait, constraint)
1416-
eval_sol.u[1:end] .= y_
1416+
eval_sol = EvalSol(__restructure_sol(y_, cache.in_size), mesh, cache)
14171417
eval_bc_residual!(resids[1], pt, bc!, eval_sol, p, mesh)
14181418
recursive_flatten!(resid, resids)
14191419
return nothing
@@ -1470,10 +1470,10 @@ end
14701470
end
14711471

14721472
@views function __firk_loss(
1473-
u, p, y, pt::StandardBVProblem, bc::BC, mesh, cache, eval_sol, trait
1473+
u, p, y, pt::StandardBVProblem, bc::BC, mesh, cache, _, trait
14741474
) where {BC}
14751475
y_ = recursive_unflatten!(y, u)
1476-
eval_sol.u[1:end] .= y_
1476+
eval_sol = EvalSol(__restructure_sol(y_, cache.in_size), mesh, cache)
14771477
resid_bc = eval_bc_residual(pt, bc, eval_sol, p, mesh)
14781478
resid_co = Φ(cache, y_, u, trait)
14791479
return vcat(resid_bc, mapreduce(vec, vcat, resid_co))

0 commit comments

Comments
 (0)