Skip to content

Commit b96b6d7

Browse files
committed
fix: Compute phase diff for PencilGrids
TODO: compute correct diff at boundaries. Related: #38
1 parent 8c5feca commit b96b6d7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/grids.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ function max_normed_phase_grad(grids)
316316

317317
max_grads = zeros(n)
318318

319-
shift = zeros(n)
319+
shift = zeros(Int, n)
320320
shift[1] = 1
321321

322322
for i in 1:n

src/pencil_grids.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ Returns an array of size `(size(field)[1], size(field)[2], size(field)[2])`
242242
containing gradients in direction `dir`.
243243
"""
244244
function phase_diff(field::PencilArray, dir)
245-
@warn "phase diff unimplemented for PencilArrays"
246-
0
247-
# out = similar(field, Real)
245+
out = similar(field, Real)
248246

249-
# out .= angle.(circshift(field, dir) ./ field)
247+
# TODO diff at boundaries
248+
out .= 0
249+
out[1:end-dir[1], 1:end-dir[2], 1:end-dir[3]] .= angle.(circshift(field[1:end-dir[1], 1:end-dir[2], 1:end-dir[3]], dir) ./ field[1+dir[1]:end, 1+dir[2]:end, 1+dir[3]:end])
250250

251-
# out
251+
out
252252
end

0 commit comments

Comments
 (0)