From 7cf44aba1324713b40c58ba40ba56fa42ff40455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20F=C3=A9votte?= <francois.fevotte@triscale-innov.com> Date: Fri, 29 Nov 2024 16:45:39 +0100 Subject: [PATCH] Box_size parameter for `NearestMin` ray calculations --- CHANGELOG.md | 3 +++ src/Eikonal.jl | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bebe1d2..c9877f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Eikonal.jl b/src/Eikonal.jl index e0c1b03..dab73f4 100644 --- a/src/Eikonal.jl +++ b/src/Eikonal.jl @@ -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