comparison test/testGrids.jl @ 693:d52902f36868

Merging feature/boundary_quads
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Sat, 13 Feb 2021 16:05:02 +0100
parents e9e46a587370
children
comparison
equal deleted inserted replaced
674:621460cf8279 693:d52902f36868
11 @test_throws DomainError EquidistantGrid(0,0.0,1.0) 11 @test_throws DomainError EquidistantGrid(0,0.0,1.0)
12 @test_throws DomainError EquidistantGrid(1,1.0,1.0) 12 @test_throws DomainError EquidistantGrid(1,1.0,1.0)
13 @test_throws DomainError EquidistantGrid(1,1.0,-1.0) 13 @test_throws DomainError EquidistantGrid(1,1.0,-1.0)
14 @test EquidistantGrid(4,0.0,1.0) == EquidistantGrid((4,),(0.0,),(1.0,)) 14 @test EquidistantGrid(4,0.0,1.0) == EquidistantGrid((4,),(0.0,),(1.0,))
15 15
16 # size 16 @testset "Base" begin
17 @test size(EquidistantGrid(4,0.0,1.0)) == (4,) 17 @test eltype(EquidistantGrid(4,0.0,1.0)) == Float64
18 @test size(EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))) == (5,3) 18 @test eltype(EquidistantGrid((4,3),(0,0),(1,3))) == Int
19 @test size(EquidistantGrid(4,0.0,1.0)) == (4,)
20 @test size(EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))) == (5,3)
21 end
19 22
20 # dimension 23 # dimension
21 @test dimension(EquidistantGrid(4,0.0,1.0)) == 1 24 @test dimension(EquidistantGrid(4,0.0,1.0)) == 1
22 @test dimension(EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))) == 2 25 @test dimension(EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))) == 2
23 26
61 CartesianBoundary{2,Lower}(),CartesianBoundary{2,Upper}(), 64 CartesianBoundary{2,Lower}(),CartesianBoundary{2,Upper}(),
62 CartesianBoundary{3,Lower}(),CartesianBoundary{3,Upper}()) 65 CartesianBoundary{3,Lower}(),CartesianBoundary{3,Upper}())
63 @test boundary_identifiers(g) == bids 66 @test boundary_identifiers(g) == bids
64 @inferred boundary_identifiers(g) 67 @inferred boundary_identifiers(g)
65 end 68 end
69
70 @testset "boundary_grid" begin
71 @testset "1D" begin
72 g = EquidistantGrid(5,0.0,2.0)
73 (id_l, id_r) = boundary_identifiers(g)
74 @test boundary_grid(g,id_l) == EquidistantGrid{Float64}()
75 @test boundary_grid(g,id_r) == EquidistantGrid{Float64}()
76 @test_throws DomainError boundary_grid(g,CartesianBoundary{2,Lower}())
77 @test_throws DomainError boundary_grid(g,CartesianBoundary{0,Lower}())
78 end
79 @testset "2D" begin
80 g = EquidistantGrid((5,3),(0.0,0.0),(1.0,3.0))
81 (id_w, id_e, id_s, id_n) = boundary_identifiers(g)
82 @test boundary_grid(g,id_w) == restrict(g,2)
83 @test boundary_grid(g,id_e) == restrict(g,2)
84 @test boundary_grid(g,id_s) == restrict(g,1)
85 @test boundary_grid(g,id_n) == restrict(g,1)
86 @test_throws DomainError boundary_grid(g,CartesianBoundary{4,Lower}())
87 end
88 @testset "3D" begin
89 g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0))
90 (id_w, id_e,
91 id_s, id_n,
92 id_t, id_b) = boundary_identifiers(g)
93 @test boundary_grid(g,id_w) == restrict(g,[2,3])
94 @test boundary_grid(g,id_e) == restrict(g,[2,3])
95 @test boundary_grid(g,id_s) == restrict(g,[1,3])
96 @test boundary_grid(g,id_n) == restrict(g,[1,3])
97 @test boundary_grid(g,id_t) == restrict(g,[1,2])
98 @test boundary_grid(g,id_b) == restrict(g,[1,2])
99 @test_throws DomainError boundary_grid(g,CartesianBoundary{4,Lower}())
100 end
101 end
66 end 102 end
67 103
68 end 104 end