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
2 changes: 2 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
Expand All @@ -18,6 +19,7 @@ Enzyme = "0.13.47"
ExplicitImports = "1.6.0"
LinearAlgebra = "1"
Meshes = "0.51.20, 0.52, 0.53, 0.54"
Pkg = "1"
SpecialFunctions = "2"
TestItemRunner = "1"
TestItems = "1"
Expand Down
39 changes: 27 additions & 12 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
using MeshIntegrals: _default_diff_method, _parametric, _units, _zeros, _ones
using Unitful
import Enzyme

import Pkg
println("julia: " * string(VERSION))
println("Enzyme.jl: " * string(Pkg.dependencies()[Base.PkgId(Enzyme).uuid].version))
println("Meshes.jl: " * string(Pkg.dependencies()[Base.PkgId(Meshes).uuid].version))
end

@testitem "Utilities" setup=[Utils] begin
Expand All @@ -26,25 +31,35 @@ 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 upstream Meshes-Enzyme incompatibility
let cyl = Cylinder(Point(0, 0, 0), Point(0, 0, 1), 2.0)
@test_throws "jl_get_builtin_fptr" jacobian(cyl, (0.5, 0.5, 0.5), AutoEnzyme())
@test _default_diff_method(Meshes.Cylinder, Float64) isa FiniteDifference
end
# CylinderSurface: blocked by upstream Meshes-Enzyme incompatibility
let cylsurf = CylinderSurface(Point(0, 0, 0), Point(0, 0, 1), 2.0)
@test_throws "jl_get_builtin_fptr" jacobian(cylsurf, (0.5, 0.5), AutoEnzyme())
@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