@@ -36,9 +36,6 @@ def mac_vels(qx, qy, ng, dx, dy, dt,
3636 MAC velocities in the x and y directions
3737 """
3838
39- u_MAC = np .zeros ((qx , qy ))
40- v_MAC = np .zeros ((qx , qy ))
41-
4239 # get the full u and v left and right states (including transverse
4340 # terms) on both the x- and y-interfaces
4441 u_xl , u_xr , u_yl , u_yr , v_xl , v_xr , v_yl , v_yr = get_interface_states (qx , qy , ng , dx , dy , dt ,
@@ -50,8 +47,8 @@ def mac_vels(qx, qy, ng, dx, dy, dt,
5047 # Riemann problem -- this follows Burger's equation. We don't use
5148 # any input velocity for the upwinding. Also, we only care about
5249 # the normal states here (u on x and v on y)
53- riemann_and_upwind (qx , qy , ng , u_xl , u_xr , u_MAC )
54- riemann_and_upwind (qx , qy , ng , v_yl , v_yr , v_MAC )
50+ u_MAC = riemann_and_upwind (qx , qy , ng , u_xl , u_xr )
51+ v_MAC = riemann_and_upwind (qx , qy , ng , v_yl , v_yr )
5552
5653 return u_MAC , v_MAC
5754
@@ -96,11 +93,6 @@ def states(qx, qy, ng, dx, dy, dt,
9693 x and y velocities predicted to the interfaces
9794 """
9895
99- u_xint = np .zeros ((qx , qy ))
100- u_yint = np .zeros ((qx , qy ))
101- v_xint = np .zeros ((qx , qy ))
102- v_yint = np .zeros ((qx , qy ))
103-
10496 # get the full u and v left and right states (including transverse
10597 # terms) on both the x- and y-interfaces
10698 u_xl , u_xr , u_yl , u_yr , v_xl , v_xr , v_yl , v_yr = get_interface_states (qx , qy , ng , dx , dy , dt ,
@@ -111,10 +103,10 @@ def states(qx, qy, ng, dx, dy, dt,
111103
112104 # upwind using the MAC velocity to determine which state exists on
113105 # the interface
114- upwind (qx , qy , ng , u_xl , u_xr , u_MAC , u_xint )
115- upwind (qx , qy , ng , v_xl , v_xr , u_MAC , v_xint )
116- upwind (qx , qy , ng , u_yl , u_yr , v_MAC , u_yint )
117- upwind (qx , qy , ng , v_yl , v_yr , v_MAC , v_yint )
106+ u_xint = upwind (qx , qy , ng , u_xl , u_xr , u_MAC )
107+ v_xint = upwind (qx , qy , ng , v_xl , v_xr , u_MAC )
108+ u_yint = upwind (qx , qy , ng , u_yl , u_yr , v_MAC )
109+ v_yint = upwind (qx , qy , ng , v_yl , v_yr , v_MAC )
118110
119111 return u_xint , u_yint , v_xint , v_yint
120112
@@ -166,14 +158,6 @@ def get_interface_states(qx, qy, ng, dx, dy, dt,
166158 v_yl = np .zeros ((qx , qy ))
167159 v_yr = np .zeros ((qx , qy ))
168160
169- uhat_adv = np .zeros ((qx , qy ))
170- vhat_adv = np .zeros ((qx , qy ))
171-
172- u_xint = np .zeros ((qx , qy ))
173- u_yint = np .zeros ((qx , qy ))
174- v_xint = np .zeros ((qx , qy ))
175- v_yint = np .zeros ((qx , qy ))
176-
177161 nx = qx - 2 * ng
178162 ny = qy - 2 * ng
179163 ilo = ng
@@ -216,19 +200,19 @@ def get_interface_states(qx, qy, ng, dx, dy, dt,
216200
217201 # now get the normal advective velocities on the interfaces by solving
218202 # the Riemann problem.
219- riemann (qx , qy , ng , u_xl , u_xr , uhat_adv )
220- riemann (qx , qy , ng , v_yl , v_yr , vhat_adv )
203+ uhat_adv = riemann (qx , qy , ng , u_xl , u_xr )
204+ vhat_adv = riemann (qx , qy , ng , v_yl , v_yr )
221205
222206 # now that we have the advective velocities, upwind the left and right
223207 # states using the appropriate advective velocity.
224208
225209 # on the x-interfaces, we upwind based on uhat_adv
226- upwind (qx , qy , ng , u_xl , u_xr , uhat_adv , u_xint )
227- upwind (qx , qy , ng , v_xl , v_xr , uhat_adv , v_xint )
210+ u_xint = upwind (qx , qy , ng , u_xl , u_xr , uhat_adv )
211+ v_xint = upwind (qx , qy , ng , v_xl , v_xr , uhat_adv )
228212
229213 # on the y-interfaces, we upwind based on vhat_adv
230- upwind (qx , qy , ng , u_yl , u_yr , vhat_adv , u_yint )
231- upwind (qx , qy , ng , v_yl , v_yr , vhat_adv , v_yint )
214+ u_yint = upwind (qx , qy , ng , u_yl , u_yr , vhat_adv )
215+ v_yint = upwind (qx , qy , ng , v_yl , v_yr , vhat_adv )
232216
233217 # at this point, these states are the `hat' states -- they only
234218 # considered the normal to the interface portion of the predictor.
@@ -277,7 +261,7 @@ def get_interface_states(qx, qy, ng, dx, dy, dt,
277261
278262# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
279263@njit (cache = True )
280- def upwind (qx , qy , ng , q_l , q_r , s , q_int ):
264+ def upwind (qx , qy , ng , q_l , q_r , s ):
281265 r"""
282266 upwind the left and right states based on the specified input
283267 velocity, s. The resulting interface state is q_int
@@ -292,7 +276,10 @@ def upwind(qx, qy, ng, q_l, q_r, s, q_int):
292276 left and right states
293277 s : ndarray
294278 velocity
295- q_int : ndarray
279+
280+ Returns
281+ -------
282+ out : ndarray
296283 Upwinded state
297284 """
298285
@@ -303,6 +290,8 @@ def upwind(qx, qy, ng, q_l, q_r, s, q_int):
303290 jlo = ng
304291 jhi = ng + ny
305292
293+ q_int = np .zeros ((qx , qy ))
294+
306295 for j in range (jlo - 1 , jhi + 1 ):
307296 for i in range (ilo - 1 , ihi + 1 ):
308297
@@ -313,10 +302,12 @@ def upwind(qx, qy, ng, q_l, q_r, s, q_int):
313302 else :
314303 q_int [i , j ] = q_r [i , j ]
315304
305+ return q_int
306+
316307
317308# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
318309@njit (cache = True )
319- def riemann (qx , qy , ng , q_l , q_r , s ):
310+ def riemann (qx , qy , ng , q_l , q_r ):
320311 """
321312 Solve the Burger's Riemann problem given the input left and right
322313 states and return the state on the interface.
@@ -331,7 +322,10 @@ def riemann(qx, qy, ng, q_l, q_r, s):
331322 The number of ghost cells
332323 q_l, q_r : ndarray
333324 left and right states
334- s : ndarray
325+
326+ Returns
327+ -------
328+ out : ndarray
335329 Interface state
336330 """
337331
@@ -342,6 +336,8 @@ def riemann(qx, qy, ng, q_l, q_r, s):
342336 jlo = ng
343337 jhi = ng + ny
344338
339+ s = np .zeros ((qx , qy ))
340+
345341 for j in range (jlo - 1 , jhi + 1 ):
346342 for i in range (ilo - 1 , ihi + 1 ):
347343
@@ -352,10 +348,12 @@ def riemann(qx, qy, ng, q_l, q_r, s):
352348 else :
353349 s [i , j ] = q_r [i , j ]
354350
351+ return s
352+
355353
356354# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
357355@njit (cache = True )
358- def riemann_and_upwind (qx , qy , ng , q_l , q_r , q_int ):
356+ def riemann_and_upwind (qx , qy , ng , q_l , q_r ):
359357 r"""
360358 First solve the Riemann problem given q_l and q_r to give the
361359 velocity on the interface and: use this velocity to upwind to
@@ -372,11 +370,12 @@ def riemann_and_upwind(qx, qy, ng, q_l, q_r, q_int):
372370 The number of ghost cells
373371 q_l, q_r : ndarray
374372 left and right states
375- q_int : ndarray
373+
374+ Returns
375+ -------
376+ out : ndarray
376377 Upwinded state
377378 """
378379
379- s = np .zeros ((qx , qy ))
380-
381- riemann (qx , qy , ng , q_l , q_r , s )
382- upwind (qx , qy , ng , q_l , q_r , s , q_int )
380+ s = riemann (qx , qy , ng , q_l , q_r )
381+ return upwind (qx , qy , ng , q_l , q_r , s )
0 commit comments