comparison test/SbpOperators/boundaryops/boundary_operator_test.jl @ 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 f1bb1b6d85dd
comparison
equal deleted inserted replaced
1107:f80e69b0566b 1108:6b24dc2d7b11
12 closure_stencil = Stencil(2.,1.,3.; center = 1) 12 closure_stencil = Stencil(2.,1.,3.; center = 1)
13 g_1D = EquidistantGrid(11, 0.0, 1.0) 13 g_1D = EquidistantGrid(11, 0.0, 1.0)
14 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0)) 14 g_2D = EquidistantGrid((11,15), (0.0, 0.0), (1.0,1.0))
15 15
16 @testset "Constructors" begin 16 @testset "Constructors" begin
17 @testset "1D" begin # TODO: Remove these testsets 17 op_l = BoundaryOperator{Lower}(closure_stencil,size(g_1D)[1])
18 op_l = BoundaryOperator{Lower}(closure_stencil,size(g_1D)[1]) 18 @test op_l == BoundaryOperator(g_1D,closure_stencil,Lower())
19 @test op_l == BoundaryOperator(g_1D,closure_stencil,Lower()) 19 @test op_l isa LazyTensor{T,0,1} where T
20 @test op_l isa LazyTensor{T,0,1} where T
21 20
22 op_r = BoundaryOperator{Upper}(closure_stencil,size(g_1D)[1]) # TBD: Is this constructor really needed? looks weird! 21 op_r = BoundaryOperator{Upper}(closure_stencil,size(g_1D)[1])
23 @test op_r == BoundaryOperator(g_1D,closure_stencil,Upper()) 22 @test op_r == BoundaryOperator(g_1D,closure_stencil,Upper())
24 @test op_r isa LazyTensor{T,0,1} where T 23 @test op_r isa LazyTensor{T,0,1} where T
25 end
26 end 24 end
27 25
28 op_l = BoundaryOperator(g_1D, closure_stencil, Lower()) 26 op_l = BoundaryOperator(g_1D, closure_stencil, Lower())
29 op_r = BoundaryOperator(g_1D, closure_stencil, Upper()) 27 op_r = BoundaryOperator(g_1D, closure_stencil, Upper())
30 28
31 @testset "Sizes" begin 29 @testset "Sizes" begin
32 @testset "1D" begin 30 @test domain_size(op_l) == (11,)
33 @test domain_size(op_l) == (11,) 31 @test domain_size(op_r) == (11,)
34 @test domain_size(op_r) == (11,)
35 32
36 @test range_size(op_l) == () 33 @test range_size(op_l) == ()
37 @test range_size(op_r) == () 34 @test range_size(op_r) == ()
38 end
39 end 35 end
40 36
41 @testset "Application" begin 37 @testset "Application" begin
42 @testset "1D" begin 38 v = evalOn(g_1D,x->1+x^2)
43 v = evalOn(g_1D,x->1+x^2) 39 u = fill(3.124)
44 u = fill(3.124) 40 @test (op_l*v)[] == 2*v[1] + v[2] + 3*v[3]
45 @test (op_l*v)[] == 2*v[1] + v[2] + 3*v[3] 41 @test (op_r*v)[] == 2*v[end] + v[end-1] + 3*v[end-2]
46 @test (op_r*v)[] == 2*v[end] + v[end-1] + 3*v[end-2] 42 @test (op_r*v)[1] == 2*v[end] + v[end-1] + 3*v[end-2]
47 @test (op_r*v)[1] == 2*v[end] + v[end-1] + 3*v[end-2] 43 @test op_l'*u == [2*u[]; u[]; 3*u[]; zeros(8)]
48 @test op_l'*u == [2*u[]; u[]; 3*u[]; zeros(8)] 44 @test op_r'*u == [zeros(8); 3*u[]; u[]; 2*u[]]
49 @test op_r'*u == [zeros(8); 3*u[]; u[]; 2*u[]]
50 45
51 v = evalOn(g_1D, x->1. +x*im) 46 v = evalOn(g_1D, x->1. +x*im)
52 @test (op_l*v)[] isa ComplexF64 47 @test (op_l*v)[] isa ComplexF64
53 48
54 u = fill(1. +im) 49 u = fill(1. +im)
55 @test (op_l'*u)[1] isa ComplexF64 50 @test (op_l'*u)[1] isa ComplexF64
56 @test (op_l'*u)[5] isa ComplexF64 51 @test (op_l'*u)[5] isa ComplexF64
57 @test (op_l'*u)[11] isa ComplexF64 52 @test (op_l'*u)[11] isa ComplexF64
58 end
59 53
60 @testset "Regions" begin 54 u = fill(3.124)
61 u = fill(3.124) 55 @test (op_l'*u)[Index(1,Lower)] == 2*u[]
62 @test (op_l'*u)[Index(1,Lower)] == 2*u[] 56 @test (op_l'*u)[Index(2,Lower)] == u[]
63 @test (op_l'*u)[Index(2,Lower)] == u[] 57 @test (op_l'*u)[Index(6,Interior)] == 0
64 @test (op_l'*u)[Index(6,Interior)] == 0 58 @test (op_l'*u)[Index(10,Upper)] == 0
65 @test (op_l'*u)[Index(10,Upper)] == 0 59 @test (op_l'*u)[Index(11,Upper)] == 0
66 @test (op_l'*u)[Index(11,Upper)] == 0
67 60
68 @test (op_r'*u)[Index(1,Lower)] == 0 61 @test (op_r'*u)[Index(1,Lower)] == 0
69 @test (op_r'*u)[Index(2,Lower)] == 0 62 @test (op_r'*u)[Index(2,Lower)] == 0
70 @test (op_r'*u)[Index(6,Interior)] == 0 63 @test (op_r'*u)[Index(6,Interior)] == 0
71 @test (op_r'*u)[Index(10,Upper)] == u[] 64 @test (op_r'*u)[Index(10,Upper)] == u[]
72 @test (op_r'*u)[Index(11,Upper)] == 2*u[] 65 @test (op_r'*u)[Index(11,Upper)] == 2*u[]
73 end
74 end 66 end
75 67
76 @testset "Inferred" begin 68 @testset "Inferred" begin
77 v = ones(Float64, 11) 69 v = ones(Float64, 11)
78 u = fill(1.) 70 u = fill(1.)