Skip to content

Commit bacdb02

Browse files
committed
update swe example
1 parent 2c1ec52 commit bacdb02

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

examples/OneDShallowWaterGeostrophicAdjustment.jl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ nothing #hide
7777
# A constructor populates empty arrays based on the dimension of the `grid`
7878
# and then creates `Vars` struct.
7979
"""
80-
Vars(dev, grid)
80+
Vars(grid)
8181
Constructs Vars for 1D shallow water based on the dimensions of arrays of the `grid`.
8282
"""
83-
function Vars(::Dev, grid) where Dev
83+
function Vars(grid)
84+
Dev = typeof(grid.device)
85+
8486
T = eltype(grid)
8587
@devzeros Dev T grid.nx u v η
8688
@devzeros Dev Complex{T} grid.nkr uh vh ηh
@@ -125,19 +127,21 @@ nothing #hide
125127
# Next we construct the `Equation` struct:
126128

127129
"""
128-
Equation(dev, params, grid)
130+
Equation(params, grid)
129131
Construct the equation: the linear part, in this case the hyperviscous dissipation,
130132
and the nonlinear part, which is computed by `calcN!` function.
131133
"""
132-
function Equation(dev, params, grid)
134+
function Equation(params, grid)
133135
T = eltype(grid)
136+
dev = grid.device
137+
134138
L = zeros(dev, T, (grid.nkr, 3))
135139
D = @. - params.ν * grid.kr^(2*params.nν)
136-
140+
137141
L[:, 1] .= D # for u equation
138142
L[:, 2] .= D # for v equation
139143
L[:, 3] .= D # for η equation
140-
144+
141145
return FourierFlows.Equation(L, calcN!, grid)
142146
end
143147
nothing #hide
@@ -223,16 +227,17 @@ nothing # hide
223227

224228

225229
# ## Construct the `struct`s and you are ready to go!
230+
226231
# Create a `grid` and also `params`, `vars`, and the `equation` structs. Then
227232
# give them all as input to the `FourierFlows.Problem()` constructor to get a
228233
# problem struct, `prob`, that contains all of the above.
229234

230235
grid = OneDGrid(dev; nx, Lx)
231236
params = Params(ν, nν, g, H, f)
232-
vars = Vars(dev, grid)
233-
equation = Equation(dev, params, grid)
237+
vars = Vars(grid)
238+
equation = Equation(params, grid)
234239

235-
prob = FourierFlows.Problem(equation, stepper, dt, grid, vars, params, dev)
240+
prob = FourierFlows.Problem(equation, stepper, dt, grid, vars, params)
236241
nothing #hide
237242

238243
# ## Setting initial conditions

0 commit comments

Comments
 (0)