comparison test/testSbpOperators.jl @ 389:0433ab553d13 refactor/sbp_operators_tests/collect_and_compare

Rewrite l2 norm comparison to use the norm key word of isapprox
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 01 Oct 2020 08:23:22 +0200
parents 5223872485cd
children 737e597e0e6d
comparison
equal deleted inserted replaced
388:5223872485cd 389:0433ab553d13
63 @test_broken Dₓₓ*v0 ≈ 0.0 atol=5e-11 63 @test_broken Dₓₓ*v0 ≈ 0.0 atol=5e-11
64 @test_broken Dₓₓ*v1 ≈ 0.0 atol=5e-11 64 @test_broken Dₓₓ*v1 ≈ 0.0 atol=5e-11
65 @test Dₓₓ*v2 ≈ v0 atol=5e-11 65 @test Dₓₓ*v2 ≈ v0 atol=5e-11
66 @test Dₓₓ*v3 ≈ v1 atol=5e-11 66 @test Dₓₓ*v3 ≈ v1 atol=5e-11
67 67
68 e4 = Dₓₓ*v4 - v2
69 e5 = Dₓₓ*v5 + v5
70 h = spacing(g)[1]; 68 h = spacing(g)[1];
71 @test sqrt(h*sum(e4.^2)) ≈ 0 atol=5e-4 69 l2(v) = sqrt(h*sum(v.^2))
72 @test sqrt(h*sum(e5.^2)) ≈ 0 atol=5e-4 70 @test Dₓₓ*v4 ≈ v2 atol=5e-4 norm=l2
71 @test Dₓₓ*v5 ≈ -v5 atol=5e-4 norm=l2
73 end 72 end
74 73
75 74
76 @testset "Laplace2D" begin 75 @testset "Laplace2D" begin
77 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") 76 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
106 # the error is measured in the H-norm. 105 # the error is measured in the H-norm.
107 @test_broken L*v0 ≈ 0 atol=5e-11 106 @test_broken L*v0 ≈ 0 atol=5e-11
108 @test_broken L*v1 ≈ 0 atol=5e-11 107 @test_broken L*v1 ≈ 0 atol=5e-11
109 @test L*v2 ≈ v0 # Seems to be more accurate 108 @test L*v2 ≈ v0 # Seems to be more accurate
110 @test L*v3 ≈ v1 atol=5e-10 109 @test L*v3 ≈ v1 atol=5e-10
111 e4 = L*v4 - v2
112 e5 = L*v5 - v5ₓₓ
113 110
114 h = spacing(g) 111 h = spacing(g)
115 @test sqrt(prod(h)*sum(e4.^2)) ≈ 0 atol=5e-4 112 l2(v) = sqrt(prod(h)*sum(v.^2))
116 @test sqrt(prod(h)*sum(e5.^2)) ≈ 0 atol=5e-4 113 @test L*v4 ≈ v2 atol=5e-4 norm=l2
114 @test L*v5 ≈ v5ₓₓ atol=5e-4 norm=l2
117 end 115 end
118 116
119 @testset "DiagonalInnerProduct" begin 117 @testset "DiagonalInnerProduct" begin
120 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") 118 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
121 L = 2.3 119 L = 2.3