comparison test/Grids/mapped_grid_test.jl @ 1571:c2620118f110 feature/grids/manifolds

Merge feature/grids/curvilinear
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 25 Apr 2024 14:00:40 +0200
parents 473cf7677e0f 063a2bfb03da
children aeb561754248
comparison
equal deleted inserted replaced
1569:473cf7677e0f 1571:c2620118f110
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 186
187 187
188 @testset "mapped_grid(::Chart,J)" begin 188 @testset "mapped_grid(::Chart,J)" begin