Skip to content

Commit 45949a1

Browse files
committed
Add docstrings, formatting
1 parent 08b9bf2 commit 45949a1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/utils.jl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,37 @@ end
1212
# DifferentiationMethod
1313
################################################################################
1414

15+
"""
16+
supports_autoenzyme(geometry)
17+
18+
Return whether a geometry (or geometry type) has a parametric function that can be
19+
differentiated with Enzyme. See GitHub Issue #154 for more information.
20+
"""
1521
supports_autoenzyme(::Type{<:Meshes.Geometry}) = true
1622
supports_autoenzyme(::Type{<:Meshes.BezierCurve}) = false
1723
supports_autoenzyme(::Type{<:Meshes.CylinderSurface}) = false
1824
supports_autoenzyme(::Type{<:Meshes.Cylinder}) = false
1925
supports_autoenzyme(::Type{<:Meshes.ParametrizedCurve}) = false
2026
supports_autoenzyme(::G) where {G <: Geometry} = supports_autoenzyme(G)
2127

28+
"""
29+
_check_diff_method_support(::Geometry, ::DifferentiationMethod) -> nothing
30+
31+
Throw an error if incompatible geometry-diff_method combination detected.
32+
"""
2233
_check_diff_method_support(::Geometry, ::DifferentiationMethod) = nothing
2334
function _check_diff_method_support(geometry::Geometry, ::AutoEnzyme)
2435
if !supports_autoenzyme(geometry)
25-
throw(ArgumentError("Differentiation method AutoEnzyme not supported for this geometry."))
36+
throw(ArgumentError("AutoEnzyme not supported for this geometry."))
2637
end
2738
end
2839

29-
# Return the default DifferentiationMethod instance for a particular geometry type
40+
"""
41+
_default_diff_method(geometry, FP)
42+
43+
Return an instance of the default DifferentiationMethod for a particular geometry
44+
(or geometry type) and floating point type.
45+
"""
3046
function _default_diff_method(
3147
g::Type{G}, FP::Type{T}
3248
) where {G <: Geometry, T <: AbstractFloat}
@@ -37,7 +53,6 @@ function _default_diff_method(
3753
end
3854
end
3955

40-
# Return the default DifferentiationMethod instance for a particular geometry instance
4156
function _default_diff_method(::G, ::Type{T}) where {G <: Geometry, T <: AbstractFloat}
4257
_default_diff_method(G, T)
4358
end

0 commit comments

Comments
 (0)