def compute(self, inputs): if inputs["dir"] == 1: direction = "x" if inputs["dir"] == 2: direction = "y" copy_corners(inputs["q"], direction, self.grid) return {"q": inputs["q"]}
def compute(qdel, nmax, cd, km): grid = spec.grid origin = (grid.isd, grid.jsd, 0) # Construct some necessary temporary storage objects fx = utils.make_storage_from_shape(qdel.shape, origin=origin) fy = utils.make_storage_from_shape(qdel.shape, origin=origin) # set up the temporal loop ntimes = min(3, nmax) for n in range(1, ntimes + 1): nt = ntimes - n origin = (grid.is_ - nt, grid.js - nt, 0) # Fill in appropriate corner values qdel = corner_fill(grid, qdel) if nt > 0: corners.copy_corners(qdel, "x", grid) nx = grid.njc + 2 * nt + 1 # (grid.ie+nt+1) - (grid.is_-nt) + 1 ny = grid.njc + 2 * nt # (grid.je+nt) - (grid.js-nt) + 1 compute_zonal_flux(fx, qdel, grid.del6_v, origin=origin, domain=(nx, ny, km)) if nt > 0: corners.copy_corners(qdel, "y", grid) nx = grid.nic + 2 * nt # (grid.ie+nt) - (grid.is_-nt) + 1 ny = grid.njc + 2 * nt + 1 # (grid.je+nt+1) - (grid.js-nt) + 1 compute_meridional_flux(fy, qdel, grid.del6_u, origin=origin, domain=(nx, ny, km)) # Update q values ny = grid.njc + 2 * nt # (grid.je+nt) - (grid.js-nt) + 1 update_q(qdel, grid.rarea, fx, fy, cd, origin=origin, domain=(nx, ny, km))
def compute_no_sg(q, fx2, fy2, nord, damp_c, d2, kstart=0, nk=None, mass=None): grid = spec.grid nord = int(nord) i1 = grid.is_ - 1 - nord i2 = grid.ie + 1 + nord j1 = grid.js - 1 - nord j2 = grid.je + 1 + nord if nk is None: nk = grid.npz - kstart kslice = slice(kstart, kstart + nk) origin_d2 = (i1, j1, kstart) domain_d2 = (i2 - i1 + 1, j2 - j1 + 1, nk) if mass is None: d2_damp(q, d2, damp_c, origin=origin_d2, domain=domain_d2) else: d2 = copy(q, origin=origin_d2, domain=domain_d2) if nord > 0: corners.copy_corners(d2, "x", grid, kslice) f1_ny = grid.je - grid.js + 1 + 2 * nord f1_nx = grid.ie - grid.is_ + 2 + 2 * nord fx_origin = (grid.is_ - nord, grid.js - nord, kstart) fx2_order(d2, grid.del6_v, fx2, order=1, origin=fx_origin, domain=(f1_nx, f1_ny, nk)) if nord > 0: corners.copy_corners(d2, "y", grid, kslice) fy2_order( d2, grid.del6_u, fy2, order=1, origin=fx_origin, domain=(f1_nx - 1, f1_ny + 1, nk), ) if nord > 0: for n in range(nord): nt = nord - 1 - n nt_origin = (grid.is_ - nt - 1, grid.js - nt - 1, kstart) nt_ny = grid.je - grid.js + 3 + 2 * nt nt_nx = grid.ie - grid.is_ + 3 + 2 * nt d2_highorder(fx2, fy2, grid.rarea, d2, origin=nt_origin, domain=(nt_nx, nt_ny, nk)) corners.copy_corners(d2, "x", grid, kslice) nt_origin = (grid.is_ - nt, grid.js - nt, kstart) fx2_order( d2, grid.del6_v, fx2, order=2 + n, origin=nt_origin, domain=(nt_nx - 1, nt_ny - 2, nk), ) corners.copy_corners(d2, "y", grid, kslice) fy2_order( d2, grid.del6_u, fy2, order=2 + n, origin=nt_origin, domain=(nt_nx - 2, nt_ny - 1, nk), )
def compute_no_sg( q, crx, cry, hord, xfx, yfx, ra_x, ra_y, fx, fy, kstart=0, nk=None, nord=None, damp_c=None, mass=None, mfx=None, mfy=None, ): grid = spec.grid if nk is None: nk = grid.npz - kstart kslice = slice(kstart, kstart + nk) compute_origin = (grid.is_, grid.js, kstart) q_i = utils.make_storage_from_shape(q.shape, (grid.isd, grid.js, kstart)) q_j = utils.make_storage_from_shape(q.shape, (grid.is_, grid.jsd, kstart)) fy2 = utils.make_storage_from_shape(q.shape, compute_origin) fx2 = utils.make_storage_from_shape(q.shape, compute_origin) if hord == 10: ord_in = 8 else: ord_in = hord ord_ou = hord corners.copy_corners(q, "y", grid, kslice) yppm.compute_flux(q, cry, fy2, ord_in, grid.isd, grid.ied, kstart=kstart, nk=nk) q_i_stencil( q, grid.area, yfx, fy2, ra_y, q_i, origin=(grid.isd, grid.js, kstart), domain=(grid.nid, grid.njc + 1, nk), ) xppm.compute_flux(q_i, crx, fx, ord_ou, grid.js, grid.je, kstart=kstart, nk=nk) corners.copy_corners(q, "x", grid, kslice) xppm.compute_flux(q, crx, fx2, ord_in, grid.jsd, grid.jed, kstart=kstart, nk=nk) q_j_stencil( q, grid.area, xfx, fx2, ra_x, q_j, origin=(grid.is_, grid.jsd, kstart), domain=(grid.nic + 1, grid.njd, nk), ) yppm.compute_flux(q_j, cry, fy, ord_ou, grid.is_, grid.ie, kstart=kstart, nk=nk) if mfx is not None and mfy is not None: transport_flux(fx, fx2, mfx, origin=compute_origin, domain=(grid.nic + 1, grid.njc, nk)) transport_flux(fy, fy2, mfy, origin=compute_origin, domain=(grid.nic, grid.njc + 1, nk)) if (mass is not None) and (nord is not None) and (damp_c is not None): delnflux.compute_delnflux_no_sg(q, fx, fy, nord, damp_c, kstart, nk, mass=mass) else: transport_flux(fx, fx2, xfx, origin=compute_origin, domain=(grid.nic + 1, grid.njc, nk)) transport_flux(fy, fy2, yfx, origin=compute_origin, domain=(grid.nic, grid.njc + 1, nk)) if (nord is not None) and (damp_c is not None): delnflux.compute_delnflux_no_sg(q, fx, fy, nord, damp_c, kstart, nk)