trixi-framework / trixi-framework/Trixi.jl

`jacobian_ad_forward` Not working with `IndicatorHennemannGassner`

Open
#1,252 8 comments 0 reactions 0 assignees View on GitHub
bug enhancement
Dominant language
Julia
Stars
731
Forks
166
Avg merge
2d 18h
Merged PRs (30d)
25

Description

Not sure if this is a known issue, but right now calling `jacobian_ad_forward` with a semidiscretization build from `VolumeIntegralShockCapturingHG` with shock indicator [`IndicatorHennemannGassner`](https://github.com/trixi-framework/Trixi.jl/blob/3ea50d1d108d9c3b4d5ce463a40a20bfa7937633/src/solvers/dgsem_tree/indicators_1d.jl) like in [`examples/structured_1d_dgsem/elixir_euler_sedov.jl`](https://github.com/trixi-framework/Trixi.jl/blob/3ea50d1d108d9c3b4d5ce463a40a20bfa7937633/examples/structured_1d_dgsem/elixir_euler_sedov.jl#L58) gives the error

```
ERROR: MethodError: no method matching Float64(::ForwardDiff.Dual{Nothing, Float64, 12})
Closest candidates are:
(::Type{T})(::Real, ::RoundingMode) where T<:AbstractFloat at rounding.jl:200
(::Type{T})(::T) where T<:Number at boot.jl:772
(::Type{T})(::VectorizationBase.Double{T}) where T<:Union{Float16, Float32, Float64, VectorizationBase.Vec{<:Any, <:Union{Float16, Float32, Float64}}, VectorizationBase.VecUnroll{var"#s36", var"#s35", var"#s34", V} where {var"#s36", var"#s35", var"#s34"<:Union{Float16, Float32, Float64}, V<:Union{Bool, Float16, Float32, Float64, Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8, SIMDTypes.Bit, VectorizationBase.AbstractSIMD{var"#s35", var"#s34"}}}} at ~/.julia/packages/VectorizationBase/MOxkH/src/special/double.jl:100
...
Stacktrace:
[1] convert(#unused#::Type{Float64}, x::ForwardDiff.Dual{Nothing, Float64, 12})
@ Base ./number.jl:7
[2] setindex!(A::Vector{Float64}, x::ForwardDiff.Dual{Nothing, Float64, 12}, i1::Int64)
@ Base ./array.jl:966
[3] macro expansion
@ ~/.julia/dev/Trixi/src/solvers/dgsem_tree/indicators_1d.jl:51 [inlined]

...
```

i.e., what goes wrong is that the datatypes within

[`indicator[i] = indicator_hg.variable(u_local, equations)`](https://github.com/trixi-framework/Trixi.jl/blob/3ea50d1d108d9c3b4d5ce463a40a20bfa7937633/src/solvers/dgsem_tree/indicators_1d.jl#L51)

disagree.

Contributor guide

Open the contributing guide

Research direction

Start with src/solvers/dgsem_tree/indicators_1d.jl at the indicator[i] assignment around line 51, then reproduce the failure using examples/structured_1d_dgsem/elixir_euler_sedov.jl with jacobian_ad_forward. Trace the IndicatorHennemannGassner path and verify that the indicator storage and ForwardDiff result use compatible datatypes.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.