diff test/Grids/tensor_grid_test.jl @ 1465:88e738d807cb feature/grids/boundary_indicies

Implement boundary_indices for TensorGrid
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 29 Nov 2023 09:14:06 +0100
parents c0c5e0620b83
children d9d9ab18cdfc 611ae2308aa1
line wrap: on
line diff
--- a/test/Grids/tensor_grid_test.jl	Wed Nov 29 09:04:12 2023 +0100
+++ b/test/Grids/tensor_grid_test.jl	Wed Nov 29 09:14:06 2023 +0100
@@ -169,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