Skip to content

Commit

Permalink
fix: make applypressure and pressuregradient same
Browse files Browse the repository at this point in the history
  • Loading branch information
agdestein committed Nov 29, 2024
1 parent 672de2a commit d48706b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,20 +213,22 @@ ChainRulesCore.rrule(::typeof(applypressure), u, p, setup) = (
"Subtract pressure gradient (in-place version)."
function applypressure!(u, p, setup)
(; grid, backend, workgroupsize) = setup
(; dimension, Δu, N) = grid
(; dimension, Δu, N, Iu) = grid
D = dimension()
e = Offset(D)
kernel = applypressure_kernel!(backend, workgroupsize)
I0 = oneunit(CartesianIndex{D})
kernel(u, p, Δu, e, Val(1:D), I0; ndrange = N .- 2)
kernel(u, p, Δu, Iu, e, Val(1:D), I0; ndrange = N .- 2)
u
end

@kernel function applypressure_kernel!(u, p, Δu, e, valdims, I0)
@kernel function applypressure_kernel!(u, p, Δu, Iu, e, valdims, I0)

Check warning on line 225 in src/operators.jl

View check run for this annotation

Codecov / codecov/patch

src/operators.jl#L225

Added line #L225 was not covered by tests
I = @index(Global, Cartesian)
I = I0 + I
@unroll for α in getval(valdims)
u[I, α] -= (p[I+e(α)] - p[I]) / Δu[α][I[α]]
if I Iu[α]
u[I, α] -= (p[I+e(α)] - p[I]) / Δu[α][I[α]]
end
end
end

Expand Down

0 comments on commit d48706b

Please sign in to comment.