Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/volumeops/derivatives/second_derivative_test.jl @ 1040:7fc8df5157a7 refactor/lazy_tensors
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 22 Mar 2022 14:23:55 +0100 |
parents | 1ba8a398af9c 5ec49dd2c7c4 |
children | f1bb1b6d85dd |
comparison
equal
deleted
inserted
replaced
1037:9e76bf19904c | 1040:7fc8df5157a7 |
---|---|
19 @testset "Constructors" begin | 19 @testset "Constructors" begin |
20 @testset "1D" begin | 20 @testset "1D" begin |
21 Dₓₓ = second_derivative(g_1D,inner_stencil,closure_stencils,1) | 21 Dₓₓ = second_derivative(g_1D,inner_stencil,closure_stencils,1) |
22 @test Dₓₓ == second_derivative(g_1D,inner_stencil,closure_stencils) | 22 @test Dₓₓ == second_derivative(g_1D,inner_stencil,closure_stencils) |
23 @test Dₓₓ == second_derivative(g_1D,stencil_set,1) | 23 @test Dₓₓ == second_derivative(g_1D,stencil_set,1) |
24 @test Dₓₓ == second_derivative(g_1D,stencil_set) | |
24 @test Dₓₓ isa VolumeOperator | 25 @test Dₓₓ isa VolumeOperator |
25 end | 26 end |
26 @testset "2D" begin | 27 @testset "2D" begin |
27 Dₓₓ = second_derivative(g_2D,inner_stencil,closure_stencils,1) | 28 Dₓₓ = second_derivative(g_2D,inner_stencil,closure_stencils,1) |
28 D2 = second_derivative(g_1D,inner_stencil,closure_stencils) | 29 D2 = second_derivative(g_1D,inner_stencil,closure_stencils,1) |
29 I = IdentityTensor{Float64}(size(g_2D)[2]) | 30 I = IdentityTensor{Float64}(size(g_2D)[2]) |
30 @test Dₓₓ == D2⊗I | 31 @test Dₓₓ == D2⊗I |
31 @test Dₓₓ == second_derivative(g_2D,stencil_set,1) | 32 @test Dₓₓ == second_derivative(g_2D,stencil_set,1) |
32 @test Dₓₓ isa LazyTensor{T,2,2} where T | 33 @test Dₓₓ isa LazyTensor{T,2,2} where T |
33 end | 34 end |
49 | 50 |
50 # 2nd order interior stencil, 1nd order boundary stencil, | 51 # 2nd order interior stencil, 1nd order boundary stencil, |
51 # implies that L*v should be exact for monomials up to order 2. | 52 # implies that L*v should be exact for monomials up to order 2. |
52 @testset "2nd order" begin | 53 @testset "2nd order" begin |
53 stencil_set = read_stencil_set(operator_path; order=2) | 54 stencil_set = read_stencil_set(operator_path; order=2) |
54 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) | 55 Dₓₓ = second_derivative(g_1D,stencil_set) |
55 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) | |
56 Dₓₓ = second_derivative(g_1D,inner_stencil,closure_stencils) | |
57 @test Dₓₓ*monomials[1] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 | 56 @test Dₓₓ*monomials[1] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 |
58 @test Dₓₓ*monomials[2] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 | 57 @test Dₓₓ*monomials[2] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 |
59 @test Dₓₓ*monomials[3] ≈ monomials[1] atol = 5e-10 | 58 @test Dₓₓ*monomials[3] ≈ monomials[1] atol = 5e-10 |
60 @test Dₓₓ*v ≈ vₓₓ rtol = 5e-2 norm = l2 | 59 @test Dₓₓ*v ≈ vₓₓ rtol = 5e-2 norm = l2 |
61 end | 60 end |
62 | 61 |
63 # 4th order interior stencil, 2nd order boundary stencil, | 62 # 4th order interior stencil, 2nd order boundary stencil, |
64 # implies that L*v should be exact for monomials up to order 3. | 63 # implies that L*v should be exact for monomials up to order 3. |
65 @testset "4th order" begin | 64 @testset "4th order" begin |
66 stencil_set = read_stencil_set(operator_path; order=4) | 65 stencil_set = read_stencil_set(operator_path; order=4) |
67 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) | 66 Dₓₓ = second_derivative(g_1D,stencil_set) |
68 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) | |
69 Dₓₓ = second_derivative(g_1D,inner_stencil,closure_stencils) | |
70 # NOTE: high tolerances for checking the "exact" differentiation | 67 # NOTE: high tolerances for checking the "exact" differentiation |
71 # due to accumulation of round-off errors/cancellation errors? | 68 # due to accumulation of round-off errors/cancellation errors? |
72 @test Dₓₓ*monomials[1] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 | 69 @test Dₓₓ*monomials[1] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 |
73 @test Dₓₓ*monomials[2] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 | 70 @test Dₓₓ*monomials[2] ≈ zeros(Float64,size(g_1D)...) atol = 5e-10 |
74 @test Dₓₓ*monomials[3] ≈ monomials[1] atol = 5e-10 | 71 @test Dₓₓ*monomials[3] ≈ monomials[1] atol = 5e-10 |
90 | 87 |
91 # 2nd order interior stencil, 1st order boundary stencil, | 88 # 2nd order interior stencil, 1st order boundary stencil, |
92 # implies that L*v should be exact for binomials up to order 2. | 89 # implies that L*v should be exact for binomials up to order 2. |
93 @testset "2nd order" begin | 90 @testset "2nd order" begin |
94 stencil_set = read_stencil_set(operator_path; order=2) | 91 stencil_set = read_stencil_set(operator_path; order=2) |
95 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) | 92 Dyy = second_derivative(g_2D,stencil_set,2) |
96 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) | |
97 Dyy = second_derivative(g_2D,inner_stencil,closure_stencils,2) | |
98 @test Dyy*binomials[1] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 | 93 @test Dyy*binomials[1] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 |
99 @test Dyy*binomials[2] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 | 94 @test Dyy*binomials[2] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 |
100 @test Dyy*binomials[3] ≈ evalOn(g_2D,(x,y)->1.) atol = 5e-9 | 95 @test Dyy*binomials[3] ≈ evalOn(g_2D,(x,y)->1.) atol = 5e-9 |
101 @test Dyy*v ≈ v_yy rtol = 5e-2 norm = l2 | 96 @test Dyy*v ≈ v_yy rtol = 5e-2 norm = l2 |
102 end | 97 end |
103 | 98 |
104 # 4th order interior stencil, 2nd order boundary stencil, | 99 # 4th order interior stencil, 2nd order boundary stencil, |
105 # implies that L*v should be exact for binomials up to order 3. | 100 # implies that L*v should be exact for binomials up to order 3. |
106 @testset "4th order" begin | 101 @testset "4th order" begin |
107 stencil_set = read_stencil_set(operator_path; order=4) | 102 stencil_set = read_stencil_set(operator_path; order=4) |
108 inner_stencil = parse_stencil(stencil_set["D2"]["inner_stencil"]) | 103 Dyy = second_derivative(g_2D,stencil_set,2) |
109 closure_stencils = parse_stencil.(stencil_set["D2"]["closure_stencils"]) | |
110 Dyy = second_derivative(g_2D,inner_stencil,closure_stencils,2) | |
111 # NOTE: high tolerances for checking the "exact" differentiation | 104 # NOTE: high tolerances for checking the "exact" differentiation |
112 # due to accumulation of round-off errors/cancellation errors? | 105 # due to accumulation of round-off errors/cancellation errors? |
113 @test Dyy*binomials[1] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 | 106 @test Dyy*binomials[1] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 |
114 @test Dyy*binomials[2] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 | 107 @test Dyy*binomials[2] ≈ zeros(Float64,size(g_2D)...) atol = 5e-9 |
115 @test Dyy*binomials[3] ≈ evalOn(g_2D,(x,y)->1.) atol = 5e-9 | 108 @test Dyy*binomials[3] ≈ evalOn(g_2D,(x,y)->1.) atol = 5e-9 |