Skip to content

Commit

Permalink
Move to test
Browse files Browse the repository at this point in the history
  • Loading branch information
weymouth committed Oct 12, 2023
1 parent 63b88be commit cdb354c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 47 deletions.
35 changes: 0 additions & 35 deletions Convective-Exit.jl

This file was deleted.

1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
28 changes: 17 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ arrays = setup_backends()
@test ex == :(a[I, i] = Math.add(b[I], func(I, q)))
@test sym == [:a, :I, :i, :(p.b), :q]

for f arrays
# for f ∈ arrays
for f [Array]
p = Float64[i+j for i 1:4, j 1:5] |> f
@test inside(p) == CartesianIndices((2:3,2:4))
@test L₂(p) == 187
Expand All @@ -46,14 +47,19 @@ arrays = setup_backends()
σ = rand(Ng...) |> f # scalar
BC!(u, U)
BC!(σ)
@allowscalar() do
@test all(u[1, :, 1] .== U[1]) && all(u[2, :, 1] .== U[1]) && all(u[end, :, 1] .== U[1]) &&
@allowscalar @test all(u[1, :, 1] .== U[1]) && all(u[2, :, 1] .== U[1]) && all(u[end, :, 1] .== U[1]) &&
all(u[3:end-1, 1, 1] .== u[3:end-1, 2, 1]) && all(u[3:end-1, end, 1] .== u[3:end-1, end-1, 1])
@test all(u[:, 1, 2] .== U[2]) && all(u[:, 2, 2] .== U[2]) && all(u[:, end, 2] .== U[2]) &&
@allowscalar @test all(u[:, 1, 2] .== U[2]) && all(u[:, 2, 2] .== U[2]) && all(u[:, end, 2] .== U[2]) &&
all(u[1, 3:end-1, 2] .== u[2, 3:end-1, 2]) && all(u[end, 3:end-1, 2] .== u[end-1, 3:end-1, 2])
@test all(σ[1, 2:end-1] .== σ[2, 2:end-1]) && all(σ[end, 2:end-1] .== σ[end-1, 2:end-1]) &&
@allowscalar @test all(σ[1, 2:end-1] .== σ[2, 2:end-1]) && all(σ[end, 2:end-1] .== σ[end-1, 2:end-1]) &&
all(σ[2:end-1, 1] .== σ[2:end-1, 2]) && all(σ[2:end-1, end] .== σ[2:end-1, end-1])
end

@allowscalar u[end,:,1] .= 3
BC!(u, U, true) # save exit values
@allowscalar @test all(u[end, :, 1] .== 3)

WaterLily.exitBC!(u,u,U,0) # conservative exit check
@allowscalar @test all(u[end,2:end-1, 1] .== U[1])
end
end

Expand Down Expand Up @@ -205,13 +211,13 @@ end
end
end

function sphere_sim(radius = 8; mem=Array)
body = AutoBody((x,t)-> sum(abs2,x .- 2radius) - radius)
return Simulation(radius.*(6,4),(1,0),radius; body, ν=radius/250, T=Float32, mem)
function sphere_sim(radius = 8; mem=Array, exit=false)
body = AutoBody((x,t)-> sum(abs2,x .- (2radius+1.5)) - radius)
return Simulation(radius.*(6,4),(1,0),radius; body, ν=radius/250, T=Float32, mem, exit)
end
@testset "WaterLily.jl" begin
for mem arrays
sim = sphere_sim(32;mem);
for mem arrays, exit (true,false)
sim = sphere_sim(;mem,exit);
@test sim_time(sim) == 0
sim_step!(sim,0.1,remeasure=false)
@test length(sim.flow.Δt)-1 == length(sim.pois.n)÷2
Expand Down

0 comments on commit cdb354c

Please sign in to comment.