comparison test/SbpOperators/stencil_test.jl @ 868:e37ee63bf9ac feature/variable_derivatives

Add some tests and fix some bugs
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 20 Jan 2022 10:23:15 +0100
parents 313648b01504
children 0fe46190a81a
comparison
equal deleted inserted replaced
867:313648b01504 868:e37ee63bf9ac
33 end 33 end
34 34
35 @testset "NestedStencil" begin 35 @testset "NestedStencil" begin
36 36
37 @testset "Constructors" begin 37 @testset "Constructors" begin
38 s1 = Stencil(-1, 1, 0; center = 1) 38 s1 = CenteredStencil(-1, 1, 0)
39 s2 = Stencil(-1, 0, 1; center = 2) 39 s2 = CenteredStencil(-1, 0, 1)
40 s3 = Stencil( 0,-1, 1; center = 3) 40 s3 = CenteredStencil( 0,-1, 1)
41 41
42 ns = NestedStencil(CenteredStencil(s1,s2,s3)) 42 ns = NestedStencil(CenteredStencil(s1,s2,s3))
43 @test ns isa NestedStencil{Int,3} 43 @test ns isa NestedStencil{Int,3}
44 44
45 @test CenteredNestedStencil(s1,s2,s3) == ns 45 @test CenteredNestedStencil(s1,s2,s3) == ns
49 49
50 @test NestedStencil((-1,1,0),(-1,0,1),(0,-1,1), center=2) == ns 50 @test NestedStencil((-1,1,0),(-1,0,1),(0,-1,1), center=2) == ns
51 51
52 52
53 @testset "Error handling" begin 53 @testset "Error handling" begin
54
55 end 54 end
56 end 55 end
56
57 @testset "apply" begin
58 c = [ 1, 3, 6, 10, 15, 21, 28, 36, 45, 55]
59 v = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
60
61 ns = NestedStencil((-1,1,0),(-1,0,1),(0,-2,2), center=2)
62
63 @test SbpOperators.apply_inner_stencils(ns, c, 4) == Stencil(4,9,10; center=2)
64 @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) == Stencil(-5,-9,-8; center=2)
65
66 @test SbpOperators.apply_stencil(ns, c, v, 4) == 4*5 + 9*7 + 10*11
67 @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) == -8*5 - 9*7 - 5*11
68 end
57 end 69 end