-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_grid.jl
37 lines (30 loc) · 918 Bytes
/
test_grid.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sbp
using sbp.Grid:grid_xp, grid_xm, grid_2d_x, grid_2d_y
using Test
@testset "Grid properties" begin
n = 10
x, h = grid_xp(n)
@test isapprox(x[2] - x[1], x[end] - x[end-1])
@test isapprox(x[1], 0)
@test isapprox(x[end], 1.0)
x, h = grid_xm(n)
@test isapprox(x[2] - x[1], x[end] - x[end-1])
@test isapprox(x[1], 0)
@test isapprox(x[end], 1.0)
x, h = grid_xp(n, pad=true)
@test length(x) == n + 1
@test x[end] == 0
@test isapprox(x[end - 1], 1.0)
end
@testset "2D grid vector" begin
nx = 10
ny = 12
x1, h = grid_xp(nx)
y1, h = grid_xp(ny)
x = grid_2d_x(x1, ny)
@test size(x) == (nx * ny,)
@test isapprox(x[1:nx], x1[1] * ones(nx))
y = grid_2d_y(y1, nx)
@test size(y) == (nx * ny,)
@test isapprox(y[1:ny], y1)
end