comparison test/Grids/mapped_grid_test.jl @ 1742:c9c601678a14 feature/grids/curvilinear

Add test for construction of Rn->Rm grid
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 11 Sep 2024 12:09:59 +0200
parents 248304f88e49
children 49bd573ab07f
comparison
equal deleted inserted replaced
1741:248304f88e49 1742:c9c601678a14
29 29
30 @testset "MappedGrid" begin 30 @testset "MappedGrid" begin
31 @testset "Constructor" begin 31 @testset "Constructor" begin
32 lg = equidistant_grid((0,0), (1,1), 11, 21) 32 lg = equidistant_grid((0,0), (1,1), 11, 21)
33 33
34
35 x̄ = map(ξ̄ -> 2ξ̄, lg) 34 x̄ = map(ξ̄ -> 2ξ̄, lg)
36 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg) 35 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), lg)
37 mg = MappedGrid(lg, x̄, J) 36 mg = MappedGrid(lg, x̄, J)
38 37
39 @test mg isa Grid{SVector{2, Float64},2} 38 @test mg isa Grid{SVector{2, Float64},2}
42 41
43 @test collect(mg) == x̄ 42 @test collect(mg) == x̄
44 @test jacobian(mg) == J 43 @test jacobian(mg) == J
45 @test logicalgrid(mg) == lg 44 @test logicalgrid(mg) == lg
46 45
47 # TODO: Test constructor for different dims of range and domain for the coordinates 46
48 # TODO: Test constructor with different type than TensorGrid. a dummy type? 47 x̄ = map(ξ̄ -> @SVector[ξ̄[1],ξ̄[2], ξ̄[1] + ξ̄[2]], lg)
48 J = map(ξ̄ -> @SMatrix[1 0; 0 1; 1 1], lg)
49 mg = MappedGrid(lg, x̄, J)
50
51 @test mg isa Grid{SVector{3, Float64},2}
52 @test jacobian(mg) isa Array{<:AbstractMatrix}
53 @test logicalgrid(mg) isa Grid
54
55 @test collect(mg) == x̄
56 @test jacobian(mg) == J
57 @test logicalgrid(mg) == lg
58
49 # TODO: Test that the element types agree 59 # TODO: Test that the element types agree
50 60
51 @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 @test_broken false # @test_throws ArgumentError("Sizes must match") MappedGrid(lg, map(ξ̄ -> @SArray[ξ̄[1], ξ̄[2], -ξ̄[1]], lg), rand(SMatrix{2,3,Float64},15,11))
52 62
53 63