comparison test/SbpOperators/volumeops/derivatives/first_derivative_test.jl @ 989:7bf3121c6864 feature/stencil_set_type

Add type StencilSet
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 17 Mar 2022 21:31:20 +0100
parents 5bfc03cf3ba7
children b6238afd3bb0
comparison
equal deleted inserted replaced
988:83046af6143a 989:7bf3121c6864
20 x^k/factorial(k) 20 x^k/factorial(k)
21 end 21 end
22 22
23 @testset "first_derivative" begin 23 @testset "first_derivative" begin
24 @testset "Constructors" begin 24 @testset "Constructors" begin
25 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2) 25 stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order=2)
26 26
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 TensorMapping{Float64,1,1} 30 @test first_derivative(g₁, stencil_set, 1) isa TensorMapping{Float64,1,1}
40 40
41 @testset "Accuracy conditions" begin 41 @testset "Accuracy conditions" begin
42 N = 20 42 N = 20
43 g = EquidistantGrid(N, 0//1,2//1) 43 g = EquidistantGrid(N, 0//1,2//1)
44 @testset for order ∈ [2,4] 44 @testset for order ∈ [2,4]
45 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) 45 stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order)
46 D₁ = first_derivative(g, stencil_set, 1) 46 D₁ = first_derivative(g, stencil_set, 1)
47 47
48 @testset "boundary x^$k" for k ∈ 0:order÷2 48 @testset "boundary x^$k" for k ∈ 0:order÷2
49 v = evalOn(g, x->monomial(x,k)) 49 v = evalOn(g, x->monomial(x,k))
50 50
70 70
71 @testset "Accuracy on function" begin 71 @testset "Accuracy on function" begin
72 g = EquidistantGrid(30, 0.,1.) 72 g = EquidistantGrid(30, 0.,1.)
73 v = evalOn(g, x->exp(x)) 73 v = evalOn(g, x->exp(x))
74 @testset for (order, tol) ∈ [(2, 6e-3),(4, 2e-4)] 74 @testset for (order, tol) ∈ [(2, 6e-3),(4, 2e-4)]
75 stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) 75 stencil_set = StencilSet(sbp_operators_path()*"standard_diagonal.toml"; order)
76 D₁ = first_derivative(g, stencil_set, 1) 76 D₁ = first_derivative(g, stencil_set, 1)
77 77
78 @test D₁*v ≈ v rtol=tol 78 @test D₁*v ≈ v rtol=tol
79 end 79 end
80 end 80 end