changeset 878:0fe46190a81a feature/variable_derivatives

Tests for non centered nested stencils
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 20 Jan 2022 13:35:21 +0100
parents e37ee63bf9ac
children 011d3ff65e9f
files test/SbpOperators/stencil_test.jl
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/SbpOperators/stencil_test.jl	Thu Jan 20 10:23:15 2022 +0100
+++ b/test/SbpOperators/stencil_test.jl	Thu Jan 20 13:35:21 2022 +0100
@@ -48,6 +48,12 @@
         @test NestedStencil(s1,s2,s3, center = 1) == NestedStencil(Stencil(s1,s2,s3, center=1))
 
         @test NestedStencil((-1,1,0),(-1,0,1),(0,-1,1), center=2) == ns
+        @test NestedStencil((-1,1,0),(-1,0,1),(0,-1,1), center=1) == NestedStencil(Stencil(
+            Stencil(-1, 1, 0; center=1),
+            Stencil(-1, 0, 1; center=1),
+            Stencil( 0,-1, 1; center=1);
+            center=1
+        ))
 
 
         @testset "Error handling" begin
@@ -58,12 +64,20 @@
         c = [  1,  3,  6, 10, 15, 21, 28, 36, 45, 55]
         v = [  2,  3,  5,  7, 11, 13, 17, 19, 23, 29]
 
+        # Centered
         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
+
+        # Non-centered
+        ns = NestedStencil((-1,1,0),(-1,0,1),(0,-1,1), center=1)
+        @test SbpOperators.apply_inner_stencils(ns, c, 4) == Stencil(5,11,6; center=1)
+        @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) == Stencil(-4,-7,-3; center=1)
+
+        @test SbpOperators.apply_stencil(ns, c, v, 4) == 5*7 + 11*11 + 6*13
+        @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) == -3*3 - 7*5 - 4*7
     end
 end