|
13 | 13 | import compressible.eos as eos |
14 | 14 | from util import msg |
15 | 15 |
|
| 16 | +import math |
| 17 | +import numpy as np |
| 18 | + |
16 | 19 |
|
17 | 20 | def user(bc_name, bc_edge, variable, ccdata): |
18 | 21 | """ |
@@ -132,5 +135,117 @@ def user(bc_name, bc_edge, variable, ccdata): |
132 | 135 | else: |
133 | 136 | msg.fail("error: hse BC not supported for xlb or xrb") |
134 | 137 |
|
| 138 | + elif bc_name == "ramp": |
| 139 | + # Boundary conditions for double Mach reflection problem |
| 140 | + |
| 141 | + gamma = ccdata.get_aux("gamma") |
| 142 | + |
| 143 | + if bc_edge == "xlb": |
| 144 | + # lower x boundary |
| 145 | + # inflow condition with post shock setup |
| 146 | + |
| 147 | + v = ccdata.get_var(variable) |
| 148 | + i = myg.ilo - 1 |
| 149 | + if variable in ["density", "x-momentum", "y-momentum", "energy"]: |
| 150 | + val = inflow_post_bc(variable, gamma) |
| 151 | + while i >= 0: |
| 152 | + v[i, :] = val |
| 153 | + i = i - 1 |
| 154 | + else: |
| 155 | + v[:, :] = 0.0 # no source term |
| 156 | + |
| 157 | + elif bc_edge == "ylb": |
| 158 | + # lower y boundary |
| 159 | + # for x > 1./6., reflective boundary |
| 160 | + # for x < 1./6., inflow with post shock setup |
| 161 | + |
| 162 | + if variable in ["density", "x-momentum", "y-momentum", "energy"]: |
| 163 | + v = ccdata.get_var(variable) |
| 164 | + j = myg.jlo - 1 |
| 165 | + jj = 0 |
| 166 | + while j >= 0: |
| 167 | + xcen_l = myg.x < 1.0/6.0 |
| 168 | + xcen_r = myg.x >= 1.0/6.0 |
| 169 | + v[xcen_l, j] = inflow_post_bc(variable, gamma) |
| 170 | + |
| 171 | + if variable == "y-momentum": |
| 172 | + v[xcen_r, j] = -1.0*v[xcen_r, myg.jlo+jj] |
| 173 | + else: |
| 174 | + v[xcen_r, j] = v[xcen_r, myg.jlo+jj] |
| 175 | + j = j - 1 |
| 176 | + jj = jj + 1 |
| 177 | + else: |
| 178 | + v = ccdata.get_var(variable) |
| 179 | + v[:, :] = 0.0 # no source term |
| 180 | + |
| 181 | + elif bc_edge == "yrb": |
| 182 | + # upper y boundary |
| 183 | + # time-dependent boundary, the shockfront moves with a 10 mach velocity forming an angle |
| 184 | + # to the x-axis of 30 degrees clockwise. |
| 185 | + # x coordinate of the grid is used to judge whether the cell belongs to pure post shock area, |
| 186 | + # the pure pre shock area or the mixed area. |
| 187 | + |
| 188 | + if variable in ["density", "x-momentum", "y-momentum", "energy"]: |
| 189 | + v = ccdata.get_var(variable) |
| 190 | + for j in range(myg.jhi+1, myg.jhi+myg.ng+1): |
| 191 | + shockfront_up = 1.0/6.0 + (myg.y[j] + 0.5*myg.dy*math.sqrt(3))/math.tan(math.pi/3.0) \ |
| 192 | + + (10.0/math.sin(math.pi/3.0))*ccdata.t |
| 193 | + shockfront_down = 1.0/6.0 + (myg.y[j] - 0.5*myg.dy*math.sqrt(3))/math.tan(math.pi/3.0) \ |
| 194 | + + (10.0/math.sin(math.pi/3.0))*ccdata.t |
| 195 | + shockfront = np.array([shockfront_down, shockfront_up]) |
| 196 | + for i in range(myg.ihi+myg.ng+1): |
| 197 | + v[i, j] = 0.0 |
| 198 | + cx_down = myg.x[i] - 0.5*myg.dx*math.sqrt(3) |
| 199 | + cx_up = myg.x[i] + 0.5*myg.dx*math.sqrt(3) |
| 200 | + cx = np.array([cx_down, cx_up]) |
| 201 | + |
| 202 | + for sf in shockfront: |
| 203 | + for x in cx: |
| 204 | + if x < sf: |
| 205 | + v[i, j] = v[i, j] + 0.25*inflow_post_bc(variable, gamma) |
| 206 | + else: |
| 207 | + v[i, j] = v[i, j] + 0.25*inflow_pre_bc(variable, gamma) |
| 208 | + else: |
| 209 | + v = ccdata.get_var(variable) |
| 210 | + v[:, :] = 0.0 # no source term |
| 211 | + |
135 | 212 | else: |
136 | 213 | msg.fail("error: bc type %s not supported" % (bc_name)) |
| 214 | + |
| 215 | + |
| 216 | +def inflow_post_bc(var, g): |
| 217 | + # inflow boundary condition with post shock setup |
| 218 | + r_l = 8.0 |
| 219 | + u_l = 7.1447096 |
| 220 | + v_l = -4.125 |
| 221 | + p_l = 116.5 |
| 222 | + if var == "density": |
| 223 | + vl = r_l |
| 224 | + elif var == "x-momentum": |
| 225 | + vl = r_l*u_l |
| 226 | + elif var == "y-momentum": |
| 227 | + vl = r_l*v_l |
| 228 | + elif var == "energy": |
| 229 | + vl = p_l/(g - 1.0) + 0.5*r_l*(u_l*u_l + v_l*v_l) |
| 230 | + else: |
| 231 | + vl = 0.0 |
| 232 | + return vl |
| 233 | + |
| 234 | + |
| 235 | +def inflow_pre_bc(var, g): |
| 236 | + # pre shock setup |
| 237 | + r_r = 1.4 |
| 238 | + u_r = 0.0 |
| 239 | + v_r = 0.0 |
| 240 | + p_r = 1.0 |
| 241 | + if var == "density": |
| 242 | + vl = r_r |
| 243 | + elif var == "x-momentum": |
| 244 | + vl = r_r*u_r |
| 245 | + elif var == "y-momentum": |
| 246 | + vl = r_r*v_r |
| 247 | + elif var == "energy": |
| 248 | + vl = p_r/(g - 1.0) + 0.5*r_r*(u_r*u_r + v_r*v_r) |
| 249 | + else: |
| 250 | + vl = 0.0 |
| 251 | + return vl |
0 commit comments