Skip to content

Commit

Permalink
fix CI?
Browse files Browse the repository at this point in the history
  • Loading branch information
albert-de-montserrat committed Jul 4, 2024
1 parent 8da35ee commit dc8d170
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 39 deletions.
6 changes: 5 additions & 1 deletion src/boundaryconditions/BoundaryConditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ end
function _flow_bcs!(bcs, V)
n = bc_index(V)
# no slip boundary conditions
do_bc(bcs.no_slip) && (@parallel (@idx n) no_slip!(V..., bcs.no_slip))
# do_bc(bcs.no_slip) && (@parallel (@idx n) no_slip!(V..., bcs.no_slip))
if do_bc(bcs.no_slip)
@parallel (@idx n) no_slip1!(V..., bcs.no_slip)
@parallel (@idx n) no_slip2!(V..., bcs.no_slip)
end
# free slip boundary conditions
do_bc(bcs.free_slip) && (@parallel (@idx n) free_slip!(V..., bcs.free_slip))

Expand Down
35 changes: 25 additions & 10 deletions src/boundaryconditions/no_slip.jl
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
@parallel_indices (i) function no_slip!(Ax, Ay, bc)
@parallel_indices (i) function no_slip1!(Ax, Ay, bc)
@inbounds begin
if bc.left
(i size(Ax, 2)) && (Ax[1, i] = 0.0)
(1 < i < size(Ay, 2)) && (Ay[1, i] = -Ay[2, i])
end
if bc.right
(i size(Ax, 2)) && (Ax[end, i] = 0.0)
(1 < i < size(Ay, 2)) && (Ay[end, i] = -Ay[end - 1, i])
end
if bc.bot
(i size(Ay, 1)) && (Ay[i, 1] = 0.0)
(1 < i < size(Ax, 1)) && (Ax[i, 1] = -Ax[i, 2])
end
if bc.top
(i size(Ay, 1)) && (Ay[i, end] = 0.0)
(1 < i < size(Ax, 1)) && (Ax[i, end] = -Ax[i, end - 1])
end
# corners
# bc.bot && (Ax[1, 1] = 0.0; Ax[1, 1] = 0.0)
# bc.left && bc.bot && (Ax[1, 1] = 0.0)
# bc.right && bc.top && (Ay[end, end] = 0.0)
end
return nothing
end

@parallel_indices (i, j) function no_slip!(Ax, Ay, Az, bc)
@parallel_indices (i) function no_slip2!(Ax, Ay, bc)
@inbounds begin
if bc.left
(i size(Ax, 2)) && (Ax[1, i] = 0.0)
end
if bc.right
(i size(Ax, 2)) && (Ax[end, i] = 0.0)
end
if bc.bot
(i size(Ay, 1)) && (Ay[i, 1] = 0.0)
end
if bc.top
(i size(Ay, 1)) && (Ay[i, end] = 0.0)
end
end
return nothing
end

@parallel_indices (i, j) function no_slip1!(Ax, Ay, Az, bc)
@inbounds begin
if bc.left
(1 size(Ay, 2)) && (1 size(Ay, 3)) && (Ay[1, i, j] = -Ay[2, i, j])
Expand Down Expand Up @@ -52,7 +62,12 @@ end
(1 size(Ax, 1)) && (1 size(Ax, 2)) && (Ax[i, j, end] = -Ax[i, j, end - 1])
(1 size(Ay, 1)) && (1 size(Ay, 2)) && (Ay[i, j, end] = -Ay[i, j, end - 1])
end
end
return nothing
end

@parallel_indices (i, j) function no_slip2!(Ax, Ay, Az, bc)
@inbounds begin
##
if bc.left
(i size(Ax, 2)) && (j size(Ax, 3)) && (Ax[1, i, j] = 0.0)
Expand Down
56 changes: 28 additions & 28 deletions test/test_boundary_conditions3D.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
ENV["JULIA_JUSTRELAX_BACKEND"] = "CPU"
@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
end

using JustRelax, JustRelax.JustRelax3D
using Test, Suppressor
using Test#, Suppressor

const backend = @static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
AMDGPUBackend
Expand Down Expand Up @@ -40,18 +41,18 @@ end
flow_bcs!(stokes, flow_bcs)
flow_bcs!(stokes, flow_bcs) # just a trick to pass the CI

