Skip to content

Commit c402eae

Browse files
committed
update the ambient BCs for compressible
this now allows stuff to flow out but not in also tweak the initial conditions for convection
1 parent 81873bc commit c402eae

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

pyro/compressible/BC.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020

2121
def user(bc_name, bc_edge, variable, ccdata):
2222
"""
23-
A hydrostatic boundary. This integrates the equation of HSE into
23+
Extra boundary condition types for compressible hydro. This includes
24+
a hydrostatic boundary, a ramp, and ambient.
25+
26+
For HSE, this integrates the equation of HSE into
2427
the ghost cells to get the pressure and density under the assumption
2528
that the specific internal energy is constant.
2629
@@ -152,6 +155,16 @@ def user(bc_name, bc_edge, variable, ccdata):
152155

153156
if bc_edge == "yrb":
154157

158+
# store the normal momentum -- skip this if we are filling
159+
# the sources
160+
dens_inside = None
161+
mom_normal = None
162+
normal_vel_inside = None
163+
if "y-momentum" in ccdata.names:
164+
mom_normal = ccdata.get_var("y-momentum")[:, myg.jhi]
165+
dens_inside = ccdata.get_var("density")[:, myg.jhi]
166+
normal_vel_inside = mom_normal / dens_inside
167+
155168
# upper y boundary
156169

157170
# by default, use a zero gradient
@@ -169,13 +182,17 @@ def user(bc_name, bc_edge, variable, ccdata):
169182

170183
elif variable == "y-momentum":
171184
rhov = ambient_rho * ambient_v
172-
v[:, myg.jhi+1:myg.jhi+myg.ng+1] = rhov
185+
# allow stuff to flow out, otherwise, reflect velocity
186+
for j in range(myg.jhi+1, myg.jhi+myg.ng+1):
187+
v[:, j] = np.where(mom_normal > 0, mom_normal, rhov)
173188

174189
elif variable == "energy":
175190
gamma = ccdata.get_aux("gamma")
176-
ke = 0.5 * ambient_rho * (ambient_u**2 + ambient_v**2)
191+
yvel = np.where(mom_normal > 0, mom_normal/dens_inside, ambient_v)
192+
ke = 0.5 * ambient_rho * (ambient_u**2 + yvel**2)
177193
rhoE = ambient_p / (gamma - 1.0) + ke
178-
v[:, myg.jhi+1:myg.jhi+myg.ng+1] = rhoE
194+
for j in range(myg.jhi+1, myg.jhi+myg.ng+1):
195+
v[:, j] = rhoE[:]
179196

180197
else:
181198
msg.fail("error: ambient BC not supported for xlb, xrb, or ylb")

pyro/compressible/problems/inputs.convection

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ tmax = 10.0
77

88
[io]
99
basename = convection_
10-
n_out = 100
10+
n_out = 100000
11+
dt_out = 0.25
1112

1213

1314
[mesh]
1415
nx = 128
15-
ny = 384
16+
ny = 512
1617
xmax = 4.0
17-
ymax = 12.0
18+
ymax = 16.0
1819

19-
xlboundary = outflow
20-
xrboundary = outflow
20+
xlboundary = periodic
21+
xrboundary = periodic
2122

2223
ylboundary = reflect
2324
yrboundary = ambient
@@ -26,7 +27,7 @@ yrboundary = ambient
2627
[convection]
2728
scale_height = 2.0
2829
dens_base = 1000.0
29-
dens_cutoff = 1.e-3
30+
dens_cutoff = 1.e-4
3031

3132
e_rate = 0.5
3233

0 commit comments

Comments
 (0)