comparison test/Grids/equidistant_grid_test.jl @ 1125:b9c6b0d8f0fa feature/grids

Add testsets to existing tests
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 05 Oct 2022 21:24:13 +0200
parents c2d7e940639e
children dfbd62c7eb09
comparison
equal deleted inserted replaced
1117:aeeffca46b94 1125:b9c6b0d8f0fa
21 21
22 # dim 22 # dim
23 @test dim(EquidistantGrid(4,0.0,1.0)) == 1 23 @test dim(EquidistantGrid(4,0.0,1.0)) == 1
24 @test dim(EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))) == 2 24 @test dim(EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))) == 2
25 25
26 # spacing 26 @testset "spacing" begin
27 @test [spacing(EquidistantGrid(4,0.0,1.0))...] ≈ [(1. /3,)...] atol=5e-13 27 @test [spacing(EquidistantGrid(4,0.0,1.0))...] ≈ [(1. /3,)...] atol=5e-13
28 @test [spacing(EquidistantGrid((5,3), (0.0,-1.0), (2.0,1.0)))...] ≈ [(0.5, 1.)...] atol=5e-13 28 @test [spacing(EquidistantGrid((5,3), (0.0,-1.0), (2.0,1.0)))...] ≈ [(0.5, 1.)...] atol=5e-13
29
30 # inverse_spacing
31 @test [inverse_spacing(EquidistantGrid(4,0.0,1.0))...] ≈ [(3.,)...] atol=5e-13
32 @test [inverse_spacing(EquidistantGrid((5,3), (0.0,-1.0), (2.0,1.0)))...] ≈ [(2, 1.)...] atol=5e-13
33
34 # points
35 g = EquidistantGrid((5,3), (-1.0,0.0), (0.0,7.11))
36 gp = points(g);
37 p = [(-1.,0.) (-1.,7.11/2) (-1.,7.11);
38 (-0.75,0.) (-0.75,7.11/2) (-0.75,7.11);
39 (-0.5,0.) (-0.5,7.11/2) (-0.5,7.11);
40 (-0.25,0.) (-0.25,7.11/2) (-0.25,7.11);
41 (0.,0.) (0.,7.11/2) (0.,7.11)]
42 for i ∈ eachindex(gp)
43 @test [gp[i]...] ≈ [p[i]...] atol=5e-13
44 end 29 end
45 30
46 # restrict 31 @testset "inverse_spacing" begin
47 g = EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0)) 32 @test [inverse_spacing(EquidistantGrid(4,0.0,1.0))...] ≈ [(3.,)...] atol=5e-13
48 @test restrict(g, 1) == EquidistantGrid(5,0.0,2.0) 33 @test [inverse_spacing(EquidistantGrid((5,3), (0.0,-1.0), (2.0,1.0)))...] ≈ [(2, 1.)...] atol=5e-13
49 @test restrict(g, 2) == EquidistantGrid(3,0.0,1.0) 34 end
50 35
51 g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0)) 36 @testset "points" begin
52 @test restrict(g, 1) == EquidistantGrid(2,0.0,2.0) 37 g = EquidistantGrid((5,3), (-1.0,0.0), (0.0,7.11))
53 @test restrict(g, 2) == EquidistantGrid(5,0.0,1.0) 38 gp = points(g);
54 @test restrict(g, 3) == EquidistantGrid(3,0.0,3.0) 39 p = [(-1.,0.) (-1.,7.11/2) (-1.,7.11);
55 @test restrict(g, 1:2) == EquidistantGrid((2,5),(0.0,0.0),(2.0,1.0)) 40 (-0.75,0.) (-0.75,7.11/2) (-0.75,7.11);
56 @test restrict(g, 2:3) == EquidistantGrid((5,3),(0.0,0.0),(1.0,3.0)) 41 (-0.5,0.) (-0.5,7.11/2) (-0.5,7.11);
57 @test restrict(g, [1,3]) == EquidistantGrid((2,3),(0.0,0.0),(2.0,3.0)) 42 (-0.25,0.) (-0.25,7.11/2) (-0.25,7.11);
58 @test restrict(g, [2,1]) == EquidistantGrid((5,2),(0.0,0.0),(1.0,2.0)) 43 (0.,0.) (0.,7.11/2) (0.,7.11)]
44 for i ∈ eachindex(gp)
45 @test [gp[i]...] ≈ [p[i]...] atol=5e-13
46 end
47 end
48
49 @testset "restrict" begin
50 g = EquidistantGrid((5,3), (0.0,0.0), (2.0,1.0))
51 @test restrict(g, 1) == EquidistantGrid(5,0.0,2.0)
52 @test restrict(g, 2) == EquidistantGrid(3,0.0,1.0)
53
54 g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0))
55 @test restrict(g, 1) == EquidistantGrid(2,0.0,2.0)
56 @test restrict(g, 2) == EquidistantGrid(5,0.0,1.0)
57 @test restrict(g, 3) == EquidistantGrid(3,0.0,3.0)
58 @test restrict(g, 1:2) == EquidistantGrid((2,5),(0.0,0.0),(2.0,1.0))
59 @test restrict(g, 2:3) == EquidistantGrid((5,3),(0.0,0.0),(1.0,3.0))
60 @test restrict(g, [1,3]) == EquidistantGrid((2,3),(0.0,0.0),(2.0,3.0))
61 @test restrict(g, [2,1]) == EquidistantGrid((5,2),(0.0,0.0),(1.0,2.0))
62 end
59 63
60 @testset "boundary_identifiers" begin 64 @testset "boundary_identifiers" begin
61 g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0)) 65 g = EquidistantGrid((2,5,3), (0.0,0.0,0.0), (2.0,1.0,3.0))
62 bids = (CartesianBoundary{1,Lower}(),CartesianBoundary{1,Upper}(), 66 bids = (CartesianBoundary{1,Lower}(),CartesianBoundary{1,Upper}(),
63 CartesianBoundary{2,Lower}(),CartesianBoundary{2,Upper}(), 67 CartesianBoundary{2,Lower}(),CartesianBoundary{2,Upper}(),