changeset 387:4686c3509b54 refactor/sbp_operators_tests/collect_and_compare

Switch to using isapprox operator
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 01 Oct 2020 08:10:14 +0200
parents 6ef73611f4d9
children 5223872485cd
files test/testSbpOperators.jl
diffstat 1 files changed, 26 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/test/testSbpOperators.jl	Thu Oct 01 06:20:30 2020 +0200
+++ b/test/testSbpOperators.jl	Thu Oct 01 08:10:14 2020 +0200
@@ -62,16 +62,17 @@
     # implies that L*v should be exact for v - monomial up to order 3.
     # Exact differentiation is measured point-wise. For other grid functions
     # the error is measured in the l2-norm.
-    @test all(abs.(Dₓₓ*v0) .<= 5e-11)
-    @test all(abs.(Dₓₓ*v1) .<= 5e-11)
-    @test all(abs.((Dₓₓ*v2 - v0)) .<= 5e-11)
-    @test all(abs.((Dₓₓ*v3 - v1)) .<= 5e-11)
+    @test_broken Dₓₓ*v0 ≈ 0.0 atol=5e-11
+    @test_broken Dₓₓ*v1 ≈ 0.0 atol=5e-11
+    @test Dₓₓ*v2 ≈ v0 atol=5e-11
+    @test Dₓₓ*v3 ≈ v1 atol=5e-11
     e4 = Dₓₓ*v4 - v2
     e5 = Dₓₓ*v5 + v5
-    @test sqrt(h*sum(e4.^2)) <= 5e-4
-    @test sqrt(h*sum(e5.^2)) <= 5e-4
+    @test sqrt(h*sum(e4.^2)) ≈ 0 atol=5e-4
+    @test sqrt(h*sum(e5.^2)) ≈ 0 atol=5e-4
 end
 
+
 @testset "Laplace2D" begin
     op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
     Lx = 1.5
@@ -99,23 +100,20 @@
     @test L isa TensorMapping{T,2,2} where T
     @test L' isa TensorMapping{T,2,2} where T
 
-    # TODO: Should perhaps set tolerance level for isapporx instead?
-    #       Are these tolerance levels resonable or should tests be constructed
-    #       differently?
     # 4th order interior stencil, 2nd order boundary stencil,
     # implies that L*v should be exact for v - monomial up to order 3.
     # Exact differentiation is measured point-wise. For other grid functions
     # the error is measured in the H-norm.
-    @test all(abs.(L*v0) .<= 5e-11)
-    @test all(abs.(L*v1) .<= 5e-11)
-    @test all(L*v2 .≈ v0) # Seems to be more accurate
-    @test all(abs.((L*v3 - v1)) .<= 5e-11)
+    @test_broken L*v0 ≈ 0 atol=5e-11
+    @test_broken L*v1 ≈ 0 atol=5e-11
+    @test L*v2 ≈ v0 # Seems to be more accurate
+    @test L*v3 ≈ v1 atol=5e-10
     e4 = L*v4 - v2
     e5 = L*v5 - v5ₓₓ
 
     h = spacing(g)
-    @test sqrt(prod(h)*sum(e4.^2)) <= 5e-4
-    @test sqrt(prod(h)*sum(e5.^2)) <= 5e-4
+    @test sqrt(prod(h)*sum(e4.^2)) ≈ 0 atol=5e-4
+    @test sqrt(prod(h)*sum(e5.^2)) ≈ 0 atol=5e-4
 end
 
 @testset "DiagonalInnerProduct" begin
@@ -161,7 +159,7 @@
 
     @test Hi isa TensorMapping{T,1,1} where T
     @test Hi' isa TensorMapping{T,1,1} where T
-    @test Hi*H*v  ≈ v
+    @test Hi*H*v ≈ v
     @test Hi*v == Hi'*v
 end
 
@@ -269,10 +267,10 @@
 #     @test size(d_s'*v) == (5,)
 #     @test size(d_n'*v) == (5,)
 #
-#     @test d_w'*v ≈ v∂x[1,:]
-#     @test d_e'*v ≈ v∂x[5,:]
-#     @test d_s'*v ≈ v∂y[:,1]
-#     @test d_n'*v ≈ v∂y[:,6]
+#     @test d_w'*v .≈ v∂x[1,:]
+#     @test d_e'*v .≈ v∂x[5,:]
+#     @test d_s'*v .≈ v∂y[:,1]
+#     @test d_n'*v .≈ v∂y[:,6]
 #
 #
 #     d_x_l = zeros(Float64, 5)
@@ -313,10 +311,10 @@
 #     @test size(d_n*g_x) == (5,UnknownDim)
 #
 #     # These tests should be moved to where they are possible (i.e we know what the grid should be)
-#     @test_broken d_w*g_y ≈ G_w
-#     @test_broken d_e*g_y ≈ G_e
-#     @test_broken d_s*g_x ≈ G_s
-#     @test_broken d_n*g_x ≈ G_n
+#     @test_broken d_w*g_y .≈ G_w
+#     @test_broken d_e*g_y .≈ G_e
+#     @test_broken d_s*g_x .≈ G_s
+#     @test_broken d_n*g_x .≈ G_n
 # end
 #
 # @testset "BoundaryQuadrature" begin
@@ -358,10 +356,10 @@
 #     @test size(H_s*v_s) == (10,)
 #     @test size(H_n*v_n) == (10,)
 #
-#     @test H_w*v_w ≈ q_y.*v_w
-#     @test H_e*v_e ≈ q_y.*v_e
-#     @test H_s*v_s ≈ q_x.*v_s
-#     @test H_n*v_n ≈ q_x.*v_n
+#     @test H_w*v_w .≈ q_y.*v_w
+#     @test H_e*v_e .≈ q_y.*v_e
+#     @test H_s*v_s .≈ q_x.*v_s
+#     @test H_n*v_n .≈ q_x.*v_n
 #
 #     @test H_w'*v_w == H_w'*v_w
 #     @test H_e'*v_e == H_e'*v_e