Skip to content

Commit

Permalink
Merge branch 'main' into fix_transverse_pres_gradient
Browse files Browse the repository at this point in the history
  • Loading branch information
zhichen3 authored Nov 20, 2024
2 parents 405720c + 9063006 commit f050fd5
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions pyro/compressible/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,27 +310,33 @@ def artificial_viscosity(ng, dx, dy, Lx, Ly,

# For SphericalPolar:
else:
# cell-centered r-coord of right, left cell and face-centered r
rr = (i + 1 - ng) * dx + xmin
rl = (i - ng) * dx + xmin
rc = 0.5 * (rr + rl)

# cell-centered sin(theta) of top, bot cell and face-centered
sint = np.sin((j + 1 - ng) * dy + ymin)
sinb = np.sin((j - ng) * dy + ymin)
sinc = np.sin((j + 0.5 - ng) * dy + ymin)
# cell-centered r-coord of right, left cell and node-centered r
rr = (i + 0.5 - ng) * dx + xmin
rl = (i - 0.5 - ng) * dx + xmin
rc = (i - ng) * dx + xmin

# Find the average right and left u velocity
ur = 0.5 * (u[i, j] + u[i, j - 1])
ul = 0.5 * (u[i - 1, j] + u[i - 1, j - 1])

# Find the average top and bottom v velocity
vt = 0.5 * (v[i, j] + v[i - 1, j])
vb = 0.5 * (v[i, j - 1] + v[i - 1, j - 1])

# Finite difference to get ux and vy
ux = (ur * rr * rr - ul * rl * rl) / (rc * rc * dx)
vy = (sint * vt - sinb * vb) / (rc * sinc * dy)

# cell-centered sin(theta) of top, bot cell and node-centered sin(theta)
sint = np.sin((j + 0.5 - ng) * dy + ymin)
sinb = np.sin((j - 0.5 - ng) * dy + ymin)
sinc = np.sin((j - ng) * dy + ymin)

# if sinc = 0, i.e. theta= {0, pi}, then vy goes inf
# but due to phi-symmetry, numerator cancel, so zero.
if sinc == 0.0:
vy = 0.0
else:
# Find the average top and bottom v velocity
vt = 0.5 * (v[i, j] + v[i - 1, j])
vb = 0.5 * (v[i, j - 1] + v[i - 1, j - 1])

vy = (sint * vt - sinb * vb) / (rc * sinc * dy)

# Find div(U)_{i-1/2, j-1/2}
divU[i, j] = ux + vy
Expand All @@ -339,7 +345,10 @@ def artificial_viscosity(ng, dx, dy, Lx, Ly,
for i in range(ilo, ihi):
for j in range(jlo, jhi):

# div(U)_{i-1/2, j} = 0.5 (div(U)_{i-1/2, j-1/2} + div(U)_{i-1/2, j+1/2})
divU_x = 0.5 * (divU[i, j] + divU[i, j + 1])

# div(U)_{i, j-1/2} = 0.5 (div(U)_{i-1/2, j-1/2} + div(U)_{i+1/2, j-1/2})
divU_y = 0.5 * (divU[i, j] + divU[i + 1, j])

avisco_x[i, j] = cvisc * max(-divU_x * Lx[i, j], 0.0)
Expand Down

0 comments on commit f050fd5

Please sign in to comment.