Skip to content

Commit e406551

Browse files
committed
fix break condition on reinitialization
1 parent aeb77f4 commit e406551

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/ReinitializationExt.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ function _sample_interface(grid, f, ∇f, upsample, maxiter, ftol)
5252
lc, hc = grid[I], grid[Ip]
5353
samples = (lc .+ (hc .- lc) .* (SVector(j, k) .+ 0.5) ./ upsample for j in 0:(upsample - 1), k in 0:(upsample - 1))
5454
# Skip cells where all samples have the same sign
55-
all(x -> f(x) > 0, samples) || all(x -> f(x) < 0, samples) && continue
55+
s = samples |> first |> f |> sign
56+
any(x -> f(x) * s < 0, samples) || continue
5657
# Go over samples and push them to the interface
5758
for x in samples
5859
pt = _project_to_interface(f, ∇f, x, maxiter, ftol)
@@ -66,7 +67,7 @@ function _project_to_interface(f, ∇f, x0, maxiter, ftol)
6667
x = x0
6768
for _ in 1:maxiter
6869
val = f(x)
69-
val < ftol && break # close enough to the interface
70+
abs(val) < ftol && break # close enough to the interface
7071
grad = ∇f(x)
7172
norm_grad = norm(grad)
7273
iszero(norm_grad) && break

0 commit comments

Comments
 (0)