This commit is contained in:
Isaac Shoebottom 2025-02-03 16:26:21 -04:00
parent 3973eabd9b
commit 72f9bd2c43

View File

@ -1,4 +1,5 @@
using DelimitedFiles
using Plots
# Solves the Eikonal equation using the Fast Sweeping Method
# Input is in file with name stored in source
@ -10,14 +11,17 @@ function solveEikonal(ni, nj, h, source, tol = 1E-6)
U = ones(ni+2, nj+2) * Inf
initialize!(F, U, ni, nj, source)
maxerr = 1
iters = 0
while maxerr > tol
maxerr = 0
maxerr = sweep!(U, ni+1, 2, 2, nj+1, F, h, maxerr) # North-East
maxerr = sweep!(U, ni+1, 2, nj+1, 2, F, h, maxerr) # North-West
maxerr = sweep!(U, 2, ni+1, nj+1, 2, F, h, maxerr) # South-West
maxerr = sweep!(U, 2, ni+1, 2, nj+1, F, h, maxerr) # South-East
iters += 1
end
U[2:ni+1, 2:nj+1]
# U[2:ni+1, 2:nj+1]
U
end
# Perform one set of sweeps on matrix U using directions specified in
@ -93,7 +97,7 @@ function initialize!(F, U, ni, nj, source)
end
# Call on file "ex1.txt" with the following format:
println(solveEikonal(7, 7, 1, "ex1.txt"))
display(solveEikonal(7, 7, 1, "ex1.txt"))
# Call on file "test100.txt" with the following format:
# println(solveEikonal(100, 100, 1, "test100.txt"))
heatmap(1:100, 1:100, solveEikonal(100, 100, 1, "test100.txt"), color=:gist_yarg)