2020
2121def 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" )
0 commit comments