comparison test/SbpOperators/volumeops/derivatives/first_derivative_test.jl @ 1100:157a78959e5d refactor/sbpoperators/inflation

Bring up to date
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 10 May 2022 20:34:20 +0200
parents 05a25a5063bb d12ab8120d29
children f1bb1b6d85dd
comparison
equal deleted inserted replaced
1099:05a25a5063bb 1100:157a78959e5d
27 g₁ = EquidistantGrid(11, 0., 1.) 27 g₁ = EquidistantGrid(11, 0., 1.)
28 g₂ = EquidistantGrid((11,14), (0.,1.), (1.,3.)) 28 g₂ = EquidistantGrid((11,14), (0.,1.), (1.,3.))
29 29
30 @test first_derivative(g₁, stencil_set, 1) isa LazyTensor{Float64,1,1} 30 @test first_derivative(g₁, stencil_set, 1) isa LazyTensor{Float64,1,1}
31 @test first_derivative(g₂, stencil_set, 2) isa LazyTensor{Float64,2,2} 31 @test first_derivative(g₂, stencil_set, 2) isa LazyTensor{Float64,2,2}
32 @test first_derivative(g₁, stencil_set, 1) == first_derivative(g₁, stencil_set)
32 33
33 interior_stencil = CenteredStencil(-1,0,1) 34 interior_stencil = CenteredStencil(-1,0,1)
34 closure_stencils = [Stencil(-1,1, center=1)] 35 closure_stencils = [Stencil(-1,1, center=1)]
35 36
36 @test first_derivative(g₁, interior_stencil, closure_stencils, 1) isa LazyTensor{Float64,1,1} 37 @test first_derivative(g₁, interior_stencil, closure_stencils, 1) isa LazyTensor{Float64,1,1}
37 @test first_derivative(g₁, interior_stencil, closure_stencils, 1) isa VolumeOperator 38 @test first_derivative(g₁, interior_stencil, closure_stencils, 1) isa VolumeOperator
39 @test first_derivative(g₁, interior_stencil, closure_stencils, 1) == first_derivative(g₁, interior_stencil, closure_stencils)
38 @test first_derivative(g₂, interior_stencil, closure_stencils, 2) isa LazyTensor{Float64,2,2} 40 @test first_derivative(g₂, interior_stencil, closure_stencils, 2) isa LazyTensor{Float64,2,2}
39 end 41 end
40 42
41 @testset "Accuracy conditions" begin 43 @testset "Accuracy conditions" begin
42 N = 20 44 N = 20
67 end 69 end
68 end 70 end
69 end 71 end
70 72
71 @testset "Accuracy on function" begin 73 @testset "Accuracy on function" begin
74 # 1D
72 g = EquidistantGrid(30, 0.,1.) 75 g = EquidistantGrid(30, 0.,1.)
73 v = evalOn(g, x->exp(x)) 76 v = evalOn(g, x->exp(x))
74 @testset for (order, tol) ∈ [(2, 6e-3),(4, 2e-4)] 77 @testset for (order, tol) ∈ [(2, 6e-3),(4, 2e-4)]
75 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) 78 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order)
76 D₁ = first_derivative(g, stencil_set, 1) 79 D₁ = first_derivative(g, stencil_set, 1)
77 80
78 @test D₁*v ≈ v rtol=tol 81 @test D₁*v ≈ v rtol=tol
79 end 82 end
80 83
84 # 2D
85 g = EquidistantGrid((30,60), (0.,0.),(1.,2.))
86 v = evalOn(g, (x,y)->exp(0.8x+1.2*y))
87 @testset for (order, tol) ∈ [(2, 6e-3),(4, 3e-4)]
88 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order)
89 Dx = first_derivative(g, stencil_set, 1)
90 Dy = first_derivative(g, stencil_set, 2)
81 91
82 # TODO: Different directions 92 @test Dx*v ≈ 0.8v rtol=tol
93 @test Dy*v ≈ 1.2v rtol=tol
94 end
83 end 95 end
84 end 96 end
85 97