Mercurial > repos > public > sbplib_julia
comparison test/Grids/mapped_grid_test.jl @ 1707:519a8cb1439e feature/grids/curvilinear
Change dimensions of testing grid to be different
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Wed, 04 Sep 2024 15:53:19 +0200 |
| parents | 11640aa3e348 |
| children | 36986b75bf98 |
comparison
equal
deleted
inserted
replaced
| 1706:11640aa3e348 | 1707:519a8cb1439e |
|---|---|
| 26 | 26 |
| 27 return x̄, J | 27 return x̄, J |
| 28 end | 28 end |
| 29 | 29 |
| 30 @testset "MappedGrid" begin | 30 @testset "MappedGrid" begin |
| 31 lg = equidistant_grid((0,0), (1,1), 11, 11) # TODO: Change dims of the grid to be different | 31 lg = equidistant_grid((0,0), (1,1), 11, 21) |
| 32 x̄ = map(ξ̄ -> 2ξ̄, lg) | 32 x̄ = map(ξ̄ -> 2ξ̄, lg) |
| 33 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg) | 33 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg) |
| 34 mg = MappedGrid(lg, x̄, J) | 34 mg = MappedGrid(lg, x̄, J) |
| 35 | 35 |
| 36 # TODO: Test constructor for different dims of range and domain for the coordinates | 36 # TODO: Test constructor for different dims of range and domain for the coordinates |
| 46 @test logicalgrid(mg) isa Grid | 46 @test logicalgrid(mg) isa Grid |
| 47 | 47 |
| 48 @testset "Indexing Interface" begin | 48 @testset "Indexing Interface" begin |
| 49 mg = MappedGrid(lg, x̄, J) | 49 mg = MappedGrid(lg, x̄, J) |
| 50 @test mg[1,1] == [0.0, 0.0] | 50 @test mg[1,1] == [0.0, 0.0] |
| 51 @test mg[4,2] == [0.6, 0.2] | 51 @test mg[4,2] == [0.6, 0.1] |
| 52 @test mg[6,10] == [1., 1.8] | 52 @test mg[6,10] == [1., 0.9] |
| 53 | 53 |
| 54 @test mg[begin, begin] == [0.0, 0.0] | 54 @test mg[begin, begin] == [0.0, 0.0] |
| 55 @test mg[end,end] == [2.0, 2.0] | 55 @test mg[end,end] == [2.0, 2.0] |
| 56 @test mg[begin,end] == [0., 2.] | 56 @test mg[begin,end] == [0., 2.] |
| 57 | 57 |
| 58 @test eachindex(mg) == CartesianIndices((11,11)) | 58 @test axes(mg) == (1:11, 1:21) |
| 59 @test axes(mg) == (1:11, 1:11) | |
| 60 | 59 |
| 61 @testset "cartesian indexing" begin | 60 @testset "cartesian indexing" begin |
| 62 cases = [ | 61 cases = [ |
| 63 (1,1) , | 62 (1,1) , |
| 64 (3,5) , | 63 (3,5) , |
| 71 @test mg[CartesianIndex(is...)] == mg[is...] | 70 @test mg[CartesianIndex(is...)] == mg[is...] |
| 72 end | 71 end |
| 73 end | 72 end |
| 74 | 73 |
| 75 @testset "eachindex" begin | 74 @testset "eachindex" begin |
| 76 @test eachindex(mg) == CartesianIndices((11,11)) | 75 @test eachindex(mg) == CartesianIndices((11,21)) |
| 77 end | 76 end |
| 78 | 77 |
| 79 @testset "firstindex" begin | 78 @testset "firstindex" begin |
| 80 @test firstindex(mg, 1) == 1 | 79 @test firstindex(mg, 1) == 1 |
| 81 @test firstindex(mg, 2) == 1 | 80 @test firstindex(mg, 2) == 1 |
| 82 end | 81 end |
| 83 | 82 |
| 84 @testset "lastindex" begin | 83 @testset "lastindex" begin |
| 85 @test lastindex(mg, 1) == 11 | 84 @test lastindex(mg, 1) == 11 |
| 86 @test lastindex(mg, 2) == 11 | 85 @test lastindex(mg, 2) == 21 |
| 87 end | 86 end |
| 88 end | 87 end |
| 89 # TODO: Test with different types of logical grids | 88 # TODO: Test with different types of logical grids |
| 90 | 89 |
| 91 @testset "Iterator interface" begin | 90 @testset "Iterator interface" begin |
| 98 @test eltype(sg) == SVector{3,Float64} | 97 @test eltype(sg) == SVector{3,Float64} |
| 99 | 98 |
| 100 @test eltype(typeof(mg)) == SVector{2,Float64} | 99 @test eltype(typeof(mg)) == SVector{2,Float64} |
| 101 @test eltype(typeof(sg)) == SVector{3,Float64} | 100 @test eltype(typeof(sg)) == SVector{3,Float64} |
| 102 | 101 |
| 103 @test size(mg) == (11,11) | 102 @test size(mg) == (11,21) |
| 104 @test size(sg) == (15,11) | 103 @test size(sg) == (15,11) |
| 105 | 104 |
| 106 @test size(mg,2) == 11 | 105 @test size(mg,2) == 21 |
| 107 @test size(sg,2) == 11 | 106 @test size(sg,2) == 11 |
| 108 | 107 |
| 109 @test length(mg) == 121 | 108 @test length(mg) == 231 |
| 110 @test length(sg) == 165 | 109 @test length(sg) == 165 |
| 111 | 110 |
| 112 @test Base.IteratorSize(mg) == Base.HasShape{2}() | 111 @test Base.IteratorSize(mg) == Base.HasShape{2}() |
| 113 @test Base.IteratorSize(typeof(mg)) == Base.HasShape{2}() | 112 @test Base.IteratorSize(typeof(mg)) == Base.HasShape{2}() |
| 114 | 113 |
