Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop passing p and t to the JacVec operator #2062

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/derivative_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,22 @@
dtgamma = nothing,
transform = nothing)
if (u !== nothing) && (p !== nothing) && (t !== nothing)
update_coefficients!(W.J, u, p, t)
if W.J isa FunctionOperator
update_coefficients!(W.J, u, ifelse(W.J.p === nothing, nothing, p),
ifelse(W.J.t === nothing, nothing, t))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this all about? Why doesn't the update_coefficients! handle this correctly?

else
update_coefficients!(W.J, u, p, t)
end
update_coefficients!(W.mass_matrix, u, p, t)
!isnothing(W.jacvec) && update_coefficients!(W.jacvec, u, p, t)
if !isnothing(W.jacvec)
if W.jacvec isa FunctionOperator
update_coefficients!(W.jacvec, u,
ifelse(W.jacvec.p === nothing, nothing, p),
ifelse(W.jacvec.t === nothing, nothing, t))
else
update_coefficients!(W.jacvec, u, p, t)

Check warning on line 318 in src/derivative_utils.jl

View check run for this annotation

Codecov / codecov/patch

src/derivative_utils.jl#L318

Added line #L318 was not covered by tests
end
end
end
dtgamma !== nothing && (W.gamma = dtgamma)
transform !== nothing && (W.transform = transform)
Expand Down Expand Up @@ -874,7 +887,7 @@
# be overridden with concrete_jac.

_f = islin ? (isode ? f.f : f.f1.f) : f
jacvec = JacVec(UJacobianWrapper(_f, t, p), copy(u), p, t;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is it going to update the coefficients correctly without this?

jacvec = JacVec(UJacobianWrapper(_f, t, p), copy(u);
autodiff = alg_autodiff(alg), tag = OrdinaryDiffEqTag())
J = jacvec
W = WOperator{IIP}(f.mass_matrix, dt, J, u, jacvec)
Expand All @@ -890,7 +903,7 @@
else
deepcopy(f.jac_prototype)
end
jacvec = JacVec(UJacobianWrapper(_f, t, p), copy(u), p, t;
jacvec = JacVec(UJacobianWrapper(_f, t, p), copy(u);
autodiff = alg_autodiff(alg), tag = OrdinaryDiffEqTag())
W = WOperator{IIP}(f.mass_matrix, dt, J, u, jacvec)

Expand Down
Loading