@@ -77,10 +77,12 @@ nothing #hide
77
77
# A constructor populates empty arrays based on the dimension of the `grid`
78
78
# and then creates `Vars` struct.
79
79
"""
80
- Vars(dev, grid)
80
+ Vars(grid)
81
81
Constructs Vars for 1D shallow water based on the dimensions of arrays of the `grid`.
82
82
"""
83
- function Vars (:: Dev , grid) where Dev
83
+ function Vars (grid)
84
+ Dev = typeof (grid. device)
85
+
84
86
T = eltype (grid)
85
87
@devzeros Dev T grid. nx u v η
86
88
@devzeros Dev Complex{T} grid. nkr uh vh ηh
@@ -125,19 +127,21 @@ nothing #hide
125
127
# Next we construct the `Equation` struct:
126
128
127
129
"""
128
- Equation(dev, params, grid)
130
+ Equation(params, grid)
129
131
Construct the equation: the linear part, in this case the hyperviscous dissipation,
130
132
and the nonlinear part, which is computed by `calcN!` function.
131
133
"""
132
- function Equation (dev, params, grid)
134
+ function Equation (params, grid)
133
135
T = eltype (grid)
136
+ dev = grid. device
137
+
134
138
L = zeros (dev, T, (grid. nkr, 3 ))
135
139
D = @. - params. ν * grid. kr^ (2 * params. nν)
136
-
140
+
137
141
L[:, 1 ] .= D # for u equation
138
142
L[:, 2 ] .= D # for v equation
139
143
L[:, 3 ] .= D # for η equation
140
-
144
+
141
145
return FourierFlows. Equation (L, calcN!, grid)
142
146
end
143
147
nothing # hide
@@ -223,16 +227,17 @@ nothing # hide
223
227
224
228
225
229
# ## Construct the `struct`s and you are ready to go!
230
+
226
231
# Create a `grid` and also `params`, `vars`, and the `equation` structs. Then
227
232
# give them all as input to the `FourierFlows.Problem()` constructor to get a
228
233
# problem struct, `prob`, that contains all of the above.
229
234
230
235
grid = OneDGrid (dev; nx, Lx)
231
236
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)
234
239
235
- prob = FourierFlows. Problem (equation, stepper, dt, grid, vars, params, dev )
240
+ prob = FourierFlows. Problem (equation, stepper, dt, grid, vars, params)
236
241
nothing # hide
237
242
238
243
# ## Setting initial conditions
0 commit comments