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

Comments explaining usage of ForwardDiff.jacobian #1800

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Changes from all commits
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
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
Loading