diff DiffOps/test/runtests.jl @ 239:60011a10e17d boundary_conditions

Add tests for BoundaryValue and fix index types
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 26 Jun 2019 20:02:01 +0200
parents a5fdc00d5070
children 9819243102dd
line wrap: on
line diff
--- a/DiffOps/test/runtests.jl	Wed Jun 26 20:01:10 2019 +0200
+++ b/DiffOps/test/runtests.jl	Wed Jun 26 20:02:01 2019 +0200
@@ -9,19 +9,19 @@
 
 @testset "BoundaryValue" begin
     op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
-    g = EquidistantGrid((3,3), (0.0, 0.0), (1.0,1.0))
+    g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0))
 
     e_w = BoundaryValue(op, g, CartesianBoundary{1,Lower}())
     e_e = BoundaryValue(op, g, CartesianBoundary{1,Upper}())
     e_s = BoundaryValue(op, g, CartesianBoundary{2,Lower}())
     e_n = BoundaryValue(op, g, CartesianBoundary{2,Upper}())
 
-    v = [
-        1 2 3;
-        4 5 6;
-        7 8 9.0;
-        10 11 12;
-    ]
+    v = zeros(Float64, 4, 5)
+    v[:,5] = [1, 2, 3,4]
+    v[:,4] = [1, 2, 3,4]
+    v[:,3] = [4, 5, 6, 7]
+    v[:,2] = [7, 8, 9, 10]
+    v[:,1] = [10, 11, 12, 13]
 
     @test e_w  isa TensorMapping{T,2,1} where T
     @test e_w' isa TensorMapping{T,1,2} where T
@@ -31,7 +31,14 @@
     @test domain_size(e_s, (3,2)) == (3,)
     @test domain_size(e_n, (3,2)) == (3,)
 
+    @test size(e_w'*v) == (5,)
+    @test size(e_e'*v) == (5,)
+    @test size(e_s'*v) == (4,)
+    @test size(e_n'*v) == (4,)
 
-    @test collect(e_w'*v) == [1,4,7.0]
+    @test collect(e_w'*v) == [10,7,4,1.0,1]
+    @test collect(e_e'*v) == [13,10,7,4,4.0]
+    @test collect(e_s'*v) == [10,11,12,13.0]
+    @test collect(e_n'*v) == [1,2,3,4.0]
 
 end