Mercurial > repos > public > sbplib_julia
changeset 1108:6b24dc2d7b11 refactor/sbpoperators/inflation
Clean up testsets in boundary_operator_test
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 09 Jun 2022 07:30:20 +0200 |
parents | f80e69b0566b |
children | 69c635e1d346 |
files | src/SbpOperators/boundaryops/boundary_operator.jl test/SbpOperators/boundaryops/boundary_operator_test.jl |
diffstat | 2 files changed, 35 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/src/SbpOperators/boundaryops/boundary_operator.jl Thu Jun 09 07:24:11 2022 +0200 +++ b/src/SbpOperators/boundaryops/boundary_operator.jl Thu Jun 09 07:30:20 2022 +0200 @@ -13,6 +13,7 @@ end BoundaryOperator{R}(stencil::Stencil{T,N}, size::Int) where {T,R,N} = BoundaryOperator{T,R,N}(stencil, size) +# TBD: Will the above convenience constructor ever be used? """ BoundaryOperator(grid::EquidistantGrid{1}, closure_stencil, region)
--- a/test/SbpOperators/boundaryops/boundary_operator_test.jl Thu Jun 09 07:24:11 2022 +0200 +++ b/test/SbpOperators/boundaryops/boundary_operator_test.jl Thu Jun 09 07:30:20 2022 +0200 @@ -14,63 +14,55 @@ g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) @testset "Constructors" begin - @testset "1D" begin # TODO: Remove these testsets - op_l = BoundaryOperator{Lower}(closure_stencil,size(g_1D)[1]) - @test op_l == BoundaryOperator(g_1D,closure_stencil,Lower()) - @test op_l isa LazyTensor{T,0,1} where T + op_l = BoundaryOperator{Lower}(closure_stencil,size(g_1D)[1]) + @test op_l == BoundaryOperator(g_1D,closure_stencil,Lower()) + @test op_l isa LazyTensor{T,0,1} where T - op_r = BoundaryOperator{Upper}(closure_stencil,size(g_1D)[1]) # TBD: Is this constructor really needed? looks weird! - @test op_r == BoundaryOperator(g_1D,closure_stencil,Upper()) - @test op_r isa LazyTensor{T,0,1} where T - end + op_r = BoundaryOperator{Upper}(closure_stencil,size(g_1D)[1]) + @test op_r == BoundaryOperator(g_1D,closure_stencil,Upper()) + @test op_r isa LazyTensor{T,0,1} where T end op_l = BoundaryOperator(g_1D, closure_stencil, Lower()) op_r = BoundaryOperator(g_1D, closure_stencil, Upper()) @testset "Sizes" begin - @testset "1D" begin - @test domain_size(op_l) == (11,) - @test domain_size(op_r) == (11,) + @test domain_size(op_l) == (11,) + @test domain_size(op_r) == (11,) - @test range_size(op_l) == () - @test range_size(op_r) == () - end + @test range_size(op_l) == () + @test range_size(op_r) == () end @testset "Application" begin - @testset "1D" begin - v = evalOn(g_1D,x->1+x^2) - u = fill(3.124) - @test (op_l*v)[] == 2*v[1] + v[2] + 3*v[3] - @test (op_r*v)[] == 2*v[end] + v[end-1] + 3*v[end-2] - @test (op_r*v)[1] == 2*v[end] + v[end-1] + 3*v[end-2] - @test op_l'*u == [2*u[]; u[]; 3*u[]; zeros(8)] - @test op_r'*u == [zeros(8); 3*u[]; u[]; 2*u[]] + v = evalOn(g_1D,x->1+x^2) + u = fill(3.124) + @test (op_l*v)[] == 2*v[1] + v[2] + 3*v[3] + @test (op_r*v)[] == 2*v[end] + v[end-1] + 3*v[end-2] + @test (op_r*v)[1] == 2*v[end] + v[end-1] + 3*v[end-2] + @test op_l'*u == [2*u[]; u[]; 3*u[]; zeros(8)] + @test op_r'*u == [zeros(8); 3*u[]; u[]; 2*u[]] - v = evalOn(g_1D, x->1. +x*im) - @test (op_l*v)[] isa ComplexF64 + v = evalOn(g_1D, x->1. +x*im) + @test (op_l*v)[] isa ComplexF64 - u = fill(1. +im) - @test (op_l'*u)[1] isa ComplexF64 - @test (op_l'*u)[5] isa ComplexF64 - @test (op_l'*u)[11] isa ComplexF64 - end + u = fill(1. +im) + @test (op_l'*u)[1] isa ComplexF64 + @test (op_l'*u)[5] isa ComplexF64 + @test (op_l'*u)[11] isa ComplexF64 - @testset "Regions" begin - u = fill(3.124) - @test (op_l'*u)[Index(1,Lower)] == 2*u[] - @test (op_l'*u)[Index(2,Lower)] == u[] - @test (op_l'*u)[Index(6,Interior)] == 0 - @test (op_l'*u)[Index(10,Upper)] == 0 - @test (op_l'*u)[Index(11,Upper)] == 0 + u = fill(3.124) + @test (op_l'*u)[Index(1,Lower)] == 2*u[] + @test (op_l'*u)[Index(2,Lower)] == u[] + @test (op_l'*u)[Index(6,Interior)] == 0 + @test (op_l'*u)[Index(10,Upper)] == 0 + @test (op_l'*u)[Index(11,Upper)] == 0 - @test (op_r'*u)[Index(1,Lower)] == 0 - @test (op_r'*u)[Index(2,Lower)] == 0 - @test (op_r'*u)[Index(6,Interior)] == 0 - @test (op_r'*u)[Index(10,Upper)] == u[] - @test (op_r'*u)[Index(11,Upper)] == 2*u[] - end + @test (op_r'*u)[Index(1,Lower)] == 0 + @test (op_r'*u)[Index(2,Lower)] == 0 + @test (op_r'*u)[Index(6,Interior)] == 0 + @test (op_r'*u)[Index(10,Upper)] == u[] + @test (op_r'*u)[Index(11,Upper)] == 2*u[] end @testset "Inferred" begin