comparison test/Grids/tensor_grid_test.jl @ 1736:863385aae454 feature/grids/curvilinear

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 10 Sep 2024 21:59:10 +0200
parents 51f0c5f895fb 471a948cd2b2
children 189e69d44056 871f3f1decea
comparison
equal deleted inserted replaced
1735:36986b75bf98 1736:863385aae454
1 using Test 1 using Test
2 using Sbplib.Grids 2 using Diffinitive.Grids
3 using StaticArrays 3 using StaticArrays
4 using Sbplib.RegionIndices
5 4
6 @testset "TensorGrid" begin 5 @testset "TensorGrid" begin
7 g₁ = EquidistantGrid(range(0,1,length=11)) 6 g₁ = EquidistantGrid(range(0,1,length=11))
8 g₂ = EquidistantGrid(range(2,3,length=6)) 7 g₂ = EquidistantGrid(range(2,3,length=6))
9 g₃ = EquidistantGrid(1:10) 8 g₃ = EquidistantGrid(1:10)
168 @test coarsen(TensorGrid(g1(11), g₄), 1) == TensorGrid(g1(11), g₄) 167 @test coarsen(TensorGrid(g1(11), g₄), 1) == TensorGrid(g1(11), g₄)
169 @test coarsen(TensorGrid(g1(21), g₄), 2) == TensorGrid(g1(11), g₄) 168 @test coarsen(TensorGrid(g1(21), g₄), 2) == TensorGrid(g1(11), g₄)
170 end 169 end
171 170
172 @testset "boundary_identifiers" begin 171 @testset "boundary_identifiers" begin
173 @test boundary_identifiers(TensorGrid(g₁, g₂)) == map((n,id)->TensorGridBoundary{n,id}(), (1,1,2,2), (Lower,Upper,Lower,Upper)) 172 @test boundary_identifiers(TensorGrid(g₁, g₂)) == map((n,id)->TensorGridBoundary{n,id}(), (1,1,2,2), (LowerBoundary,UpperBoundary,LowerBoundary,UpperBoundary))
174 @test boundary_identifiers(TensorGrid(g₁, g₄)) == (TensorGridBoundary{1,Lower}(),TensorGridBoundary{1,Upper}()) 173 @test boundary_identifiers(TensorGrid(g₁, g₄)) == (TensorGridBoundary{1,LowerBoundary}(),TensorGridBoundary{1,UpperBoundary}())
175 end 174 end
176 175
177 @testset "boundary_grid" begin 176 @testset "boundary_grid" begin
178 @test boundary_grid(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₂) 177 @test boundary_grid(TensorGrid(g₁, g₂), TensorGridBoundary{1, UpperBoundary}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₂)
179 @test boundary_grid(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₄) 178 @test boundary_grid(TensorGrid(g₁, g₄), TensorGridBoundary{1, UpperBoundary}()) == TensorGrid(ZeroDimGrid(g₁[end]), g₄)
180 end 179 end
181 180
182 @testset "boundary_indices" begin 181 @testset "boundary_indices" begin
183 g₁ = EquidistantGrid(range(0,1,length=11)) 182 g₁ = EquidistantGrid(range(0,1,length=11))
184 g₂ = EquidistantGrid(range(2,3,length=6)) 183 g₂ = EquidistantGrid(range(2,3,length=6))
185 g₄ = ZeroDimGrid(@SVector[1,2]) 184 g₄ = ZeroDimGrid(@SVector[1,2])
186 185
187 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Lower}()) == (1,:) 186 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, LowerBoundary}()) == (1,:)
188 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, Upper}()) == (11,:) 187 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{1, UpperBoundary}()) == (11,:)
189 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Lower}()) == (:,1) 188 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, LowerBoundary}()) == (:,1)
190 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, Upper}()) == (:,6) 189 @test boundary_indices(TensorGrid(g₁, g₂), TensorGridBoundary{2, UpperBoundary}()) == (:,6)
191 @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, Lower}()) == (1,) 190 @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, LowerBoundary}()) == (1,)
192 @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, Upper}()) == (11,) 191 @test boundary_indices(TensorGrid(g₁, g₄), TensorGridBoundary{1, UpperBoundary}()) == (11,)
193 @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, Lower}()) == (1,) 192 @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, LowerBoundary}()) == (1,)
194 @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, Upper}()) == (11,) 193 @test boundary_indices(TensorGrid(g₄,g₁), TensorGridBoundary{2, UpperBoundary}()) == (11,)
195 end 194 end
196 end 195 end
197 196
198 @testset "combined_coordinate_vector_type" begin 197 @testset "combined_coordinate_vector_type" begin
199 @test Grids.combined_coordinate_vector_type(Float64) == Float64 198 @test Grids.combined_coordinate_vector_type(Float64) == Float64