Mercurial > repos > public > sbplib_julia
diff 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 |
line wrap: on
line diff
--- a/test/Grids/tensor_grid_test.jl Sat Dec 23 23:01:28 2023 +0100 +++ b/test/Grids/tensor_grid_test.jl Sat Dec 23 23:03:13 2023 +0100 @@ -85,12 +85,30 @@ @test eltype(TensorGrid(g₁, g₄)) == SVector{3,Float64} @test eltype(TensorGrid(g₁, g₄, g₂)) == SVector{4,Float64} + @test eltype(typeof(TensorGrid(g₁, g₂))) == SVector{2,Float64} + @test eltype(typeof(TensorGrid(g₁, g₃))) == SVector{2,Float64} + @test eltype(typeof(TensorGrid(g₁, g₂, g₃))) == SVector{3,Float64} + @test eltype(typeof(TensorGrid(g₁, g₄))) == SVector{3,Float64} + @test eltype(typeof(TensorGrid(g₁, g₄, g₂))) == SVector{4,Float64} + @test size(TensorGrid(g₁, g₂)) == (11,6) @test size(TensorGrid(g₁, g₃)) == (11,10) @test size(TensorGrid(g₁, g₂, g₃)) == (11,6,10) @test size(TensorGrid(g₁, g₄)) == (11,) @test size(TensorGrid(g₁, g₄, g₂)) == (11,6) + @test size(TensorGrid(g₁, g₂, g₃),1) == 11 + @test size(TensorGrid(g₁, g₂, g₃),2) == 6 + @test size(TensorGrid(g₁, g₂, g₃),3) == 10 + @test size(TensorGrid(g₁, g₄, g₂),1) == 11 + @test size(TensorGrid(g₁, g₄, g₂),2) == 6 + + @test length(TensorGrid(g₁, g₂)) == 66 + @test length(TensorGrid(g₁, g₃)) == 110 + @test length(TensorGrid(g₁, g₂, g₃)) == 660 + @test length(TensorGrid(g₁, g₄)) == 11 + @test length(TensorGrid(g₁, g₄, g₂)) == 66 + @test Base.IteratorSize(TensorGrid(g₁, g₂)) == Base.HasShape{2}() @test Base.IteratorSize(TensorGrid(g₁, g₃)) == Base.HasShape{2}() @test Base.IteratorSize(TensorGrid(g₁, g₂, g₃)) == Base.HasShape{3}() @@ -151,6 +169,21 @@ @test boundary_grid(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₂) @test boundary_grid(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₄) end + + @testset "boundary_indices" begin + g₁ = EquidistantGrid(range(0,1,length=11)) + g₂ = EquidistantGrid(range(2,3,length=6)) + g₄ = ZeroDimGrid(@SVector[1,2]) + + @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Lower}()) == (1,:) + @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}()) == (11,:) + @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Lower}()) == (:,1) + @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Upper}()) == (:,6) + @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, Lower}()) == (1,) + @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}()) == (11,) + @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, Lower}()) == (1,) + @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, Upper}()) == (11,) + end end @testset "combined_coordinate_vector_type" begin