Skip to content

Commit

Permalink
workaround for allocations when broadcasting equations
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha authored Sep 6, 2023
1 parent f098ea2 commit 0854773
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/equations/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ end

@inline Base.ndims(::AbstractEquations{NDIMS}) where {NDIMS} = NDIMS

# equations act like scalars in broadcasting
Base.broadcastable(equations::AbstractEquations) = Ref(equations)
# Equations act like scalars in broadcasting.
# Using `Ref(equations)` would be more convenient in some circumstances.
# However, this does not work with Julia v1.9.3 correctly due to a (performance)
# bug in Julia, see
# - https://github.com/trixi-framework/Trixi.jl/pull/1618
# - https://github.com/JuliaLang/julia/issues/51118
# Thus, we use the workaround below.
Base.broadcastable(equations::AbstractEquations) = (equations,)

"""
flux(u, orientation_or_normal, equations)
Expand Down

0 comments on commit 0854773

Please sign in to comment.