comparison test/Grids/curvilinear_grid_test.jl @ 1430:9fc3c1af33e5 feature/grids/curvilinear

Add testsets and a few tests
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 26 Jul 2023 21:00:44 +0200
parents 9c689a627244
children 6adf31ba6cfd
comparison
equal deleted inserted replaced
1429:e87f3465b770 1430:9fc3c1af33e5
1 using Sbplib.Grids 1 using Sbplib.Grids
2 using Test 2 using Test
3 using StaticArrays
3 4
4 @testset "CurvilinearGrid" begin 5 @testset "CurvilinearGrid" begin
5 @test CurvilinearGrid isa Any 6 g = equidistant_grid((10,10), (0,0), (1,1))
7 x̄ = map(ξ̄ -> 2ξ̄, g)
8 J = map(ξ̄ -> @SArray(fill(2., 2, 2)), g)
9
10 @test CurvilinearGrid(g, x̄, J) isa Grid{SVector{2, Float64},2}
11
12
13 @test_broken jacobian(cg) isa Array{<:AbstractVector}
14 @test_broken logicalgrid(cg) isa Grid
15
16
17
18 @testset "Indexing Interface" begin
19 # cg = CurvilinearGrid(g, x̄, J)
20 # @test cg[1,1] == [0.0, 0.0]
21 # @test cg[4,2] == [3/9,1/9]
22 # @test cg[6,10] == [5/9, 1]
23
24 # @test cg[begin, begin] == [0.0, 0.0]
25 # @test cg[end,end] == [1.0, 1.0]
26 # @test cg[begin,end] == [0., 1.]
27
28 # @test eachindex(cg) == 1:101
29 end
30
31 @testset "Iterator interface" begin
32 # @test eltype(EquidistantGrid(0:10)) == Int
33 # @test eltype(EquidistantGrid(0:2:10)) == Int
34 # @test eltype(EquidistantGrid(0:0.1:10)) == Float64
35
36 # @test size(EquidistantGrid(0:10)) == (11,)
37 # @test size(EquidistantGrid(0:0.1:10)) == (101,)
38
39 # @test collect(EquidistantGrid(0:0.1:0.5)) == [0.0, 0.1, 0.2, 0.3, 0.4, 0.5]
40
41 # @test Base.IteratorSize(EquidistantGrid{Float64, StepRange{Float64}}) == Base.HasShape{1}()
42 end
43
44 @testset "Base" begin
45 # @test ndims(EquidistantGrid(0:10)) == 1
46 end
47
48 @testset "boundary_identifiers" begin
49 # g = EquidistantGrid(0:0.1:10)
50 # @test boundary_identifiers(g) == (Lower(), Upper())
51 # @inferred boundary_identifiers(g)
52 end
53
54 @testset "boundary_grid" begin
55 # g = EquidistantGrid(0:0.1:1)
56 # @test boundary_grid(g, Lower()) == ZeroDimGrid(0.0)
57 # @test boundary_grid(g, Upper()) == ZeroDimGrid(1.0)
58 end
59
60 @testset "refine" begin
61 # g = EquidistantGrid(0:0.1:1)
62 # @test refine(g, 1) == g
63 # @test refine(g, 2) == EquidistantGrid(0:0.05:1)
64 # @test refine(g, 3) == EquidistantGrid(0:(0.1/3):1)
65 end
66
67 @testset "coarsen" begin
68 # g = EquidistantGrid(0:1:10)
69 # @test coarsen(g, 1) == g
70 # @test coarsen(g, 2) == EquidistantGrid(0:2:10)
71
72 # g = EquidistantGrid(0:0.1:1)
73 # @test coarsen(g, 1) == g
74 # @test coarsen(g, 2) == EquidistantGrid(0:0.2:1)
75
76 # g = EquidistantGrid(0:10)
77 # @test coarsen(g, 1) == EquidistantGrid(0:1:10)
78 # @test coarsen(g, 2) == EquidistantGrid(0:2:10)
79
80 # @test_throws DomainError(3, "Size minus 1 must be divisible by the ratio.") coarsen(g, 3)
81 end
6 end 82 end