Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
utkinis committed Oct 13, 2023
1 parent 379d9b6 commit 82b17c6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/test_bc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ using FastIce.BoundaryConditions
east_bc = FieldBoundaryConditions((field,), (DirichletBC{FullCell}(0.5),))
apply_boundary_conditions!(Val(1), Val(1), backend, grid, west_bc; async=false)
apply_boundary_conditions!(Val(2), Val(1), backend, grid, east_bc; async=false)
@test all((field[0, 1:ny, 1:nz] .+ field[1, 1:ny, 1:nz]) ./ 2 .≈ west_bc.conditions[1].condition)
@test all(field[nx+1, 1:ny, 1:nz] .≈ east_bc.conditions[1].condition)
@test all((parent(field)[1, 2:ny+1, 2:nz+1] .+ parent(field)[2, 2:ny+1, 2:nz+1]) ./ 2 .≈ west_bc.conditions[1].condition)
@test all(parent(field)[nx+2, 2:ny+1, 2:nz+1] .≈ east_bc.conditions[1].condition)
end
@testset "y-dim" begin
data(field) .= 0.0
south_bc = FieldBoundaryConditions((field,), (DirichletBC{HalfCell}(1.0),))
north_bc = FieldBoundaryConditions((field,), (DirichletBC{FullCell}(0.5),))
apply_boundary_conditions!(Val(1), Val(2), backend, grid, south_bc; async=false)
apply_boundary_conditions!(Val(2), Val(2), backend, grid, north_bc; async=false)
@test all((field[1:nx, 0, 1:nz] .+ field[1:nx, 1, 1:nz]) ./ 2 .≈ south_bc.conditions[1].condition)
@test all(field[1:nx, ny+1, 1:nz] .≈ north_bc.conditions[1].condition)
@test all((parent(field)[2:nx+1, 1, 2:nz+1] .+ parent(field)[2:nx+1, 2, 2:nz+1]) ./ 2 .≈ south_bc.conditions[1].condition)
@test all(parent(field)[2:nx+1, ny+2, 2:nz+1] .≈ north_bc.conditions[1].condition)
end
@testset "z-dim" begin
data(field) .= 0.0
bottom_bc = FieldBoundaryConditions((field,), (DirichletBC{HalfCell}(1.0),))
top_bc = FieldBoundaryConditions((field,), (DirichletBC{FullCell}(0.5),))
apply_boundary_conditions!(Val(1), Val(3), backend, grid, bottom_bc; async=false)
apply_boundary_conditions!(Val(2), Val(3), backend, grid, top_bc; async=false)
@test all((field[1:nx, 1:ny, 0] .+ field[1:nx, 1:ny, 1]) ./ 2 .≈ bottom_bc.conditions[1].condition)
@test all(field[1:nx, 1:ny, nz+1] .≈ top_bc.conditions[1].condition)
@test all((parent(field)[2:nx+1, 2:ny+1, 1] .+ parent(field)[2:nx+1, 2:ny+1, 2]) ./ 2 .≈ bottom_bc.conditions[1].condition)
@test all(parent(field)[2:nx+1, 2:ny+1, nz+2] .≈ top_bc.conditions[1].condition)
end
end
@testset "array" begin
Expand All @@ -49,8 +49,8 @@ using FastIce.BoundaryConditions
east_bc = FieldBoundaryConditions((field,), (DirichletBC{FullCell}(bc_array_east),))
apply_boundary_conditions!(Val(1), Val(1), backend, grid, west_bc; async=false)
apply_boundary_conditions!(Val(2), Val(1), backend, grid, east_bc; async=false)
@test all((field[0, 1:ny, 1:nz] .+ field[1, 1:ny, 1:nz]) ./ 2 .≈ west_bc.conditions[1].condition)
@test all(field[nx+1, 1:ny, 1:nz] .≈ east_bc.conditions[1].condition)
@test all((parent(field)[1, 2:ny+1, 2:nz+1] .+ parent(field)[2, 2:ny+1, 2:nz+1]) ./ 2 .≈ west_bc.conditions[1].condition)
@test all(parent(field)[nx+2, 2:ny+1, 2:nz+1] .≈ east_bc.conditions[1].condition)
end
@testset "y-dim" begin
data(field) .= 0.0
Expand All @@ -62,8 +62,8 @@ using FastIce.BoundaryConditions
north_bc = FieldBoundaryConditions((field,), (DirichletBC{FullCell}(bc_array_north),))
apply_boundary_conditions!(Val(1), Val(2), backend, grid, south_bc; async=false)
apply_boundary_conditions!(Val(2), Val(2), backend, grid, north_bc; async=false)
@test all((field[1:nx, 0, 1:nz] .+ field[1:nx, 1, 1:nz]) ./ 2 .≈ south_bc.conditions[1].condition)
@test all(field[1:nx, ny+1, 1:nz] .≈ north_bc.conditions[1].condition)
@test all((parent(field)[2:nx+1, 1, 2:nz+1] .+ parent(field)[2:nx+1, 2, 2:nz+1]) ./ 2 .≈ south_bc.conditions[1].condition)
@test all(parent(field)[2:nx+1, ny+2, 2:nz+1] .≈ north_bc.conditions[1].condition)
end
@testset "z-dim" begin
data(field) .= 0.0
Expand All @@ -75,8 +75,8 @@ using FastIce.BoundaryConditions
top_bc = FieldBoundaryConditions((field,), (DirichletBC{FullCell}(bc_array_top),))
apply_boundary_conditions!(Val(1), Val(3), backend, grid, bottom_bc; async=false)
apply_boundary_conditions!(Val(2), Val(3), backend, grid, top_bc; async=false)
@test all((field[1:nx, 1:ny, 0] .+ field[1:nx, 1:ny, 1]) ./ 2 .≈ bottom_bc.conditions[1].condition)
@test all(field[1:nx, 1:ny, nz+1] .≈ top_bc.conditions[1].condition)
@test all((parent(field)[2:nx+1, 2:ny+1, 1] .+ parent(field)[2:nx+1, 2:ny+1, 2]) ./ 2 .≈ bottom_bc.conditions[1].condition)
@test all(parent(field)[2:nx+1, 2:ny+1, nz+2] .≈ top_bc.conditions[1].condition)
end
end
end
Expand Down

0 comments on commit 82b17c6

Please sign in to comment.