@test @views stokes.V.Vx[ :, :, 1] == stokes.V.Vx[:, :, 2]
@test @views stokes.V.Vx[ :, :, end] == stokes.V.Vx[:, :, end - 1]
@test @views stokes.V.Vx[ :, 1, :] == stokes.V.Vx[:, 2, :]
@test @views stokes.V.Vx[ :, end, :] == stokes.V.Vx[:, end - 1, :]
@test @views stokes.V.Vy[ :, :, 1] == stokes.V.Vy[:, :, 2]
@test @views stokes.V.Vy[ :, :, end] == stokes.V.Vy[:, :, end - 1]
@test @views stokes.V.Vy[ 1, :, :] == stokes.V.Vy[2, :, :]
@test @views stokes.V.Vy[end, :, :] == stokes.V.Vy[end - 1, :, :]
@test @views stokes.V.Vz[ 1, :, :] == stokes.V.Vz[2, :, :]
@test @views stokes.V.Vz[end, :, :] == stokes.V.Vz[end - 1, :, :]
@test @views stokes.V.Vz[ :, 1, :] == stokes.V.Vz[:, 2, :]
@test @views stokes.V.Vz[ :, end, :] == stokes.V.Vz[:, end - 1, :]
@test stokes.V.Vx[ :, :, 1] == stokes.V.Vx[:, :, 2]
@test stokes.V.Vx[ :, :, end] == stokes.V.Vx[:, :, end - 1]
@test stokes.V.Vx[ :, 1, :] == stokes.V.Vx[:, 2, :]
@test stokes.V.Vx[ :, end, :] == stokes.V.Vx[:, end - 1, :]
@test stokes.V.Vy[ :, :, 1] == stokes.V.Vy[:, :, 2]
@test stokes.V.Vy[ :, :, end] == stokes.V.Vy[:, :, end - 1]
@test stokes.V.Vy[ 1, :, :] == stokes.V.Vy[2, :, :]
@test stokes.V.Vy[end, :, :] == stokes.V.Vy[end - 1, :, :]
@test stokes.V.Vz[ 1, :, :] == stokes.V.Vz[2, :, :]
@test stokes.V.Vz[end, :, :] == stokes.V.Vz[end - 1, :, :]
@test stokes.V.Vz[ :, 1, :] == stokes.V.Vz[:, 2, :]
@test stokes.V.Vz[ :, end, :] == stokes.V.Vz[:, end - 1, :]

# no-slip
flow_bcs = FlowBoundaryConditions(;
Expand All @@ -64,24 +65,23 @@ end

@test sum(!iszero(Vx[1 , i, j]) for i in axes(Vx,2), j in axes(Vx,3)) == 0
@test sum(!iszero(Vx[end, i, j]) for i in axes(Vx,2), j in axes(Vx,3)) == 0
@test sum(!iszero(Vy[i, 1, j]) for i in axes(Vy,1), j in axes(Vy,3)) == 0
@test sum(!iszero(Vy[i, end, j]) for i in axes(Vy,1), j in axes(Vy,3)) == 0
@test sum(!iszero(Vy[i, 1, j]) for i in axes(Vy,1), j in axes(Vy,2)) == 0
@test sum(!iszero(Vy[i, end, j]) for i in axes(Vy,1), j in axes(Vy,2)) == 0
@test sum(!iszero(Vz[i, j, 1]) for i in axes(Vz,1), j in axes(Vz,3)) == 0
@test sum(!iszero(Vz[i, j, end]) for i in axes(Vz,1), j in axes(Vz,3)) == 0


@test @views Vx[:, 1, :] == -Vx[:, 2, :]
@test @views Vx[:, end, :] == -Vx[:, end - 1, :]
@test @views Vx[:, :, 1] == -Vx[:, :, 2]
@test @views Vx[:, :, end] == -Vx[:, :, end - 1]
@test @views Vy[1 , :, :] == -Vy[2 , :, :]
@test @views Vy[end , :, :] == -Vy[end - 1, :, :]
@test @views Vy[:, :, 1] == -Vy[:, :, 2]
@test @views Vy[:, :, end] == -Vy[:, :, end - 1]
@test @views Vz[:, 1, :] == -Vz[:, 2, :]
@test @views Vz[:, end, :] == -Vz[:, end - 1, :]
@test @views Vz[ 1, :, :] == -Vz[ 2, :, :]
@test @views Vz[ end, :, :] == -Vz[end - 1, :, :]
@test Vx[:, 1, :][:, 2:end-1] == -Vx[:, 2, :][:, 2:end-1]
@test Vx[:, end, :][:, 2:end-1] == -Vx[:, end - 1, :][:, 2:end-1]
@test Vx[:, :, 1][:, 2:end-1] == -Vx[:, :, 2][:, 2:end-1]
@test Vx[:, :, end][:, 2:end-1] == -Vx[:, :, end - 1][:, 2:end-1]
@test Vy[1 , :, :][:, 2:end-1] == -Vy[2 , :, :][:, 2:end-1]
@test Vy[end , :, :][:, 2:end-1] == -Vy[end - 1, :, :][:, 2:end-1]
@test Vy[:, :, 1][2:end-1, :] == -Vy[:, :, 2][2:end-1, :]
@test Vy[:, :, end][2:end-1, :] == -Vy[:, :, end - 1][2:end-1, :]
@test Vz[:, 1, :][2:end-1, :] == -Vz[:, 2, :][2:end-1, :]
@test Vz[:, end, :][:, 2:end-1] == -Vz[:, end - 1, :][:, 2:end-1]
@test Vz[ 1, :, :][2:end-1, :] == -Vz[ 2, :, :][2:end-1, :]
@test Vz[ end, :, :][:, 2:end-1] == -Vz[end - 1, :, :][:, 2:end-1]
end
else
@test true === true
Expand Down

0 comments on commit dc8d170

Please sign in to comment.