diff --git a/docs/make.jl b/docs/make.jl index 639e7fe3..e0be28b8 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -17,8 +17,8 @@ makedocs(; sitename="TopOpt.jl", format=Documenter.HTML(; prettyurls=get(ENV, "CI", nothing) == "true"), # doctest = false, - warnonly = true, - plugins = [bib], + warnonly=true, + plugins=[bib], pages=[ "Home" => "index.md", "Problem types" => "examples/problem.md", diff --git a/src/TopOpt.jl b/src/TopOpt.jl index 5bac1257..9ce76f22 100644 --- a/src/TopOpt.jl +++ b/src/TopOpt.jl @@ -19,9 +19,11 @@ function PseudoDensities(x::A) where {T,N,A<:AbstractArray{T,N}} end function PseudoDensities{I,P,F}(x::A) where {I,P,F,T,N,A<:AbstractArray{T,N}} return PseudoDensities{I,P,F,T,N,A}(x) -end -function ChainRulesCore.rrule(::Type{PseudoDensities{I, P, F, T, N, A}}, x) where {I, P, F, T, N, A <: AbstractArray{T, N}} - PseudoDensities{I, P, F, T, N, A}(x), Δ -> (NoTangent(), Δ isa Tangent ? Δ.x : Δ) +end +function ChainRulesCore.rrule( + ::Type{PseudoDensities{I,P,F,T,N,A}}, x +) where {I,P,F,T,N,A<:AbstractArray{T,N}} + return PseudoDensities{I,P,F,T,N,A}(x), Δ -> (NoTangent(), Δ isa Tangent ? Δ.x : Δ) end Base.BroadcastStyle(::Type{T}) where {T<:PseudoDensities} = Broadcast.ArrayStyle{T}() diff --git a/src/Utilities/penalties.jl b/src/Utilities/penalties.jl index b4801751..73a8e6ff 100644 --- a/src/Utilities/penalties.jl +++ b/src/Utilities/penalties.jl @@ -33,7 +33,9 @@ end @inline (P::ProjectedPenalty)(x::Real) = P.penalty(P.proj(x)) @forward_property ProjectedPenalty penalty -(P::AbstractProjection)(x::PseudoDensities{I,T,F}) where {I,T,F} = PseudoDensities{I,T,F}(P(x.x)) +function (P::AbstractProjection)(x::PseudoDensities{I,T,F}) where {I,T,F} + return PseudoDensities{I,T,F}(P(x.x)) +end (P::AbstractProjection)(x::AbstractArray) = map(P, x) mutable struct HeavisideProjection{T} <: AbstractProjection