Skip to content

Commit 81c6e53

Browse files
committed
updatee tests
1 parent 4416ff6 commit 81c6e53

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

test/test_2D_advection.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Grid x assumed defined
1818
x = range(0, length = nx, stop = Lx)
1919
y = range(0, length = ny, stop = Lx)
20-
grid = (x .* ones(ny)', ones(nx) .* y')
20+
grid_array = (x .* ones(ny)', ones(nx) .* y')
2121

2222
vx0 = ones(nx, ny)
2323
vy0 = ones(nx, ny)
@@ -30,7 +30,7 @@
3030
u0 = zeros(ny, nx)
3131

3232
for I in CartesianIndices((ny, nx))
33-
u0[I] = sign(exp(-((grid[1][I] - x0)^2 + (grid[2][I]' - x0)^2) / c^2) - 0.5) * 0.5 + 0.5
33+
u0[I] = sign(exp(-((grid_array[1][I] - x0)^2 + (grid_array[2][I]' - x0)^2) / c^2) - 0.5) * 0.5 + 0.5
3434
end
3535

3636
u = copy(u0)
@@ -70,6 +70,8 @@
7070
Δx = Lx / nx
7171
Δy = Lx / ny
7272

73+
grid = UniformGrid(arch; origin=(0.0, 0.0), extent=(Lx, Lx), dims=(nx, ny))
74+
7375
x = range(0, stop = Lx, length = nx)
7476

7577
# Courant number
@@ -79,7 +81,7 @@
7981
# Grid x assumed defined
8082
x = range(0, length = nx, stop = Lx)
8183
y = range(0, length = ny, stop = Lx)
82-
grid = (x .* ones(ny)', ones(nx) .* y')
84+
grid_array = (x .* ones(ny)', ones(nx) .* y')
8385

8486
vx0 = ones(nx, ny)
8587
vy0 = ones(nx, ny)
@@ -92,11 +94,12 @@
9294
u0 = zeros(ny, nx)
9395

9496
for I in CartesianIndices((ny, nx))
95-
u0[I] = sign(exp(-((grid[1][I] - x0)^2 + (grid[2][I]' - x0)^2) / c^2) - 0.5) * 0.5 + 0.5
97+
u0[I] = sign(exp(-((grid_array[1][I] - x0)^2 + (grid_array[2][I]' - x0)^2) / c^2) - 0.5) * 0.5 + 0.5
9698
end
9799

98-
u = copy(u0)
99-
weno = WENOScheme(u; boundary = (2, 2, 2, 2), stag = false, multithreading = true)
100+
u = Field(backend, grid, Center())
101+
set!(u, u0)
102+
weno = WENOScheme(u, grid; boundary = (2, 2, 2, 2), stag = false, multithreading = true)
100103

101104
# grid size
102105
Δt = CFL * min(Δx, Δy)^(5 / 3)

test/test_3D_advection.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@
107107
u0[I] = exp(-((X3D[I] - x0)^2 + (Y3D[I] - x0)^2 + (Z3D[I] - x0)^2) / c^2)
108108
end
109109

110-
u = copy(u0)
111-
weno = WENOScheme(u; boundary = (2, 2, 2, 2, 2, 2), stag = false, multithreading = true)
110+
u = Field(backend, grid, Center())
111+
set!(u, u0)
112+
weno = WENOScheme(u, grid; boundary = (2, 2, 2, 2, 2, 2), stag = false, multithreading = true)
112113

113114
Δt = CFL * min(Δx, Δy, Δz)^(5 / 3)
114115
tmax = period * Lx / max(maximum(abs.(vx0)), maximum(abs.(vy0)), maximum(abs.(vz0)))

0 commit comments

Comments
 (0)