Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/volumeops/derivatives/first_derivative_test.jl @ 1046:e00eb000346e feature/first_derivative
Add tests for 2D application
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 23 Mar 2022 12:39:35 +0100 |
parents | 5bfc03cf3ba7 |
children | d12ab8120d29 |
comparison
equal
deleted
inserted
replaced
984:89513bacafd1 | 1046:e00eb000346e |
---|---|
67 end | 67 end |
68 end | 68 end |
69 end | 69 end |
70 | 70 |
71 @testset "Accuracy on function" begin | 71 @testset "Accuracy on function" begin |
72 # 1D | |
72 g = EquidistantGrid(30, 0.,1.) | 73 g = EquidistantGrid(30, 0.,1.) |
73 v = evalOn(g, x->exp(x)) | 74 v = evalOn(g, x->exp(x)) |
74 @testset for (order, tol) ∈ [(2, 6e-3),(4, 2e-4)] | 75 @testset for (order, tol) ∈ [(2, 6e-3),(4, 2e-4)] |
75 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) | 76 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) |
76 D₁ = first_derivative(g, stencil_set, 1) | 77 D₁ = first_derivative(g, stencil_set, 1) |
77 | 78 |
78 @test D₁*v ≈ v rtol=tol | 79 @test D₁*v ≈ v rtol=tol |
79 end | 80 end |
81 | |
82 # 2D | |
83 g = EquidistantGrid((30,60), (0.,0.),(1.,2.)) | |
84 v = evalOn(g, (x,y)->exp(0.8x+1.2*y)) | |
85 @testset for (order, tol) ∈ [(2, 6e-3),(4, 3e-4)] | |
86 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) | |
87 Dx = first_derivative(g, stencil_set, 1) | |
88 Dy = first_derivative(g, stencil_set, 2) | |
89 | |
90 @test Dx*v ≈ 0.8v rtol=tol | |
91 @test Dy*v ≈ 1.2v rtol=tol | |
92 end | |
80 end | 93 end |
81 end | 94 end |
82 | 95 |