comparison test/Grids/tensor_grid_test.jl @ 1480:4550beef9694 feature/boundary_conditions

Merge with default
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Sat, 23 Dec 2023 23:03:13 +0100
parents 88e738d807cb
children d9d9ab18cdfc 611ae2308aa1
comparison
equal deleted inserted replaced
1479:b96858a50e35 1480:4550beef9694
83 @test eltype(TensorGrid(g₁, g₃)) == SVector{2,Float64} 83 @test eltype(TensorGrid(g₁, g₃)) == SVector{2,Float64}
84 @test eltype(TensorGrid(g₁, g₂, g₃)) == SVector{3,Float64} 84 @test eltype(TensorGrid(g₁, g₂, g₃)) == SVector{3,Float64}
85 @test eltype(TensorGrid(g₁, g₄)) == SVector{3,Float64} 85 @test eltype(TensorGrid(g₁, g₄)) == SVector{3,Float64}
86 @test eltype(TensorGrid(g₁, g₄, g₂)) == SVector{4,Float64} 86 @test eltype(TensorGrid(g₁, g₄, g₂)) == SVector{4,Float64}
87 87
88 @test eltype(typeof(TensorGrid(g₁, g₂))) == SVector{2,Float64}
89 @test eltype(typeof(TensorGrid(g₁, g₃))) == SVector{2,Float64}
90 @test eltype(typeof(TensorGrid(g₁, g₂, g₃))) == SVector{3,Float64}
91 @test eltype(typeof(TensorGrid(g₁, g₄))) == SVector{3,Float64}
92 @test eltype(typeof(TensorGrid(g₁, g₄, g₂))) == SVector{4,Float64}
93
88 @test size(TensorGrid(g₁, g₂)) == (11,6) 94 @test size(TensorGrid(g₁, g₂)) == (11,6)
89 @test size(TensorGrid(g₁, g₃)) == (11,10) 95 @test size(TensorGrid(g₁, g₃)) == (11,10)
90 @test size(TensorGrid(g₁, g₂, g₃)) == (11,6,10) 96 @test size(TensorGrid(g₁, g₂, g₃)) == (11,6,10)
91 @test size(TensorGrid(g₁, g₄)) == (11,) 97 @test size(TensorGrid(g₁, g₄)) == (11,)
92 @test size(TensorGrid(g₁, g₄, g₂)) == (11,6) 98 @test size(TensorGrid(g₁, g₄, g₂)) == (11,6)
93 99
100 @test size(TensorGrid(g₁, g₂, g₃),1) == 11
101 @test size(TensorGrid(g₁, g₂, g₃),2) == 6
102 @test size(TensorGrid(g₁, g₂, g₃),3) == 10
103 @test size(TensorGrid(g₁, g₄, g₂),1) == 11
104 @test size(TensorGrid(g₁, g₄, g₂),2) == 6
105
106 @test length(TensorGrid(g₁, g₂)) == 66
107 @test length(TensorGrid(g₁, g₃)) == 110
108 @test length(TensorGrid(g₁, g₂, g₃)) == 660
109 @test length(TensorGrid(g₁, g₄)) == 11
110 @test length(TensorGrid(g₁, g₄, g₂)) == 66
111
94 @test Base.IteratorSize(TensorGrid(g₁, g₂)) == Base.HasShape{2}() 112 @test Base.IteratorSize(TensorGrid(g₁, g₂)) == Base.HasShape{2}()
95 @test Base.IteratorSize(TensorGrid(g₁, g₃)) == Base.HasShape{2}() 113 @test Base.IteratorSize(TensorGrid(g₁, g₃)) == Base.HasShape{2}()
96 @test Base.IteratorSize(TensorGrid(g₁, g₂, g₃)) == Base.HasShape{3}() 114 @test Base.IteratorSize(TensorGrid(g₁, g₂, g₃)) == Base.HasShape{3}()
97 @test Base.IteratorSize(TensorGrid(g₁, g₄)) == Base.HasShape{1}() 115 @test Base.IteratorSize(TensorGrid(g₁, g₄)) == Base.HasShape{1}()
98 @test Base.IteratorSize(TensorGrid(g₁, g₄, g₂)) == Base.HasShape{2}() 116 @test Base.IteratorSize(TensorGrid(g₁, g₄, g₂)) == Base.HasShape{2}()
148 end 166 end
149 167
150 @testset "boundary_grid" begin 168 @testset "boundary_grid" begin
151 @test boundary_grid(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₂) 169 @test boundary_grid(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₂)
152 @test boundary_grid(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₄) 170 @test boundary_grid(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₄)
171 end
172
173 @testset "boundary_indices" begin
174 g₁ = EquidistantGrid(range(0,1,length=11))
175 g₂ = EquidistantGrid(range(2,3,length=6))
176 g₄ = ZeroDimGrid(@SVector[1,2])
177
178 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Lower}()) == (1,:)
179 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}()) == (11,:)
180 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Lower}()) == (:,1)
181 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Upper}()) == (:,6)
182 @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, Lower}()) == (1,)
183 @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}()) == (11,)
184 @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, Lower}()) == (1,)
185 @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, Upper}()) == (11,)
153 end 186 end
154 end 187 end
155 188
156 @testset "combined_coordinate_vector_type" begin 189 @testset "combined_coordinate_vector_type" begin
157 @test Grids.combined_coordinate_vector_type(Float64) == Float64 190 @test Grids.combined_coordinate_vector_type(Float64) == Float64