diff test/SbpOperators/stencil_test.jl @ 1061:d1ddcdc098bf feature/nested_stencils

Add promotion functionality for NestedTuples (grafted from cd6d71781137b29d5a9a16b7162051163e4314a4)
author Jonatan Werpers <jonatan@werpers.com>
date Sun, 13 Feb 2022 21:40:23 +0100
parents ff0e819f2075
children a7f898b1ce1e
line wrap: on
line diff
--- a/test/SbpOperators/stencil_test.jl	Sat Feb 12 22:02:06 2022 +0100
+++ b/test/SbpOperators/stencil_test.jl	Sun Feb 13 21:40:23 2022 +0100
@@ -87,6 +87,21 @@
         @test convert(NestedStencil{Rational}, ns) == NestedStencil((-1//1,1//1,0//1),(-1//1,0//1,1//1),(0//1,-1//1,1//1), center=2)
     end
 
+    @testset "promotion of weights" begin
+        @test NestedStencil((-1,1,0),(-1.,0.,1.),(0,-1,1), center=2) isa NestedStencil{Float64,3,3}
+        @test NestedStencil((-1,1,0),(-1,0,1),(0//1,-1,1), center=2) isa NestedStencil{Rational{Int64},3,3}
+    end
+
+    @testset "promotion" begin
+        promote(
+            CenteredNestedStencil((-1,1,0),(-1,0,1),(0,-1,1)),
+            CenteredNestedStencil((-1.,1.,0.),(-1.,0.,1.),(0.,-1.,1.))
+        ) == (
+            CenteredNestedStencil((-1.,1.,0.),(-1.,0.,1.),(0.,-1.,1.)),
+            CenteredNestedStencil((-1.,1.,0.),(-1.,0.,1.),(0.,-1.,1.))
+        )
+    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]