comparison test/Grids/mapped_grid_test.jl @ 1570:063a2bfb03da feature/grids/curvilinear

Fix bugs in calls to equidistant_grid after merge with default
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 25 Apr 2024 13:57:42 +0200
parents 5d32ecb98db8
children c2620118f110 3bbcd496e021
comparison
equal deleted inserted replaced
1560:5d32ecb98db8 1570:063a2bfb03da
2 using Sbplib.RegionIndices 2 using Sbplib.RegionIndices
3 using Test 3 using Test
4 using StaticArrays 4 using StaticArrays
5 5
6 @testset "MappedGrid" begin 6 @testset "MappedGrid" begin
7 lg = equidistant_grid((11,11), (0,0), (1,1)) # TODO: Change dims of the grid to be different 7 lg = equidistant_grid((0,0), (1,1), 11, 11) # TODO: Change dims of the grid to be different
8 x̄ = map(ξ̄ -> 2ξ̄, lg) 8 x̄ = map(ξ̄ -> 2ξ̄, lg)
9 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg) 9 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg)
10 mg = MappedGrid(lg, x̄, J) 10 mg = MappedGrid(lg, x̄, J)
11 11
12 # TODO: Test constructor for different dims of range and domain for the coordinates 12 # TODO: Test constructor for different dims of range and domain for the coordinates
62 end 62 end
63 # TODO: Test with different types of logical grids 63 # TODO: Test with different types of logical grids
64 64
65 @testset "Iterator interface" begin 65 @testset "Iterator interface" begin
66 sg = MappedGrid( 66 sg = MappedGrid(
67 equidistant_grid((15,11), (0,0), (1,1)), 67 equidistant_grid((0,0), (1,1), 15, 11),
68 map(ξ̄ -> @SArray[ξ̄[1], ξ̄[2], -ξ̄[1]], lg), rand(SMatrix{2,3,Float64},15,11) 68 map(ξ̄ -> @SArray[ξ̄[1], ξ̄[2], -ξ̄[1]], lg), rand(SMatrix{2,3,Float64},15,11)
69 ) 69 )
70 70
71 @test eltype(mg) == SVector{2,Float64} 71 @test eltype(mg) == SVector{2,Float64}
72 @test eltype(sg) == SVector{3,Float64} 72 @test eltype(sg) == SVector{3,Float64}
178 η*(2ξ-1) 1+ξ*(ξ-1); 178 η*(2ξ-1) 1+ξ*(ξ-1);
179 ] 179 ]
180 mg = mapped_grid(x̄, J, 10, 11) 180 mg = mapped_grid(x̄, J, 10, 11)
181 @test mg isa MappedGrid{SVector{2,Float64}, 2} 181 @test mg isa MappedGrid{SVector{2,Float64}, 2}
182 182
183 lg = equidistant_grid((10,11), (0,0), (1,1)) 183 lg = equidistant_grid((0,0), (1,1), 10, 11)
184 @test logicalgrid(mg) == lg 184 @test logicalgrid(mg) == lg
185 @test collect(mg) == map(x̄, lg) 185 @test collect(mg) == map(x̄, lg)
186 end 186 end