Mercurial > repos > public > sbplib_julia
diff 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 |
line wrap: on
line diff
--- a/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl Mon Mar 21 12:51:39 2022 +0100 +++ b/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl Tue May 10 20:34:20 2022 +0200 @@ -29,12 +29,14 @@ @test first_derivative(g₁, stencil_set, 1) isa LazyTensor{Float64,1,1} @test first_derivative(g₂, stencil_set, 2) isa LazyTensor{Float64,2,2} + @test first_derivative(g₁, stencil_set, 1) == first_derivative(g₁, stencil_set) interior_stencil = CenteredStencil(-1,0,1) closure_stencils = [Stencil(-1,1, center=1)] @test first_derivative(g₁, interior_stencil, closure_stencils, 1) isa LazyTensor{Float64,1,1} @test first_derivative(g₁, interior_stencil, closure_stencils, 1) isa VolumeOperator + @test first_derivative(g₁, interior_stencil, closure_stencils, 1) == first_derivative(g₁, interior_stencil, closure_stencils) @test first_derivative(g₂, interior_stencil, closure_stencils, 2) isa LazyTensor{Float64,2,2} end @@ -69,6 +71,7 @@ end @testset "Accuracy on function" begin + # 1D g = EquidistantGrid(30, 0.,1.) v = evalOn(g, x->exp(x)) @testset for (order, tol) ∈ [(2, 6e-3),(4, 2e-4)] @@ -78,8 +81,17 @@ @test D₁*v ≈ v rtol=tol end + # 2D + g = EquidistantGrid((30,60), (0.,0.),(1.,2.)) + v = evalOn(g, (x,y)->exp(0.8x+1.2*y)) + @testset for (order, tol) ∈ [(2, 6e-3),(4, 3e-4)] + stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) + Dx = first_derivative(g, stencil_set, 1) + Dy = first_derivative(g, stencil_set, 2) - # TODO: Different directions + @test Dx*v ≈ 0.8v rtol=tol + @test Dy*v ≈ 1.2v rtol=tol + end end end