Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Generalizes the alias functions (e.g. `lineintegral`) to also accept `Domain`s.
- Updated docstrings to improve clarity and consistency.
- Improved unit testing for `AutoEnzyme` support.


## [0.16.3] - 2025-06-26
Expand Down
2 changes: 1 addition & 1 deletion ext/MeshIntegralsEnzymeExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ MeshIntegrals.supports_autoenzyme(::Type{<:Meshes.Geometry}) = true
MeshIntegrals.supports_autoenzyme(::Type{<:Meshes.Domain}) = true
# except for those that throw errors (see GitHub Issue #154)
MeshIntegrals.supports_autoenzyme(::Type{<:Meshes.BezierCurve}) = false
MeshIntegrals.supports_autoenzyme(::Type{<:Meshes.CylinderSurface}) = false
MeshIntegrals.supports_autoenzyme(::Type{<:Meshes.Cylinder}) = false
MeshIntegrals.supports_autoenzyme(::Type{<:Meshes.CylinderSurface}) = false
MeshIntegrals.supports_autoenzyme(::Type{<:Meshes.ParametrizedCurve}) = false

end
32 changes: 20 additions & 12 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,33 @@ end
end

@testitem "Differentiation (EnzymeExt loaded)" setup=[Utils] begin
# supports_autoenzyme(::Type{<:Any})
@test MeshIntegrals.supports_autoenzyme(Nothing) == false

# _default_diff_method -- using type or instance, Enzyme-supported combination
# supports_autoenzyme & _default_diff_method
# Nominal usage: Enzyme-supported geometry and FP type
let sphere = Sphere(Point(0, 0, 0), 1.0)
@test _default_diff_method(Meshes.Sphere, Float64) isa AutoEnzyme
@test _default_diff_method(sphere, Float64) isa AutoEnzyme
end

# _default_diff_method -- Enzyme-unsupported FP types
# supports_autoenzyme(::Type{<:Any}) for CI completeness
@test MeshIntegrals.supports_autoenzyme(Nothing) == false
# BezierCurve: blocked by upstream Meshes-Enzyme incompatibility
let curve = BezierCurve([Point(t, 0) for t in range(-π, π, length = 361)])
@test_throws "proven readonly" jacobian(curve, (0.5,), AutoEnzyme())
@test _default_diff_method(Meshes.BezierCurve, Float64) isa FiniteDifference
end
# Cylinder: blocked by version-dependent upstream Meshes-Enzyme incompatibility
let cyl = Cylinder(Point(0, 0, 0), Point(0, 0, 1), 2.0)
@test _default_diff_method(Meshes.Cylinder, Float64) isa FiniteDifference
end
# CylinderSurface: blocked by version-dependent upstream Meshes-Enzyme incompatibility
let cylsurf = CylinderSurface(Point(0, 0, 0), Point(0, 0, 1), 2.0)
@test _default_diff_method(Meshes.CylinderSurface, Float64) isa FiniteDifference
end
# ParametrizedCurve: no default AD since user-defined functions
@test _default_diff_method(Meshes.ParametrizedCurve, Float64) isa FiniteDifference
# Non-Float64: other FP types not supported by Enzyme
@test _default_diff_method(Meshes.Sphere, Float16) isa FiniteDifference
@test _default_diff_method(Meshes.Sphere, BigFloat) isa FiniteDifference

# _default_diff_method -- geometries that currently error with AutoEnzyme
@test _default_diff_method(Meshes.BezierCurve, Float64) isa FiniteDifference
@test _default_diff_method(Meshes.CylinderSurface, Float64) isa FiniteDifference
@test _default_diff_method(Meshes.Cylinder, Float64) isa FiniteDifference
@test _default_diff_method(Meshes.ParametrizedCurve, Float64) isa FiniteDifference

# FiniteDifference
@test FiniteDifference().ε ≈ 1e-6

Expand Down
Loading