Mercurial > repos > public > sbplib_julia
diff test/SbpOperators/volumeops/derivatives/first_derivative_test.jl @ 1854:654a2b7e6824 tooling/benchmarks
Merge default
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 11 Jan 2025 10:19:47 +0100 |
parents | 471a948cd2b2 |
children |
line wrap: on
line diff
--- a/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl Wed May 31 08:59:34 2023 +0200 +++ b/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl Sat Jan 11 10:19:47 2025 +0100 @@ -1,31 +1,18 @@ using Test -using Sbplib.SbpOperators -using Sbplib.Grids -using Sbplib.LazyTensors - -using Sbplib.SbpOperators: closure_size, Stencil, VolumeOperator - -""" - monomial(x,k) +using Diffinitive.SbpOperators +using Diffinitive.Grids +using Diffinitive.LazyTensors -Evaluates ``x^k/k!` with the convetion that it is ``0`` for all ``k<0``. -Has the property that ``d/dx monomial(x,k) = monomial(x,k-1)`` -""" -function monomial(x,k) - if k < 0 - return zero(x) - end - x^k/factorial(k) -end +using Diffinitive.SbpOperators: closure_size, Stencil, VolumeOperator @testset "first_derivative" begin @testset "Constructors" begin stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2) - g₁ = equidistant_grid(11, 0., 1.) - g₂ = equidistant_grid((11,14), (0.,1.), (1.,3.)) + g₁ = equidistant_grid(0., 1., 11) + g₂ = equidistant_grid((0.,1.), (1.,3.), 11, 14) @test first_derivative(g₁, stencil_set) isa LazyTensor{Float64,1,1} @test first_derivative(g₂, stencil_set, 2) isa LazyTensor{Float64,2,2} @@ -38,7 +25,9 @@ @testset "Accuracy conditions" begin N = 20 - g = equidistant_grid(N, 0//1,2//1) + g = equidistant_grid(0//1, 2//1, N) + + monomial(x,k) = k < 0 ? zero(x) : x^k/factorial(k) @testset for order ∈ [2,4] stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) D₁ = first_derivative(g, stencil_set) @@ -68,7 +57,7 @@ @testset "Accuracy on function" begin @testset "1D" begin - g = equidistant_grid(30, 0.,1.) + g = equidistant_grid(0., 1., 30) v = eval_on(g, x->exp(x)) @testset for (order, tol) ∈ [(2, 6e-3),(4, 2e-4)] stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) @@ -79,7 +68,7 @@ end @testset "2D" begin - g = equidistant_grid((30,60), (0.,0.),(1.,2.)) + g = equidistant_grid((0.,0.),(1.,2.), 30, 60) v = eval_on(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)