comparison test/SbpOperators/stencil_test.jl @ 1445:76a121ee7b80 bugfix/sbp_operators/stencil_return_type

Add tests for apply with NestedStencils and differing types in the stencils and arrays
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 24 Nov 2023 21:23:41 +0100
parents c779af4d02e5
children d744b01be520
comparison
equal deleted inserted replaced
1444:c779af4d02e5 1445:76a121ee7b80
179 @test SbpOperators.apply_inner_stencils(ns, c, 4) == Stencil(5,11,6; center=1) 179 @test SbpOperators.apply_inner_stencils(ns, c, 4) == Stencil(5,11,6; center=1)
180 @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) == Stencil(-4,-7,-3; center=1) 180 @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) == Stencil(-4,-7,-3; center=1)
181 181
182 @test SbpOperators.apply_stencil(ns, c, v, 4) == 5*7 + 11*11 + 6*13 182 @test SbpOperators.apply_stencil(ns, c, v, 4) == 5*7 + 11*11 + 6*13
183 @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) == -3*3 - 7*5 - 4*7 183 @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) == -3*3 - 7*5 - 4*7
184
185 # Different types in vector and stencil
186 ns = NestedStencil((-1.,1.,0.),(-1.,0.,1.),(0.,-2.,2.), center=2)
187 @test SbpOperators.apply_inner_stencils(ns, c, 4) isa Stencil{Float64, 3}
188 @test SbpOperators.apply_inner_stencils(ns, c, 4) == Stencil(4.,9.,10.; center=2)
189 @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) isa Stencil{Float64, 3}
190 @test SbpOperators.apply_inner_stencils_backwards(ns, c, 4) == Stencil(-5.,-9.,-8.; center=2)
191
192 @test SbpOperators.apply_stencil(ns, c, v, 4) isa Float64
193 @test SbpOperators.apply_stencil(ns, c, v, 4) == 193.
194 @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) isa Float64
195 @test SbpOperators.apply_stencil_backwards(ns, c, v, 4) == -158.
184 end 196 end
185 197
186 @testset "type stability" begin 198 @testset "type stability" begin
187 s_int = CenteredNestedStencil((1,2,3),(1,2,3),(1,2,3)) 199 s_int = CenteredNestedStencil((1,2,3),(1,2,3),(1,2,3))
188 s_float = CenteredNestedStencil((1.,2.,3.),(1.,2.,3.),(1.,2.,3.)) 200 s_float = CenteredNestedStencil((1.,2.,3.),(1.,2.,3.),(1.,2.,3.))