Mercurial > repos > public > sbplib_julia
diff 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 |
line wrap: on
line diff
--- a/test/SbpOperators/stencil_test.jl Wed Jan 19 21:49:34 2022 +0100 +++ b/test/SbpOperators/stencil_test.jl Thu Jan 20 10:23:15 2022 +0100 @@ -35,9 +35,9 @@ @testset "NestedStencil" begin @testset "Constructors" begin - s1 = Stencil(-1, 1, 0; center = 1) - s2 = Stencil(-1, 0, 1; center = 2) - s3 = Stencil( 0,-1, 1; center = 3) + s1 = CenteredStencil(-1, 1, 0) + s2 = CenteredStencil(-1, 0, 1) + s3 = CenteredStencil( 0,-1, 1) ns = NestedStencil(CenteredStencil(s1,s2,s3)) @test ns isa NestedStencil{Int,3} @@ -51,7 +51,19 @@ @testset "Error handling" begin - end end + + @testset "apply" begin + c = [ 1, 3, 6, 10, 15, 21, 28, 36, 45, 55] + v = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29] + + ns = NestedStencil((-1,1,0),(-1,0,1),(0,-2,2), center=2) + + @test SbpOperators.apply_inner_stencils(ns, c, 4) == Stencil(4,9,10; center=2) + @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) == Stencil(-5,-9,-8; center=2) + + @test SbpOperators.apply_stencil(ns, c, v, 4) == 4*5 + 9*7 + 10*11 + @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) == -8*5 - 9*7 - 5*11 + end end