Skip to content

Commit

Permalink
Box_size parameter for NearestMin ray calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
ffevotte committed Nov 29, 2024
1 parent 3ef5750 commit 7cf44ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Testing with [`Aqua.jl`](https://github.com/JuliaTesting/Aqua.jl)
([#23](https://github.com/triscale-innov/Eikonal.jl/pull/23))

- Possibility to tune the box size for ray computations via the `NearestMin`
method

### Fixed

Expand Down
11 changes: 8 additions & 3 deletions src/Eikonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,19 @@ function ray(t::AbstractArray{T,D}, pos, method::Integration) where {T,D}
res
end

struct NearestMin end
function ray(t::AbstractArray{T,D}, pos, ::NearestMin) where {T, D}
struct NearestMin
box_size :: Int
NearestMin(box_size = 1) = new(box_size)
end

function ray(t::AbstractArray{T,D}, pos, method::NearestMin) where {T, D}
I = CartesianIndex(pos)
res = [pos]
bs = method.box_size

while true
# Find minimal time in a box surrounding the current position
box = I-oneunit(I):I+oneunit(I)
box = I-bs*oneunit(I):I+bs*oneunit(I)
_, ibox = findmin(box) do I′
I′ CartesianIndices(t) ? t[I′] : Inf
end
Expand Down

0 comments on commit 7cf44ab

Please sign in to comment.