55 lines
2.5 KiB
Julia
55 lines
2.5 KiB
Julia
@testset "Boundary.jl" begin
|
|
@testset "BoundaryElement" begin
|
|
be = TUG.BoundaryElement{Float64}()
|
|
@test TUG.getType(be) == TUG.CLOSED
|
|
@test TUG.getValue(be) == -1.0
|
|
|
|
be = TUG.BoundaryElement{Float64}(1.0)
|
|
@test TUG.getType(be) == TUG.CONSTANT
|
|
@test TUG.getValue(be) == 1.0
|
|
@test TUG.getValue([be]) == [1.0]
|
|
|
|
@test_throws ArgumentError TUG.BoundaryElement{Float64}(-1.0)
|
|
end
|
|
|
|
@testset "Boundary" begin
|
|
grid = TUG.Grid{Float64}(25, 20, zeros(25, 20), ones(25, 20))
|
|
boundary = TUG.Boundary(grid)
|
|
|
|
@test boundary.dim == 2
|
|
@test boundary.rows == 25
|
|
@test boundary.cols == 20
|
|
|
|
@test TUG.getBoundaryElementType(boundary, TUG.LEFT, 1) == TUG.CLOSED
|
|
@test TUG.getBoundaryElementType(boundary, TUG.RIGHT, 1) == TUG.CLOSED
|
|
@test TUG.getBoundaryElementType(boundary, TUG.TOP, 1) == TUG.CLOSED
|
|
@test TUG.getBoundaryElementType(boundary, TUG.BOTTOM, 1) == TUG.CLOSED
|
|
|
|
@test_throws ArgumentError TUG.getBoundaryElementType(boundary, TUG.LEFT, -1)
|
|
@test_throws ArgumentError TUG.getBoundaryElementType(boundary, TUG.RIGHT, 26)
|
|
|
|
@test TUG.getBoundaryElementValue(boundary, TUG.LEFT, 1) == -1.0
|
|
@test TUG.getBoundaryElementValue(boundary, TUG.RIGHT, 1) == -1.0
|
|
@test TUG.getBoundaryElementValue(boundary, TUG.TOP, 1) == -1.0
|
|
@test TUG.getBoundaryElementValue(boundary, TUG.BOTTOM, 1) == -1.0
|
|
|
|
@test_throws ArgumentError TUG.getBoundaryElementValue(boundary, TUG.BOTTOM, -1)
|
|
@test_throws ArgumentError TUG.getBoundaryElementValue(boundary, TUG.TOP, 21)
|
|
|
|
TUG.setBoundarySideClosed!(boundary, TUG.LEFT)
|
|
TUG.setBoundarySideConstant!(boundary, TUG.RIGHT, 1.0)
|
|
TUG.setBoundarySideConstant!(boundary, TUG.TOP, 2.0)
|
|
TUG.setBoundarySideConstant!(boundary, TUG.BOTTOM, 3.0)
|
|
|
|
@test TUG.getBoundaryElementType(boundary, TUG.LEFT, 1) == TUG.CLOSED
|
|
@test TUG.getBoundaryElementType(boundary, TUG.RIGHT, 1) == TUG.CONSTANT
|
|
@test TUG.getBoundaryElementType(boundary, TUG.TOP, 5) == TUG.CONSTANT
|
|
@test TUG.getBoundaryElementType(boundary, TUG.BOTTOM, 20) == TUG.CONSTANT
|
|
|
|
@test all(TUG.getValue(TUG.getBoundarySide(boundary, TUG.LEFT)) .== -1.0)
|
|
@test all(TUG.getValue(TUG.getBoundarySide(boundary, TUG.RIGHT)) .== 1.0)
|
|
@test all(TUG.getValue(TUG.getBoundarySide(boundary, TUG.TOP)) .== 2.0)
|
|
@test all(TUG.getValue(TUG.getBoundarySide(boundary, TUG.BOTTOM)) .== 3.0)
|
|
end
|
|
end
|