davemhyman / lava2d

https://doi.org/10.1029/2022JB024998
MIT License
2 stars 2 forks source link

muscl.py: subset_bounds() #1

Closed davemhyman closed 8 months ago

davemhyman commented 2 years ago

Correct for vent areas

need faster vent area corrector

static corrector is pretty fast if vents are close together

cannot compute corrector region every time -- too slow!

could make a global grid g.t_on with vent area cells having the value of time when they turn on

similar grid for when they shut off (g.t_off)

(g.t_on <= t_n) and (t_n <= g.t_off) demarcates vent areas where discharge is ongoing

g.discharge_ongoing = np.logical_and(g.t_on <= t_n, g.t_off >= t_n)

I = np.logical_or(g.h_n > 0, g.discharge_ongoing)

davemhyman commented 1 year ago

Inline comment from subset_bounds():

'''

Correct for vent areas

I[180:225,65:95] = True
#
# need faster vent area corrector
# static corrector is pretty fast if vents are close together
# cannot compute corrector region every time -- too slow!
# could make a global grid g.t_on with vent area cells having the value of time when they turn on
# similar grid for when they shut off (g.t_off)
# (g.t_on <= t_n) and (t_n <= g.t_off) demarcates vent areas where discharge is ongoing
# g.discharge_ongoing = np.logical_and(g.t_on <= t_n, g.t_off >= t_n)
# I = np.logical_or(g.h_n > 0, g.discharge_ongoing)
#
#
#
#
n_vents = len(p.vent_param_splines)
dxy_min = min(p.dx,p.dy)
for n in range(n_vents):
    x0,y0,x1,y1,W,Q_n = p.vent_param_splines[n](t) # scalars
    if Q_n != 0:
        L = np.sqrt((x1-x0)**2 + (y1-y0)**2)
        bw = int(0.5 * max(L,W) / dxy_min) + 1
        xavg = 0.5*(x0+x1)
        yavg = 0.5*(y0+y1)
        #
        id_xavg = int((xavg - x_UpperLeft) / p.dx)
        id_yavg = int((y_UpperLeft - yavg) / p.dy)
        #
        r_top = max(id_yavg - bw, 0)
        r_bottom = min(id_yavg + bw+1, ny_global)
        c_left = max(id_xavg - bw, 0)
        c_right = min(id_xavg + bw+1, nx_global)
        #
        I[r_top:r_bottom, c_left:c_right] = True
    #
#
'''
davemhyman commented 1 year ago

Inline comment from vents.py:

''' include in read_source_data:

static vent area grids

could make a global grid g.t_on with vent area cells having the value of time when they turn on

similar grid for when they shut off (g.t_off)

(g.t_on <= t_n) and (t_n <= g.t_off) demarcates vent areas where discharge is ongoing

g.discharge_ongoing = np.logical_and(g.t_on <= t_n, g.t_off >= t_n)

I = np.logical_or(g.h_n > 0, g.discharge_ongoing)

'''

davemhyman commented 8 months ago

resolved with an initial pass over vent files to determine a static cell tag of all cells that will ever be part of the source term