Mercurial > repos > public > sbplib_julia
diff test/BoundaryConditions/boundary_condition_test.jl @ 1602:3e7438e2a033 feature/boundary_conditions
Address review comments (1 left to be discussed)
author | Vidar Stiernström <vidar.stiernstrom@gmail.com> |
---|---|
date | Sat, 01 Jun 2024 17:39:54 -0700 |
parents | 330c39505a94 |
children |
line wrap: on
line diff
--- a/test/BoundaryConditions/boundary_condition_test.jl Wed May 29 23:28:33 2024 +0200 +++ b/test/BoundaryConditions/boundary_condition_test.jl Sat Jun 01 17:39:54 2024 -0700 @@ -2,6 +2,7 @@ using Sbplib.BoundaryConditions using Sbplib.Grids +using Sbplib.RegionIndices @testset "BoundaryCondition" begin grid_1d = equidistant_grid(0.0, 1.0, 11) @@ -13,13 +14,28 @@ g = 3.14 f(x,y,z) = x^2+y^2+z^2 - @test DirichletCondition(g,id_l) isa BoundaryCondition{Float64} - @test DirichletCondition(g,id_n) isa BoundaryCondition{Float64} - @test NeumannCondition(f,id_b) isa BoundaryCondition{<:Function} + @testset "Constructors" begin + @test DirichletCondition(g,id_l) isa BoundaryCondition{Lower} + @test DirichletCondition(g,id_n) isa BoundaryCondition{CartesianBoundary{2,Upper}} + @test DirichletCondition(g,id_l) isa DirichletCondition{Float64,Lower} + @test NeumannCondition(f,id_b) isa NeumannCondition{<:Function} + end + + @testset "boundary" begin + @test boundary(DirichletCondition(g,id_l)) == id_l + @test boundary(NeumannCondition(f,id_b)) == id_b + end - @test fill(g) ≈ discretize_data(grid_1d,DirichletCondition(g,id_l)) - @test g*ones(11,1) ≈ discretize_data(grid_2d,DirichletCondition(g,id_n)) - X = repeat(0:1/10:1, inner = (1,15)) - Y = repeat(0:1/14:1, outer = (1,11)) - @test map((x,y)->f(x,y,0), X,Y') ≈ discretize_data(grid_3d,NeumannCondition(f,id_b)) + @testset "boundary_data" begin + @test boundary_data(DirichletCondition(g,id_l)) == g + @test boundary_data(NeumannCondition(f,id_b)) == f + end + + @testset "discretize_data" begin + @test fill(g) ≈ discretize_data(grid_1d,DirichletCondition(g,id_l)) + @test g*ones(11,1) ≈ discretize_data(grid_2d,DirichletCondition(g,id_n)) + X = repeat(0:1/10:1, inner = (1,15)) + Y = repeat(0:1/14:1, outer = (1,11)) + @test map((x,y)->f(x,y,0), X,Y') ≈ discretize_data(grid_3d,NeumannCondition(f,id_b)) + end end