WIP
This commit is contained in:
parent
3973eabd9b
commit
72f9bd2c43
@ -1,4 +1,5 @@
|
|||||||
using DelimitedFiles
|
using DelimitedFiles
|
||||||
|
using Plots
|
||||||
|
|
||||||
# Solves the Eikonal equation using the Fast Sweeping Method
|
# Solves the Eikonal equation using the Fast Sweeping Method
|
||||||
# Input is in file with name stored in source
|
# 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
|
U = ones(ni+2, nj+2) * Inf
|
||||||
initialize!(F, U, ni, nj, source)
|
initialize!(F, U, ni, nj, source)
|
||||||
maxerr = 1
|
maxerr = 1
|
||||||
|
iters = 0
|
||||||
while maxerr > tol
|
while maxerr > tol
|
||||||
maxerr = 0
|
maxerr = 0
|
||||||
maxerr = sweep!(U, ni+1, 2, 2, nj+1, F, h, maxerr) # North-East
|
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, 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, nj+1, 2, F, h, maxerr) # South-West
|
||||||
maxerr = sweep!(U, 2, ni+1, 2, nj+1, F, h, maxerr) # South-East
|
maxerr = sweep!(U, 2, ni+1, 2, nj+1, F, h, maxerr) # South-East
|
||||||
|
iters += 1
|
||||||
end
|
end
|
||||||
U[2:ni+1, 2:nj+1]
|
# U[2:ni+1, 2:nj+1]
|
||||||
|
U
|
||||||
end
|
end
|
||||||
|
|
||||||
# Perform one set of sweeps on matrix U using directions specified in
|
# Perform one set of sweeps on matrix U using directions specified in
|
||||||
@ -93,7 +97,7 @@ function initialize!(F, U, ni, nj, source)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Call on file "ex1.txt" with the following format:
|
# 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:
|
# 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)
|
Loading…
x
Reference in New Issue
Block a user