comparison test/SbpOperators/volumeops/laplace/laplace_test.jl @ 753:fc83d672be36 feature/laplace_opset

Minor cleanup of code
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 19 Mar 2021 17:13:04 +0100
parents f94feb005e7d
children dc38e57ebd1b
comparison
equal deleted inserted replaced
752:ff0ef711c388 753:fc83d672be36
20 20
21 (id_l, id_r) = boundary_identifiers(g_1D) 21 (id_l, id_r) = boundary_identifiers(g_1D)
22 22
23 e_l = boundary_restriction(g_1D,op.eClosure,id_l) 23 e_l = boundary_restriction(g_1D,op.eClosure,id_l)
24 e_r = boundary_restriction(g_1D,op.eClosure,id_r) 24 e_r = boundary_restriction(g_1D,op.eClosure,id_r)
25 e_dict = StaticDict(Pair(id_l,e_l),Pair(id_r,e_r)) 25 e_dict = StaticDict(id_l => e_l, id_r => e_r)
26 26
27 d_l = normal_derivative(g_1D,op.dClosure,id_l) 27 d_l = normal_derivative(g_1D,op.dClosure,id_l)
28 d_r = normal_derivative(g_1D,op.dClosure,id_r) 28 d_r = normal_derivative(g_1D,op.dClosure,id_r)
29 d_dict = StaticDict(Pair(id_l,d_l),Pair(id_r,d_r)) 29 d_dict = StaticDict(id_l => d_l, id_r => d_r)
30 30
31 H_l = inner_product(boundary_grid(g_1D,id_l),op.quadratureClosure) 31 H_l = inner_product(boundary_grid(g_1D,id_l),op.quadratureClosure)
32 H_r = inner_product(boundary_grid(g_1D,id_r),op.quadratureClosure) 32 H_r = inner_product(boundary_grid(g_1D,id_r),op.quadratureClosure)
33 Hb_dict = StaticDict(Pair(id_l,H_l),Pair(id_r,H_r)) 33 Hb_dict = StaticDict(id_l => H_l, id_r => H_r)
34 34
35 L = Laplace(g_1D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 35 L = Laplace(g_1D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
36 @test L == Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict) 36 @test L == Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict)
37 @test L isa TensorMapping{T,1,1} where T 37 @test L isa TensorMapping{T,1,1} where T
38 @inferred Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict) 38 @inferred Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict)
42 Δ = laplace(g_3D, op.innerStencil, op.closureStencils) 42 Δ = laplace(g_3D, op.innerStencil, op.closureStencils)
43 H = inner_product(g_3D, op.quadratureClosure) 43 H = inner_product(g_3D, op.quadratureClosure)
44 Hi = inverse_inner_product(g_3D, op.quadratureClosure) 44 Hi = inverse_inner_product(g_3D, op.quadratureClosure)
45 45
46 (id_l, id_r, id_s, id_n, id_b, id_t) = boundary_identifiers(g_3D) 46 (id_l, id_r, id_s, id_n, id_b, id_t) = boundary_identifiers(g_3D)
47
48 e_l = boundary_restriction(g_3D,op.eClosure,id_l) 47 e_l = boundary_restriction(g_3D,op.eClosure,id_l)
49 e_r = boundary_restriction(g_3D,op.eClosure,id_r) 48 e_r = boundary_restriction(g_3D,op.eClosure,id_r)
50 e_s = boundary_restriction(g_3D,op.eClosure,id_s) 49 e_s = boundary_restriction(g_3D,op.eClosure,id_s)
51 e_n = boundary_restriction(g_3D,op.eClosure,id_n) 50 e_n = boundary_restriction(g_3D,op.eClosure,id_n)
52 e_b = boundary_restriction(g_3D,op.eClosure,id_b) 51 e_b = boundary_restriction(g_3D,op.eClosure,id_b)
53 e_t = boundary_restriction(g_3D,op.eClosure,id_t) 52 e_t = boundary_restriction(g_3D,op.eClosure,id_t)
54 e_dict = StaticDict(Pair(id_l,e_l),Pair(id_r,e_r), 53 e_dict = StaticDict(id_l => e_l, id_r => e_r,
55 Pair(id_s,e_s),Pair(id_n,e_n), 54 id_s => e_s, id_n => e_n,
56 Pair(id_b,e_b),Pair(id_t,e_t)) 55 id_b => e_b, id_t => e_t)
57 56
58 d_l = normal_derivative(g_3D,op.dClosure,id_l) 57 d_l = normal_derivative(g_3D,op.dClosure,id_l)
59 d_r = normal_derivative(g_3D,op.dClosure,id_r) 58 d_r = normal_derivative(g_3D,op.dClosure,id_r)
60 d_s = normal_derivative(g_3D,op.dClosure,id_s) 59 d_s = normal_derivative(g_3D,op.dClosure,id_s)
61 d_n = normal_derivative(g_3D,op.dClosure,id_n) 60 d_n = normal_derivative(g_3D,op.dClosure,id_n)
62 d_b = normal_derivative(g_3D,op.dClosure,id_b) 61 d_b = normal_derivative(g_3D,op.dClosure,id_b)
63 d_t = normal_derivative(g_3D,op.dClosure,id_t) 62 d_t = normal_derivative(g_3D,op.dClosure,id_t)
64 d_dict = StaticDict(Pair(id_l,d_l),Pair(id_r,d_r), 63 d_dict = StaticDict(id_l => d_l, id_r => d_r,
65 Pair(id_s,d_s),Pair(id_n,d_n), 64 id_s => d_s, id_n => d_n,
66 Pair(id_b,d_b),Pair(id_t,d_t)) 65 id_b => d_b, id_t => d_t)
67 66
68 H_l = inner_product(boundary_grid(g_3D,id_l),op.quadratureClosure) 67 H_l = inner_product(boundary_grid(g_3D,id_l),op.quadratureClosure)
69 H_r = inner_product(boundary_grid(g_3D,id_r),op.quadratureClosure) 68 H_r = inner_product(boundary_grid(g_3D,id_r),op.quadratureClosure)
70 H_s = inner_product(boundary_grid(g_3D,id_s),op.quadratureClosure) 69 H_s = inner_product(boundary_grid(g_3D,id_s),op.quadratureClosure)
71 H_n = inner_product(boundary_grid(g_3D,id_n),op.quadratureClosure) 70 H_n = inner_product(boundary_grid(g_3D,id_n),op.quadratureClosure)
72 H_b = inner_product(boundary_grid(g_3D,id_b),op.quadratureClosure) 71 H_b = inner_product(boundary_grid(g_3D,id_b),op.quadratureClosure)
73 H_t = inner_product(boundary_grid(g_3D,id_t),op.quadratureClosure) 72 H_t = inner_product(boundary_grid(g_3D,id_t),op.quadratureClosure)
74 Hb_dict = StaticDict(Pair(id_l,H_l),Pair(id_r,H_r), 73 Hb_dict = StaticDict(id_l => H_l, id_r => H_r,
75 Pair(id_s,H_s),Pair(id_n,H_n), 74 id_s => H_s, id_n => H_n,
76 Pair(id_b,H_b),Pair(id_t,H_t)) 75 id_b => H_b, id_t => H_t)
77 76
78 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 77 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
79 @test L == Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict) 78 @test L == Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict)
80 @test L isa TensorMapping{T,3,3} where T 79 @test L isa TensorMapping{T,3,3} where T
81 @inferred Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict) 80 @inferred Laplace(Δ,H,Hi,e_dict,d_dict,Hb_dict)
109 @test inverse_inner_product(L) == inverse_inner_product(g_3D,op.quadratureClosure) 108 @test inverse_inner_product(L) == inverse_inner_product(g_3D,op.quadratureClosure)
110 end 109 end
111 110
112 @testset "boundary_restriction" begin 111 @testset "boundary_restriction" begin
113 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 112 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
114 id_l = CartesianBoundary{1,Lower}() 113 (id_l, id_r, id_s, id_n, id_b, id_t) = boundary_identifiers(g_3D)
115 id_r = CartesianBoundary{1,Upper}() 114 ids = boundary_identifiers(g_3D)
116 id_s = CartesianBoundary{2,Lower}()
117 id_n = CartesianBoundary{2,Upper}()
118 id_b = CartesianBoundary{3,Lower}()
119 id_t = CartesianBoundary{3,Upper}()
120 @test boundary_restriction(L,id_l) == boundary_restriction(g_3D,op.eClosure,id_l) 115 @test boundary_restriction(L,id_l) == boundary_restriction(g_3D,op.eClosure,id_l)
121 @test boundary_restriction(L,id_r) == boundary_restriction(g_3D,op.eClosure,id_r) 116 @test boundary_restriction(L,id_r) == boundary_restriction(g_3D,op.eClosure,id_r)
122 @test boundary_restriction(L,id_s) == boundary_restriction(g_3D,op.eClosure,id_s) 117 @test boundary_restriction(L,id_s) == boundary_restriction(g_3D,op.eClosure,id_s)
123 @test boundary_restriction(L,id_n) == boundary_restriction(g_3D,op.eClosure,id_n) 118 @test boundary_restriction(L,id_n) == boundary_restriction(g_3D,op.eClosure,id_n)
124 @test boundary_restriction(L,id_b) == boundary_restriction(g_3D,op.eClosure,id_b) 119 @test boundary_restriction(L,id_b) == boundary_restriction(g_3D,op.eClosure,id_b)
125 @test boundary_restriction(L,id_t) == boundary_restriction(g_3D,op.eClosure,id_t) 120 @test boundary_restriction(L,id_t) == boundary_restriction(g_3D,op.eClosure,id_t)
126 end 121 end
127 122
128 @testset "normal_derivative" begin 123 @testset "normal_derivative" begin
129 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 124 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
130 id_l = CartesianBoundary{1,Lower}() 125 (id_l, id_r, id_s, id_n, id_b, id_t) = boundary_identifiers(g_3D)
131 id_r = CartesianBoundary{1,Upper}()
132 id_s = CartesianBoundary{2,Lower}()
133 id_n = CartesianBoundary{2,Upper}()
134 id_b = CartesianBoundary{3,Lower}()
135 id_t = CartesianBoundary{3,Upper}()
136 @test normal_derivative(L,id_l) == normal_derivative(g_3D,op.dClosure,id_l) 126 @test normal_derivative(L,id_l) == normal_derivative(g_3D,op.dClosure,id_l)
137 @test normal_derivative(L,id_r) == normal_derivative(g_3D,op.dClosure,id_r) 127 @test normal_derivative(L,id_r) == normal_derivative(g_3D,op.dClosure,id_r)
138 @test normal_derivative(L,id_s) == normal_derivative(g_3D,op.dClosure,id_s) 128 @test normal_derivative(L,id_s) == normal_derivative(g_3D,op.dClosure,id_s)
139 @test normal_derivative(L,id_n) == normal_derivative(g_3D,op.dClosure,id_n) 129 @test normal_derivative(L,id_n) == normal_derivative(g_3D,op.dClosure,id_n)
140 @test normal_derivative(L,id_b) == normal_derivative(g_3D,op.dClosure,id_b) 130 @test normal_derivative(L,id_b) == normal_derivative(g_3D,op.dClosure,id_b)
141 @test normal_derivative(L,id_t) == normal_derivative(g_3D,op.dClosure,id_t) 131 @test normal_derivative(L,id_t) == normal_derivative(g_3D,op.dClosure,id_t)
142 end 132 end
143 133
144 @testset "boundary_quadrature" begin 134 @testset "boundary_quadrature" begin
145 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4) 135 L = Laplace(g_3D, sbp_operators_path()*"standard_diagonal.toml"; order=4)
146 id_l = CartesianBoundary{1,Lower}() 136 (id_l, id_r, id_s, id_n, id_b, id_t) = boundary_identifiers(g_3D)
147 id_r = CartesianBoundary{1,Upper}()
148 id_s = CartesianBoundary{2,Lower}()
149 id_n = CartesianBoundary{2,Upper}()
150 id_b = CartesianBoundary{3,Lower}()
151 id_t = CartesianBoundary{3,Upper}()
152 @test boundary_quadrature(L,id_l) == inner_product(boundary_grid(g_3D,id_l),op.quadratureClosure) 137 @test boundary_quadrature(L,id_l) == inner_product(boundary_grid(g_3D,id_l),op.quadratureClosure)
153 @test boundary_quadrature(L,id_r) == inner_product(boundary_grid(g_3D,id_r),op.quadratureClosure) 138 @test boundary_quadrature(L,id_r) == inner_product(boundary_grid(g_3D,id_r),op.quadratureClosure)
154 @test boundary_quadrature(L,id_s) == inner_product(boundary_grid(g_3D,id_s),op.quadratureClosure) 139 @test boundary_quadrature(L,id_s) == inner_product(boundary_grid(g_3D,id_s),op.quadratureClosure)
155 @test boundary_quadrature(L,id_n) == inner_product(boundary_grid(g_3D,id_n),op.quadratureClosure) 140 @test boundary_quadrature(L,id_n) == inner_product(boundary_grid(g_3D,id_n),op.quadratureClosure)
156 @test boundary_quadrature(L,id_b) == inner_product(boundary_grid(g_3D,id_b),op.quadratureClosure) 141 @test boundary_quadrature(L,id_b) == inner_product(boundary_grid(g_3D,id_b),op.quadratureClosure)