@@ -9,7 +9,7 @@ A category of types used to specify the desired method for calculating derivativ
99Derivatives are used to form Jacobian matrices when calculating the differential
1010element size throughout the integration region.
1111
12- See also [`FiniteDifference`](@ref).
12+ See also [`FiniteDifference`](@ref), [`AutoEnzyme`](@ref) .
1313"""
1414abstract type DifferentiationMethod end
1515
2727FiniteDifference {T} () where {T <: AbstractFloat } = FiniteDifference {T} (T (1e-6 ))
2828FiniteDifference () = FiniteDifference {Float64} ()
2929
30+ """
31+ AutoEnzyme()
32+
33+ Use to specify use of the Enzyme.jl for calculating derivatives.
34+ """
35+ struct AutoEnzyme <: DifferentiationMethod end
36+
3037# Future Support:
31- # struct AutoEnzyme <: DifferentiationMethod end
3238# struct AutoZygote <: DifferentiationMethod end
3339
3440# ###############################################################################
@@ -52,7 +58,7 @@ function jacobian(
5258 geometry:: G ,
5359 ts:: Union{AbstractVector{T}, Tuple{T, Vararg{T}}}
5460) where {G <: Geometry , T <: AbstractFloat }
55- return jacobian (geometry, ts, _default_diff_method (G))
61+ return jacobian (geometry, ts, _default_diff_method (G, T ))
5662end
5763
5864function jacobian (
@@ -68,7 +74,7 @@ function jacobian(
6874 # Get the partial derivative along the n'th axis via finite difference
6975 # approximation, where ts is the current parametric position
7076 function ∂ₙr (ts, n, ε)
71- # Build left/right parametric coordinates with non-allocating iterators
77+ # Build left/right parametric coordinates with non-allocating iterators
7278 left = Iterators. map (((i, t),) -> i == n ? t - ε : t, enumerate (ts))
7379 right = Iterators. map (((i, t),) -> i == n ? t + ε : t, enumerate (ts))
7480 # Select orientation of finite-diff
@@ -107,7 +113,7 @@ possible and finite difference approximations otherwise.
107113function differential (
108114 geometry:: G ,
109115 ts:: Union{AbstractVector{T}, Tuple{T, Vararg{T}}} ,
110- diff_method:: DifferentiationMethod = _default_diff_method (G)
116+ diff_method:: DifferentiationMethod = _default_diff_method (G, T )
111117) where {G <: Geometry , T <: AbstractFloat }
112118 J = Iterators. map (_KVector, jacobian (geometry, ts, diff_method))
113119 return LinearAlgebra. norm (foldl (∧ , J))
0 commit comments