comparison 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
comparison
equal deleted inserted replaced
238:d56bf288b3be 239:60011a10e17d
7 7
8 @test_broken false 8 @test_broken false
9 9
10 @testset "BoundaryValue" begin 10 @testset "BoundaryValue" begin
11 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt") 11 op = readOperator(sbp_operators_path()*"d2_4th.txt",sbp_operators_path()*"h_4th.txt")
12 g = EquidistantGrid((3,3), (0.0, 0.0), (1.0,1.0)) 12 g = EquidistantGrid((4,5), (0.0, 0.0), (1.0,1.0))
13 13
14 e_w = BoundaryValue(op, g, CartesianBoundary{1,Lower}()) 14 e_w = BoundaryValue(op, g, CartesianBoundary{1,Lower}())
15 e_e = BoundaryValue(op, g, CartesianBoundary{1,Upper}()) 15 e_e = BoundaryValue(op, g, CartesianBoundary{1,Upper}())
16 e_s = BoundaryValue(op, g, CartesianBoundary{2,Lower}()) 16 e_s = BoundaryValue(op, g, CartesianBoundary{2,Lower}())
17 e_n = BoundaryValue(op, g, CartesianBoundary{2,Upper}()) 17 e_n = BoundaryValue(op, g, CartesianBoundary{2,Upper}())
18 18
19 v = [ 19 v = zeros(Float64, 4, 5)
20 1 2 3; 20 v[:,5] = [1, 2, 3,4]
21 4 5 6; 21 v[:,4] = [1, 2, 3,4]
22 7 8 9.0; 22 v[:,3] = [4, 5, 6, 7]
23 10 11 12; 23 v[:,2] = [7, 8, 9, 10]
24 ] 24 v[:,1] = [10, 11, 12, 13]
25 25
26 @test e_w isa TensorMapping{T,2,1} where T 26 @test e_w isa TensorMapping{T,2,1} where T
27 @test e_w' isa TensorMapping{T,1,2} where T 27 @test e_w' isa TensorMapping{T,1,2} where T
28 28
29 @test domain_size(e_w, (3,2)) == (2,) 29 @test domain_size(e_w, (3,2)) == (2,)
30 @test domain_size(e_e, (3,2)) == (2,) 30 @test domain_size(e_e, (3,2)) == (2,)
31 @test domain_size(e_s, (3,2)) == (3,) 31 @test domain_size(e_s, (3,2)) == (3,)
32 @test domain_size(e_n, (3,2)) == (3,) 32 @test domain_size(e_n, (3,2)) == (3,)
33 33
34 @test size(e_w'*v) == (5,)
35 @test size(e_e'*v) == (5,)
36 @test size(e_s'*v) == (4,)
37 @test size(e_n'*v) == (4,)
34 38
35 @test collect(e_w'*v) == [1,4,7.0] 39 @test collect(e_w'*v) == [10,7,4,1.0,1]
40 @test collect(e_e'*v) == [13,10,7,4,4.0]
41 @test collect(e_s'*v) == [10,11,12,13.0]
42 @test collect(e_n'*v) == [1,2,3,4.0]
36 43
37 end 44 end