Mercurial > repos > public > sbplib_julia
comparison test/Grids/mapped_grid_test.jl @ 1744:c38eead8be17 feature/grids/curvilinear
Add checks for the size of the jacobian
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 11 Sep 2024 14:11:03 +0200 |
parents | 49bd573ab07f |
children | 2f7974367cd3 |
comparison
equal
deleted
inserted
replaced
1743:49bd573ab07f | 1744:c38eead8be17 |
---|---|
54 | 54 |
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 | |
60 sz1 = (10,11) | 59 sz1 = (10,11) |
61 sz2 = (10,12) | 60 sz2 = (10,12) |
62 @test_throws ArgumentError("Sizes must match") MappedGrid( | 61 @test_throws ArgumentError("Sizes must match") MappedGrid( |
63 equidistant_grid((0,0), (1,1), sz2...), | 62 equidistant_grid((0,0), (1,1), sz2...), |
64 rand(SVector{2},sz1...), | 63 rand(SVector{2},sz1...), |
75 equidistant_grid((0,0), (1,1), sz1...), | 74 equidistant_grid((0,0), (1,1), sz1...), |
76 rand(SVector{2},sz1...), | 75 rand(SVector{2},sz1...), |
77 rand(SMatrix{2,2},sz2...), | 76 rand(SMatrix{2,2},sz2...), |
78 ) | 77 ) |
79 | 78 |
79 # TODO: Test that the element types agree | |
80 err_str = "The size of the jacobian must match the dimensions of the grid and coordinates" | |
81 @test_throws ArgumentError(err_str) MappedGrid( | |
82 equidistant_grid((0,0), (1,1), 10, 11), | |
83 rand(SVector{3}, 10, 11), | |
84 rand(SMatrix{3,4}, 10, 11), | |
85 ) | |
86 | |
87 @test_throws ArgumentError(err_str) MappedGrid( | |
88 equidistant_grid((0,0), (1,1), 10, 11), | |
89 rand(SVector{3}, 10, 11), | |
90 rand(SMatrix{4,2}, 10, 11), | |
91 ) | |
80 end | 92 end |
81 | 93 |
82 @testset "Indexing Interface" begin | 94 @testset "Indexing Interface" begin |
83 lg = equidistant_grid((0,0), (1,1), 11, 21) | 95 lg = equidistant_grid((0,0), (1,1), 11, 21) |
84 x̄ = map(ξ̄ -> 2ξ̄, lg) | 96 x̄ = map(ξ̄ -> 2ξ̄, lg) |
131 mg = MappedGrid(lg, x̄, J) | 143 mg = MappedGrid(lg, x̄, J) |
132 | 144 |
133 lg2 = equidistant_grid((0,0), (1,1), 15, 11) | 145 lg2 = equidistant_grid((0,0), (1,1), 15, 11) |
134 sg = MappedGrid( | 146 sg = MappedGrid( |
135 equidistant_grid((0,0), (1,1), 15, 11), | 147 equidistant_grid((0,0), (1,1), 15, 11), |
136 map(ξ̄ -> @SArray[ξ̄[1], ξ̄[2], -ξ̄[1]], lg2), rand(SMatrix{2,3,Float64},15,11) | 148 map(ξ̄ -> @SArray[ξ̄[1], ξ̄[2], -ξ̄[1]], lg2), rand(SMatrix{3,2,Float64},15,11) |
137 ) | 149 ) |
138 | 150 |
139 @test eltype(mg) == SVector{2,Float64} | 151 @test eltype(mg) == SVector{2,Float64} |
140 @test eltype(sg) == SVector{3,Float64} | 152 @test eltype(sg) == SVector{3,Float64} |
141 | 153 |
181 | 193 |
182 @testset "==" begin | 194 @testset "==" begin |
183 sz = (15,11) | 195 sz = (15,11) |
184 lg = equidistant_grid((0,0), (1,1), sz...) | 196 lg = equidistant_grid((0,0), (1,1), sz...) |
185 x = rand(SVector{3,Float64}, sz...) | 197 x = rand(SVector{3,Float64}, sz...) |
186 J = rand(SMatrix{2,3,Float64}, sz...) | 198 J = rand(SMatrix{3,2,Float64}, sz...) |
187 | 199 |
188 sg = MappedGrid(lg, x, J) | 200 sg = MappedGrid(lg, x, J) |
189 | 201 |
190 sg1 = MappedGrid(equidistant_grid((0,0), (1,1), sz...), copy(x), copy(J)) | 202 sg1 = MappedGrid(equidistant_grid((0,0), (1,1), sz...), copy(x), copy(J)) |
191 | 203 |
192 sz2 = (15,12) | 204 sz2 = (15,12) |
193 lg2 = equidistant_grid((0,0), (1,1), sz2...) | 205 lg2 = equidistant_grid((0,0), (1,1), sz2...) |
194 x2 = rand(SVector{3,Float64}, sz2...) | 206 x2 = rand(SVector{3,Float64}, sz2...) |
195 J2 = rand(SMatrix{2,3,Float64}, sz2...) | 207 J2 = rand(SMatrix{3,2,Float64}, sz2...) |
196 sg2 = MappedGrid(lg2, x2, J2) | 208 sg2 = MappedGrid(lg2, x2, J2) |
197 | 209 |
198 sg3 = MappedGrid(lg, rand(SVector{3,Float64}, sz...), J) | 210 sg3 = MappedGrid(lg, rand(SVector{3,Float64}, sz...), J) |
199 sg4 = MappedGrid(lg, x, rand(SMatrix{2,3,Float64}, sz...)) | 211 sg4 = MappedGrid(lg, x, rand(SMatrix{3,2,Float64}, sz...)) |
200 | 212 |
201 @test sg == sg1 | 213 @test sg == sg1 |
202 @test sg != sg2 # Different size | 214 @test sg != sg2 # Different size |
203 @test sg != sg3 # Different coordinates | 215 @test sg != sg3 # Different coordinates |
204 @test sg != sg4 # Different jacobian | 216 @test sg != sg4 # Different jacobian |