Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"
[extensions]
WaterLilyAMDGPUExt = "AMDGPU"
WaterLilyCUDAExt = "CUDA"
WaterLilyMakieExt = "Makie"
WaterLilyJLD2Ext = "JLD2"
WaterLilyMakieExt = "Makie"
WaterLilyMeshingExt = ["Makie", "Meshing"]
WaterLilyPlotsExt = "Plots"
WaterLilyReadVTKExt = "ReadVTK"
Expand All @@ -55,7 +55,10 @@ julia = "1.10"
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Expand All @@ -68,4 +71,17 @@ UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"

[targets]
test = ["Test", "BenchmarkTools", "CUDA", "AMDGPU", "GPUArrays", "WriteVTK", "ReadVTK", "JLD2"]
test = [
"AMDGPU",
"BenchmarkTools",
"CUDA",
"FileIO",
"GPUArrays",
"ImageMagick",
"ImageCore",
"JLD2",
"Plots",
"ReadVTK",
"Test",
"WriteVTK",
]
Binary file added test/compdata/compLogPlot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/compdata/compbody.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/compdata/compgif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/compdata/floodTestNoLims.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/compdata/floodTestWithLims.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 82 additions & 2 deletions test/maintests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using GPUArrays
using ReadVTK, WriteVTK, JLD2
using ReadVTK, WriteVTK, JLD2, Plots
using FileIO, ImageMagick, ImageCore

backend != "KernelAbstractions" && throw(ArgumentError("SIMD backend not allowed to run main tests, use KernelAbstractions backend"))
WaterLily.backend != "KernelAbstractions" && throw(ArgumentError("SIMD backend not allowed to run main tests, use KernelAbstractions backend"))
@info "Test backends: $(join(arrays,", "))"
@testset "util.jl" begin
I = CartesianIndex(1,2,3,4)
Expand Down Expand Up @@ -605,6 +606,7 @@ end
end
@test_nowarn rm(test_dir, recursive=true)
end

@testset "RigidMap.jl" begin
for T ∈ (Float32,Float64)
# initialize a rigid body
Expand Down Expand Up @@ -658,4 +660,82 @@ end
rmap = RigidMap(SA[0.,0.],π/4)
body = AutoBody((x,t)->√(x'x)-1,rmap)-AutoBody((x,t)->√(x'x)-0.5,rmap) # annulus
@test all(measure(setmap(body,ω=1.),SA[0.25,0.],0) .≈ (0.25,SA[-1,0],SA[0,0.25]))
end

make_egg_noarray(ra=40,rb=20, U=1) = Simulation((5*ra,5*rb),(U,0), rb;
body=AutoBody((x,t)->√sum((x[1]-8)^2/ra+(x[2]-8)^2/rb)-1))

@testset "WaterLilyPlotsExt.jl" begin
Plots.plot(); # reset the plot

# make a simulation
sim = make_egg_noarray();

# make a body plot of the simulation setup
test = body_plot!(sim)
Plots.savefig(test, "temp.png")
test = load("temp.png")

# compare output and do cleanup
comp = load("compdata/compbody.png")
@test abs(maximum(channelview(test)-channelview(comp))) < 1
rm("temp.png")

Plots.plot(); # reset the plot

# make a simulation
sim = make_egg_noarray();

# make a gif of the simulation
testgif = sim_gif!(sim,duration=0.5, clims=(-5,5),plotbody=true)
fn = testgif.filename
testgif = load(fn)

# compare output and do cleanup
compgif = load("compdata/compgif.gif")
@test abs(maximum(channelview(testgif)-channelview(compgif))) < 1
rm(fn)

Plots.plot(); # reset the plot

# make a 2d plot with flood
xr = -1:0.01:1
yr = -1:0.01:1
g(x,y) = x^2/2 + y^2/3
flood(g.(xr,yr'))

# compare output and do cleanup
Plots.savefig("temp.png")
comp = load("compdata/floodTestNoLims.png")
test = load("temp.png")
@test abs(maximum(channelview(test)-channelview(comp))) < 1
rm("temp.png")

Plots.plot(); # reset the plot

flood(g.(xr,yr'), clims = (0.00,0.01))
Plots.savefig("temp.png")

# compare output and do cleanup
comp = load("compdata/floodTestWithLims.png")
test = load("temp.png")
@test abs(maximum(channelview(test)-channelview(comp))) < 1
rm("temp.png")

Plots.plot(); # reset the plot

# make a simulation
sim = make_egg_noarray();

# make a plot of the simulation log
WaterLily.logger("testLog") # Log the residual of pressure solver
sim_step!(sim, 0.5) # Run the simulation
plot_logger("testLog.log")
Plots.savefig("testLogPlot.png")

# compare output and do cleanup
comp = load("compdata/compLogPlot.png")
test = load("testLogPlot.png")
@test abs(maximum(channelview(test)-channelview(comp))) < 1
rm("testLogPlot.png")
end
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ function setup_backends()
end

arrays = setup_backends()
Threads.nthreads() > 1 ? include("maintests.jl") : include("alloctest.jl")
Threads.nthreads() > 1 ? include("maintests.jl") : include("alloctest.jl")