comparison SbpOperators/test/runtests.jl @ 329:408c37b295c2

Refactor 1D tensor mapping in inverse quadrature to separate file, InverseDiagonalNorm. Add tests
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 25 Sep 2020 09:34:37 +0200
parents 9cc5d1498b2d
children
comparison
equal deleted inserted replaced
328:9cc5d1498b2d 329:408c37b295c2
150 @test Q isa TensorOperator{T,2} where T 150 @test Q isa TensorOperator{T,2} where T
151 @test Q' isa TensorMapping{T,2,2} where T 151 @test Q' isa TensorMapping{T,2,2} where T
152 @test sum(collect(Q*v)) ≈ (Lx*Ly) 152 @test sum(collect(Q*v)) ≈ (Lx*Ly)
153 @test collect(Q*v) == collect(Q'*v) 153 @test collect(Q*v) == collect(Q'*v)
154 end 154 end
155 # 155
156 # @testset "InverseQuadrature" begin 156 @testset "InverseDiagonalInnerProduct" begin
157 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") 157 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
158 # Lx = 7.3 158 L = 2.3
159 # Ly = 8.2 159 g = EquidistantGrid((77,), (0.0,), (L,))
160 # g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly)) 160 h = spacing(g)
161 # H = Quadrature(op,g) 161 H = DiagonalInnerProduct(h[1],op.quadratureClosure)
162 # Hinv = InverseQuadrature(op,g) 162
163 # v = evalOn(g, (x,y)-> x^2 + (y-1)^2 + x*y) 163 h_i = inverse_spacing(g)
164 # 164 Hi = InverseDiagonalInnerProduct(h_i[1],1 ./ op.quadratureClosure)
165 # @test Hinv isa TensorOperator{T,2} where T 165 v = evalOn(g, x->sin(x))
166 # @test Hinv' isa TensorMapping{T,2,2} where T 166
167 # @test collect(Hinv*H*v) ≈ v 167 @test Hi isa TensorOperator{T,1} where T
168 # @test collect(Hinv*v) == collect(Hinv'*v) 168 @test Hi' isa TensorMapping{T,1,1} where T
169 # end 169 @test collect(Hi*H*v) ≈ v
170 @test collect(Hi*v) == collect(Hi'*v)
171 end
172
173 @testset "InverseQuadrature" begin
174 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
175 Lx = 7.3
176 Ly = 8.2
177 g = EquidistantGrid((77,66), (0.0, 0.0), (Lx,Ly))
178
179 h = spacing(g)
180 Hx = DiagonalInnerProduct(h[1], op.quadratureClosure);
181 Hy = DiagonalInnerProduct(h[2], op.quadratureClosure);
182 Q = Quadrature((Hx,Hy))
183
184 hi = inverse_spacing(g)
185 Hix = InverseDiagonalInnerProduct(hi[1], 1 ./ op.quadratureClosure);
186 Hiy = InverseDiagonalInnerProduct(hi[2], 1 ./ op.quadratureClosure);
187 Qinv = InverseQuadrature((Hix,Hiy))
188 v = evalOn(g, (x,y)-> x^2 + (y-1)^2 + x*y)
189
190 @test Qinv isa TensorOperator{T,2} where T
191 @test Qinv' isa TensorMapping{T,2,2} where T
192 @test collect(Qinv*Q*v) ≈ v
193 @test collect(Qinv*v) == collect(Qinv'*v)
194 end
170 # 195 #
171 # @testset "BoundaryValue" begin 196 # @testset "BoundaryValue" begin
172 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") 197 # op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
173 # g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0)) 198 # g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0))
174 # 199 #