Mercurial > repos > public > sbplib_julia
comparison test/Grids/mapped_grid_test.jl @ 1584:d7483e8af705 feature/sbp_operators/laplace_curvilinear
Merge feature/grids/manifolds
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 26 Apr 2024 08:45:54 +0200 |
parents | f77c5309dd2b |
children | d4a6f9effcdd |
comparison
equal
deleted
inserted
replaced
1563:6e910408c51a | 1584:d7483e8af705 |
---|---|
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 | |
187 | |
188 @testset "mapped_grid(::Chart)" begin | |
189 c = Chart(unitsquare()) do (ξ,η) | |
190 @SVector[2ξ, 3η] | |
191 end | |
192 Grids.jacobian(c::typeof(c), ξ̄) = @SMatrix[2 0; 0 3] | |
193 | |
194 @test mapped_grid(c, 5, 4) isa Grid | |
195 end | |
196 | |
186 end | 197 end |