Mercurial > repos > public > sbplib_julia
comparison test/SbpOperators/stencil_test.jl @ 1054:ce16519aa7ff feature/nested_stencils
Tests for non centered nested stencils
(grafted from 0fe46190a81a3c4cb36911d78e223ff9d398bd44)
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 20 Jan 2022 13:35:21 +0100 |
parents | cb0a5f41be02 |
children | 011d3ff65e9f |
comparison
equal
deleted
inserted
replaced
1053:cb0a5f41be02 | 1054:ce16519aa7ff |
---|---|
46 | 46 |
47 @test NestedStencil(s1,s2,s3, center = 2) == ns | 47 @test NestedStencil(s1,s2,s3, center = 2) == ns |
48 @test NestedStencil(s1,s2,s3, center = 1) == NestedStencil(Stencil(s1,s2,s3, center=1)) | 48 @test NestedStencil(s1,s2,s3, center = 1) == NestedStencil(Stencil(s1,s2,s3, center=1)) |
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 @test NestedStencil((-1,1,0),(-1,0,1),(0,-1,1), center=1) == NestedStencil(Stencil( | |
52 Stencil(-1, 1, 0; center=1), | |
53 Stencil(-1, 0, 1; center=1), | |
54 Stencil( 0,-1, 1; center=1); | |
55 center=1 | |
56 )) | |
51 | 57 |
52 | 58 |
53 @testset "Error handling" begin | 59 @testset "Error handling" begin |
54 end | 60 end |
55 end | 61 end |
56 | 62 |
57 @testset "apply" begin | 63 @testset "apply" begin |
58 c = [ 1, 3, 6, 10, 15, 21, 28, 36, 45, 55] | 64 c = [ 1, 3, 6, 10, 15, 21, 28, 36, 45, 55] |
59 v = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29] | 65 v = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29] |
60 | 66 |
67 # Centered | |
61 ns = NestedStencil((-1,1,0),(-1,0,1),(0,-2,2), center=2) | 68 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) | 69 @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) | 70 @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) == Stencil(-5,-9,-8; center=2) |
65 | 71 |
66 @test SbpOperators.apply_stencil(ns, c, v, 4) == 4*5 + 9*7 + 10*11 | 72 @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 | 73 @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) == -8*5 - 9*7 - 5*11 |
74 | |
75 # Non-centered | |
76 ns = NestedStencil((-1,1,0),(-1,0,1),(0,-1,1), center=1) | |
77 @test SbpOperators.apply_inner_stencils(ns, c, 4) == Stencil(5,11,6; center=1) | |
78 @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) == Stencil(-4,-7,-3; center=1) | |
79 | |
80 @test SbpOperators.apply_stencil(ns, c, v, 4) == 5*7 + 11*11 + 6*13 | |
81 @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) == -3*3 - 7*5 - 4*7 | |
68 end | 82 end |
69 end | 83 end |