Skip to content

Commit b4abb48

Browse files
committed
changed boundary condition handling in utils.py
1 parent be6b654 commit b4abb48

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

aeolis/utils.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -485,20 +485,23 @@ def sweep(Ct, Cu, mass, dt, Ts, ds, dn, us, un, w):
485485
ufs = np.zeros((np.shape(us)[0], np.shape(us)[1]+1, np.shape(us)[2]))
486486
ufn = np.zeros((np.shape(un)[0]+1, np.shape(un)[1], np.shape(un)[2]))
487487

488-
# define fluxes
488+
# define velocity at cell faces
489489
ufs[:,1:-1, :] = 0.5*us[:,:-1, :] + 0.5*us[:,1:, :]
490490
ufn[1:-1,:, :] = 0.5*un[:-1,:, :] + 0.5*un[1:,:, :]
491491

492492
# print(ufs[5,:,0])
493493

494-
# boundary values
495-
ufs[:,0, :] = us[:,0, :]
496-
ufs[:,-1, :] = us[:,-1, :]
494+
# set empty boundary values, extending the velocities at the boundaries
495+
ufs[:,0, :] = ufs[:,1, :]
496+
ufs[:,-1, :] = ufs[:,-2, :]
497497

498-
ufn[0,:, :] = un[0,:, :]
499-
ufn[-1,:, :] = un[-1,:, :]
500-
# first lets take the average of the top and bottom and left/right boundary cells
498+
ufn[0,:, :] = ufn[1,:, :]
499+
ufn[-1,:, :] = ufn[-2,:, :]
500+
501+
# Lets take the average of the top and bottom and left/right boundary cells
501502
# apply the average to the boundary cells
503+
# this ensures that the inflow at one side is equal to the outflow at the other side
504+
502505
ufs[:,0,:] = (ufs[:,0,:]+ufs[:,-1,:])/2
503506
ufs[:,-1,:] = ufs[:,0,:]
504507
ufs[0,:,:] = (ufs[0,:,:]+ufs[-1,:,:])/2
@@ -510,15 +513,15 @@ def sweep(Ct, Cu, mass, dt, Ts, ds, dn, us, un, w):
510513
ufn[-1,:,:] = ufn[0,:,:]
511514

512515
# now make sure that there is no gradients at the boundaries
513-
ufs[:,1,:] = ufs[:,0,:]
514-
ufs[:,-2,:] = ufs[:,-1,:]
515-
ufs[1,:,:] = ufs[0,:,:]
516-
ufs[-2,:,:] = ufs[-1,:,:]
517-
518-
ufn[:,1,:] = ufn[:,0,:]
519-
ufn[:,-2,:] = ufn[:,-1,:]
520-
ufn[1,:,:] = ufn[0,:,:]
521-
ufn[-2,:,:] = ufn[-1,:,:]
516+
# ufs[:,1,:] = ufs[:,0,:]
517+
# ufs[:,-2,:] = ufs[:,-1,:]
518+
# ufs[1,:,:] = ufs[0,:,:]
519+
# ufs[-2,:,:] = ufs[-1,:,:]
520+
521+
# ufn[:,1,:] = ufn[:,0,:]
522+
# ufn[:,-2,:] = ufn[:,-1,:]
523+
# ufn[1,:,:] = ufn[0,:,:]
524+
# ufn[-2,:,:] = ufn[-1,:,:]
522525

523526
# ufn[:,:,:] = ufn[-2,:,:]
524527

0 commit comments

Comments
 (0)