comparison test/Grids/tensor_grid_test.jl @ 1268:dbddd0f61bde refactor/grids

Add refine, coarsen, boundary_identifiers, and boundary_grid methods to ZeroDimGrid
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 24 Feb 2023 21:54:39 +0100
parents a4ddae8b5d49
children 279179677040
comparison
equal deleted inserted replaced
1267:30729cba1095 1268:dbddd0f61bde
78 g2(n) = EquidistantGrid(range(2,3,length=n)) 78 g2(n) = EquidistantGrid(range(2,3,length=n))
79 79
80 @test refine(TensorGrid(g1(11), g2(6)),1) == TensorGrid(g1(11), g2(6)) 80 @test refine(TensorGrid(g1(11), g2(6)),1) == TensorGrid(g1(11), g2(6))
81 @test refine(TensorGrid(g1(11), g2(6)),2) == TensorGrid(g1(21), g2(11)) 81 @test refine(TensorGrid(g1(11), g2(6)),2) == TensorGrid(g1(21), g2(11))
82 @test refine(TensorGrid(g1(11), g2(6)),3) == TensorGrid(g1(31), g2(16)) 82 @test refine(TensorGrid(g1(11), g2(6)),3) == TensorGrid(g1(31), g2(16))
83 @test_broken refine(TensorGrid(g1(11), g₄), 1) == TensorGrid(g1(11), g₄) 83 @test refine(TensorGrid(g1(11), g₄), 1) == TensorGrid(g1(11), g₄)
84 @test_broken refine(TensorGrid(g1(11), g₄), 2) == TensorGrid(g1(21), g₄) 84 @test refine(TensorGrid(g1(11), g₄), 2) == TensorGrid(g1(21), g₄)
85 end 85 end
86 86
87 @testset "coarsen" begin 87 @testset "coarsen" begin
88 g1(n) = EquidistantGrid(range(0,1,length=n)) 88 g1(n) = EquidistantGrid(range(0,1,length=n))
89 g2(n) = EquidistantGrid(range(2,3,length=n)) 89 g2(n) = EquidistantGrid(range(2,3,length=n))
90 90
91 @test coarsen(TensorGrid(g1(11), g2(6)),1) == TensorGrid(g1(11), g2(6)) 91 @test coarsen(TensorGrid(g1(11), g2(6)),1) == TensorGrid(g1(11), g2(6))
92 @test coarsen(TensorGrid(g1(21), g2(11)),2) == TensorGrid(g1(11), g2(6)) 92 @test coarsen(TensorGrid(g1(21), g2(11)),2) == TensorGrid(g1(11), g2(6))
93 @test coarsen(TensorGrid(g1(31), g2(16)),3) == TensorGrid(g1(11), g2(6)) 93 @test coarsen(TensorGrid(g1(31), g2(16)),3) == TensorGrid(g1(11), g2(6))
94 @test_broken coarsen(TensorGrid(g1(11), g₄), 1) == TensorGrid(g1(11), g₄) 94 @test coarsen(TensorGrid(g1(11), g₄), 1) == TensorGrid(g1(11), g₄)
95 @test_broken coarsen(TensorGrid(g1(21), g₄), 2) == TensorGrid(g1(11), g₄) 95 @test coarsen(TensorGrid(g1(21), g₄), 2) == TensorGrid(g1(11), g₄)
96 end 96 end
97 97
98 @testset "boundary_identifiers" begin 98 @testset "boundary_identifiers" begin
99 @test boundary_identifiers(TensorGrid(g₁, g₂)) == map((n,id)->TensorGridBoundary{n,id}(), (1,1,2,2), (Lower,Upper,Lower,Upper)) 99 @test boundary_identifiers(TensorGrid(g₁, g₂)) == map((n,id)->TensorGridBoundary{n,id}(), (1,1,2,2), (Lower,Upper,Lower,Upper))
100 @test_broken boundary_identifiers(TensorGrid(g₁, g₄)) == (TensorGridBoundary{1,Lower}(),TensorGridBoundary{1,Upper}()) 100 @test boundary_identifiers(TensorGrid(g₁, g₄)) == (TensorGridBoundary{1,Lower}(),TensorGridBoundary{1,Upper}())
101 end 101 end
102 102
103 @testset "boundary_grid" begin 103 @testset "boundary_grid" begin
104 @test boundary_grid(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₂) 104 @test boundary_grid(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₂)
105 @test boundary_grid(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₄) 105 @test boundary_grid(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₄)