comparison test/DiffOps/DiffOps_test.jl @ 711:df88aee35bb9 feature/selectable_tests

Switch to _test.jl suffix
author Jonatan Werpers <jonatan@werpers.com>
date Sat, 20 Feb 2021 20:45:40 +0100
parents test/DiffOps/testDiffOps.jl@44fa9a171557
children 11a444d6fc93
comparison
equal deleted inserted replaced
710:44fa9a171557 711:df88aee35bb9
1 using Test
2 using Sbplib.DiffOps
3 using Sbplib.Grids
4 using Sbplib.SbpOperators
5 using Sbplib.RegionIndices
6 using Sbplib.LazyTensors
7
8 @testset "DiffOps" begin
9 #
10 # @testset "BoundaryValue" begin
11 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
12 # g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0))
13 #
14 # e_w = BoundaryValue(op, g, CartesianBoundary{1,Lower}())
15 # e_e = BoundaryValue(op, g, CartesianBoundary{1,Upper}())
16 # e_s = BoundaryValue(op, g, CartesianBoundary{2,Lower}())
17 # e_n = BoundaryValue(op, g, CartesianBoundary{2,Upper}())
18 #
19 # v = zeros(Float64, 4, 5)
20 # v[:,5] = [1, 2, 3,4]
21 # v[:,4] = [1, 2, 3,4]
22 # v[:,3] = [4, 5, 6, 7]
23 # v[:,2] = [7, 8, 9, 10]
24 # v[:,1] = [10, 11, 12, 13]
25 #
26 # @test e_w isa TensorMapping{T,2,1} where T
27 # @test e_w' isa TensorMapping{T,1,2} where T
28 #
29 # @test domain_size(e_w, (3,2)) == (2,)
30 # @test domain_size(e_e, (3,2)) == (2,)
31 # @test domain_size(e_s, (3,2)) == (3,)
32 # @test domain_size(e_n, (3,2)) == (3,)
33 #
34 # @test size(e_w'*v) == (5,)
35 # @test size(e_e'*v) == (5,)
36 # @test size(e_s'*v) == (4,)
37 # @test size(e_n'*v) == (4,)
38 #
39 # @test collect(e_w'*v) == [10,7,4,1.0,1]
40 # @test collect(e_e'*v) == [13,10,7,4,4.0]
41 # @test collect(e_s'*v) == [10,11,12,13.0]
42 # @test collect(e_n'*v) == [1,2,3,4.0]
43 #
44 # g_x = [1,2,3,4.0]
45 # g_y = [5,4,3,2,1.0]
46 #
47 # G_w = zeros(Float64, (4,5))
48 # G_w[1,:] = g_y
49 #
50 # G_e = zeros(Float64, (4,5))
51 # G_e[4,:] = g_y
52 #
53 # G_s = zeros(Float64, (4,5))
54 # G_s[:,1] = g_x
55 #
56 # G_n = zeros(Float64, (4,5))
57 # G_n[:,5] = g_x
58 #
59 # @test size(e_w*g_y) == (UnknownDim,5)
60 # @test size(e_e*g_y) == (UnknownDim,5)
61 # @test size(e_s*g_x) == (4,UnknownDim)
62 # @test size(e_n*g_x) == (4,UnknownDim)
63 #
64 # # These tests should be moved to where they are possible (i.e we know what the grid should be)
65 # @test_broken collect(e_w*g_y) == G_w
66 # @test_broken collect(e_e*g_y) == G_e
67 # @test_broken collect(e_s*g_x) == G_s
68 # @test_broken collect(e_n*g_x) == G_n
69 # end
70 #
71 # @testset "NormalDerivative" begin
72 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
73 # g = EquidistantGrid((5,6), (0.0, 0.0), (4.0,5.0))
74 #
75 # d_w = NormalDerivative(op, g, CartesianBoundary{1,Lower}())
76 # d_e = NormalDerivative(op, g, CartesianBoundary{1,Upper}())
77 # d_s = NormalDerivative(op, g, CartesianBoundary{2,Lower}())
78 # d_n = NormalDerivative(op, g, CartesianBoundary{2,Upper}())
79 #
80 #
81 # v = evalOn(g, (x,y)-> x^2 + (y-1)^2 + x*y)
82 # v∂x = evalOn(g, (x,y)-> 2*x + y)
83 # v∂y = evalOn(g, (x,y)-> 2*(y-1) + x)
84 #
85 # @test d_w isa TensorMapping{T,2,1} where T
86 # @test d_w' isa TensorMapping{T,1,2} where T
87 #
88 # @test domain_size(d_w, (3,2)) == (2,)
89 # @test domain_size(d_e, (3,2)) == (2,)
90 # @test domain_size(d_s, (3,2)) == (3,)
91 # @test domain_size(d_n, (3,2)) == (3,)
92 #
93 # @test size(d_w'*v) == (6,)
94 # @test size(d_e'*v) == (6,)
95 # @test size(d_s'*v) == (5,)
96 # @test size(d_n'*v) == (5,)
97 #
98 # @test collect(d_w'*v) ≈ v∂x[1,:]
99 # @test collect(d_e'*v) ≈ v∂x[5,:]
100 # @test collect(d_s'*v) ≈ v∂y[:,1]
101 # @test collect(d_n'*v) ≈ v∂y[:,6]
102 #
103 #
104 # d_x_l = zeros(Float64, 5)
105 # d_x_u = zeros(Float64, 5)
106 # for i ∈ eachindex(d_x_l)
107 # d_x_l[i] = op.dClosure[i-1]
108 # d_x_u[i] = -op.dClosure[length(d_x_u)-i]
109 # end
110 #
111 # d_y_l = zeros(Float64, 6)
112 # d_y_u = zeros(Float64, 6)
113 # for i ∈ eachindex(d_y_l)
114 # d_y_l[i] = op.dClosure[i-1]
115 # d_y_u[i] = -op.dClosure[length(d_y_u)-i]
116 # end
117 #
118 # function prod_matrix(x,y)
119 # G = zeros(Float64, length(x), length(y))
120 # for I ∈ CartesianIndices(G)
121 # G[I] = x[I[1]]*y[I[2]]
122 # end
123 #
124 # return G
125 # end
126 #
127 # g_x = [1,2,3,4.0,5]
128 # g_y = [5,4,3,2,1.0,11]
129 #
130 # G_w = prod_matrix(d_x_l, g_y)
131 # G_e = prod_matrix(d_x_u, g_y)
132 # G_s = prod_matrix(g_x, d_y_l)
133 # G_n = prod_matrix(g_x, d_y_u)
134 #
135 #
136 # @test size(d_w*g_y) == (UnknownDim,6)
137 # @test size(d_e*g_y) == (UnknownDim,6)
138 # @test size(d_s*g_x) == (5,UnknownDim)
139 # @test size(d_n*g_x) == (5,UnknownDim)
140 #
141 # # These tests should be moved to where they are possible (i.e we know what the grid should be)
142 # @test_broken collect(d_w*g_y) ≈ G_w
143 # @test_broken collect(d_e*g_y) ≈ G_e
144 # @test_broken collect(d_s*g_x) ≈ G_s
145 # @test_broken collect(d_n*g_x) ≈ G_n
146 # end
147 #
148 # @testset "BoundaryQuadrature" begin
149 # op = read_D2_operator(sbp_operators_path()*"standard_diagonal.toml"; order=4)
150 # g = EquidistantGrid((10,11), (0.0, 0.0), (1.0,1.0))
151 #
152 # H_w = BoundaryQuadrature(op, g, CartesianBoundary{1,Lower}())
153 # H_e = BoundaryQuadrature(op, g, CartesianBoundary{1,Upper}())
154 # H_s = BoundaryQuadrature(op, g, CartesianBoundary{2,Lower}())
155 # H_n = BoundaryQuadrature(op, g, CartesianBoundary{2,Upper}())
156 #
157 # v = evalOn(g, (x,y)-> x^2 + (y-1)^2 + x*y)
158 #
159 # function get_quadrature(N)
160 # qc = op.quadratureClosure
161 # q = (qc..., ones(N-2*closuresize(op))..., reverse(qc)...)
162 # @assert length(q) == N
163 # return q
164 # end
165 #
166 # v_w = v[1,:]
167 # v_e = v[10,:]
168 # v_s = v[:,1]
169 # v_n = v[:,11]
170 #
171 # q_x = spacing(g)[1].*get_quadrature(10)
172 # q_y = spacing(g)[2].*get_quadrature(11)
173 #
174 # @test H_w isa TensorOperator{T,1} where T
175 #
176 # @test domain_size(H_w, (3,)) == (3,)
177 # @test domain_size(H_n, (3,)) == (3,)
178 #
179 # @test range_size(H_w, (3,)) == (3,)
180 # @test range_size(H_n, (3,)) == (3,)
181 #
182 # @test size(H_w*v_w) == (11,)
183 # @test size(H_e*v_e) == (11,)
184 # @test size(H_s*v_s) == (10,)
185 # @test size(H_n*v_n) == (10,)
186 #
187 # @test collect(H_w*v_w) ≈ q_y.*v_w
188 # @test collect(H_e*v_e) ≈ q_y.*v_e
189 # @test collect(H_s*v_s) ≈ q_x.*v_s
190 # @test collect(H_n*v_n) ≈ q_x.*v_n
191 #
192 # @test collect(H_w'*v_w) == collect(H_w'*v_w)
193 # @test collect(H_e'*v_e) == collect(H_e'*v_e)
194 # @test collect(H_s'*v_s) == collect(H_s'*v_s)
195 # @test collect(H_n'*v_n) == collect(H_n'*v_n)
196 # end
197
198 end