Skip to content

Commit f4c1a98

Browse files
authored
add density and pres geom term in normal reconstruction for spherical geom (#299)
When we convert from conservative variables to primitive variables, there are geometric source terms associated with density and pressure. This pr adds them when we construct the normal primitive variables. Note that dlogax and dlogay are 0 for cartesian.
1 parent b801067 commit f4c1a98

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

pyro/compressible/interface.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
@njit(cache=True)
6-
def states(idir, ng, dx, dt,
6+
def states(idir, ng, dx, dloga, dt,
77
irho, iu, iv, ip, ix, nspec,
88
gamma, qv, dqv):
99
r"""
@@ -212,6 +212,27 @@ def states(idir, ng, dx, dt,
212212
q_l[i, j + 1, m] = q_l[i, j + 1, m] + sum_l
213213
q_r[i, j, m] = q_r[i, j, m] + sum_r
214214

215+
# Geometric Source term from converting conserved-variable to primitive
216+
# It's only there for non Cartesian coord.
217+
218+
if idir == 1:
219+
rho_source = -0.5 * dt * dloga[i, j] * q[irho] * q[iu]
220+
221+
q_l[i + 1, j, irho] += rho_source
222+
q_r[i, j, irho] += rho_source
223+
224+
q_l[i + 1, j, ip] += rho_source * cs * cs
225+
q_r[i, j, ip] += rho_source * cs * cs
226+
227+
else:
228+
rho_source = -0.5 * dt * dloga[i, j] * q[irho] * q[iv]
229+
230+
q_l[i, j + 1, irho] += rho_source
231+
q_r[i, j, irho] += rho_source
232+
233+
q_l[i, j + 1, ip] += rho_source * cs * cs
234+
q_r[i, j, ip] += rho_source * cs * cs
235+
215236
return q_l, q_r
216237

217238

pyro/compressible/unsplit_fluxes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,13 @@ def interface_states(my_data, rp, ivars, tc, dt):
206206
tm_states = tc.timer("interfaceStates")
207207
tm_states.begin()
208208

209-
V_l, V_r = ifc.states(1, myg.ng, myg.Lx, dt,
209+
_V_l, _V_r = ifc.states(1, myg.ng, myg.Lx, myg.dlogAx, dt,
210210
ivars.irho, ivars.iu, ivars.iv, ivars.ip, ivars.ix,
211211
ivars.naux,
212212
gamma,
213213
q, ldx)
214+
V_l = ai.ArrayIndexer(d=_V_l, grid=myg)
215+
V_r = ai.ArrayIndexer(d=_V_r, grid=myg)
214216

215217
tm_states.end()
216218

@@ -225,7 +227,7 @@ def interface_states(my_data, rp, ivars, tc, dt):
225227
# left and right primitive variable states
226228
tm_states.begin()
227229

228-
_V_l, _V_r = ifc.states(2, myg.ng, myg.Ly, dt,
230+
_V_l, _V_r = ifc.states(2, myg.ng, myg.Ly, myg.dlogAy, dt,
229231
ivars.irho, ivars.iu, ivars.iv, ivars.ip, ivars.ix,
230232
ivars.naux,
231233
gamma,

0 commit comments

Comments
 (0)