comparison test/Grids/mapped_grid_test.jl @ 1743:49bd573ab07f feature/grids/curvilinear

Implement checking of sizes for inputs to MappedGrid
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 11 Sep 2024 13:46:33 +0200
parents c9c601678a14
children c38eead8be17
comparison
equal deleted inserted replaced
1742:c9c601678a14 1743:49bd573ab07f
55 @test collect(mg) == x̄ 55 @test collect(mg) == x̄
56 @test jacobian(mg) == J 56 @test jacobian(mg) == J
57 @test logicalgrid(mg) == lg 57 @test logicalgrid(mg) == lg
58 58
59 # TODO: Test that the element types agree 59 # TODO: Test that the element types agree
60 60 sz1 = (10,11)
61 @test_broken false # @test_throws ArgumentError("Sizes must match") MappedGrid(lg, map(ξ̄ -> @SArray[ξ̄[1], ξ̄[2], -ξ̄[1]], lg), rand(SMatrix{2,3,Float64},15,11)) 61 sz2 = (10,12)
62 62 @test_throws ArgumentError("Sizes must match") MappedGrid(
63 equidistant_grid((0,0), (1,1), sz2...),
64 rand(SVector{2},sz1...),
65 rand(SMatrix{2,2},sz1...),
66 )
67
68 @test_throws ArgumentError("Sizes must match") MappedGrid(
69 equidistant_grid((0,0), (1,1), sz1...),
70 rand(SVector{2},sz2...),
71 rand(SMatrix{2,2},sz1...),
72 )
73
74 @test_throws ArgumentError("Sizes must match") MappedGrid(
75 equidistant_grid((0,0), (1,1), sz1...),
76 rand(SVector{2},sz1...),
77 rand(SMatrix{2,2},sz2...),
78 )
63 79
64 end 80 end
65 81
66 @testset "Indexing Interface" begin 82 @testset "Indexing Interface" begin
67 lg = equidistant_grid((0,0), (1,1), 11, 21) 83 lg = equidistant_grid((0,0), (1,1), 11, 21)
109 125
110 @testset "Iterator interface" begin 126 @testset "Iterator interface" begin
111 lg = equidistant_grid((0,0), (1,1), 11, 21) 127 lg = equidistant_grid((0,0), (1,1), 11, 21)
112 x̄ = map(ξ̄ -> 2ξ̄, lg) 128 x̄ = map(ξ̄ -> 2ξ̄, lg)
113 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg) 129 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg)
114 mg = MappedGrid(lg, x̄, J) 130
115 131 mg = MappedGrid(lg, x̄, J)
132
133 lg2 = equidistant_grid((0,0), (1,1), 15, 11)
116 sg = MappedGrid( 134 sg = MappedGrid(
117 equidistant_grid((0,0), (1,1), 15, 11), 135 equidistant_grid((0,0), (1,1), 15, 11),
118 map(ξ̄ -> @SArray[ξ̄[1], ξ̄[2], -ξ̄[1]], lg), rand(SMatrix{2,3,Float64},15,11) 136 map(ξ̄ -> @SArray[ξ̄[1], ξ̄[2], -ξ̄[1]], lg2), rand(SMatrix{2,3,Float64},15,11)
119 ) 137 )
120 138
121 @test eltype(mg) == SVector{2,Float64} 139 @test eltype(mg) == SVector{2,Float64}
122 @test eltype(sg) == SVector{3,Float64} 140 @test eltype(sg) == SVector{3,Float64}
123 141