Skip to content

Commit

Permalink
comments explaining usage of ForwardDiff.jacobian
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDoehring committed Jan 8, 2024
1 parent 1b6a4a9 commit a1de7e8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/semidiscretization/semidiscretization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ end

function _jacobian_ad_forward(semi, t0, u0_ode, du_ode, config)
new_semi = remake(semi, uEltype = eltype(config))
# Create anonymous function passed as first argument to `ForwardDiff.jacobian` to match
# `ForwardDiff.jacobian(f!, y::AbstractArray, x::AbstractArray,
# cfg::JacobianConfig = JacobianConfig(f!, y, x), check=Val{true}())`
J = ForwardDiff.jacobian(du_ode, u0_ode, config) do du_ode, u_ode
Trixi.rhs!(du_ode, u_ode, new_semi, t0)
end
Expand All @@ -279,6 +282,9 @@ end

function _jacobian_ad_forward_structarrays(semi, t0, u0_ode_plain, du_ode_plain, config)
new_semi = remake(semi, uEltype = eltype(config))
# Create anonymous function passed as first argument to `ForwardDiff.jacobian` to match
# `ForwardDiff.jacobian(f!, y::AbstractArray, x::AbstractArray,
# cfg::JacobianConfig = JacobianConfig(f!, y, x), check=Val{true}())`
J = ForwardDiff.jacobian(du_ode_plain, u0_ode_plain,
config) do du_ode_plain, u_ode_plain
u_ode = StructArray{SVector{nvariables(semi), eltype(config)}}(ntuple(v -> view(u_ode_plain,
Expand Down

0 comments on commit a1de7e8

Please sign in to comment.