def compute_al(q: FloatField, dxa: FloatFieldIJ): """ Interpolate q at interface. Inputs: q: transported scalar centered along the x-direction dxa: dx on A-grid (?) Returns: q interpolated to x-interfaces """ from __externals__ import i_end, i_start, iord compile_assert(iord < 8) al = ppm.p1 * (q[-1, 0, 0] + q) + ppm.p2 * (q[-2, 0, 0] + q[1, 0, 0]) if __INLINED(iord < 0): compile_assert(False) al = max(al, 0.0) with horizontal(region[i_start - 1, :], region[i_end, :]): al = ppm.c1 * q[-2, 0, 0] + ppm.c2 * q[-1, 0, 0] + ppm.c3 * q with horizontal(region[i_start, :], region[i_end + 1, :]): al = 0.5 * (((2.0 * dxa[-1, 0] + dxa[-2, 0]) * q[-1, 0, 0] - dxa[-1, 0] * q[-2, 0, 0]) / (dxa[-2, 0] + dxa[-1, 0]) + ((2.0 * dxa[0, 0] + dxa[1, 0]) * q[0, 0, 0] - dxa[0, 0] * q[1, 0, 0]) / (dxa[0, 0] + dxa[1, 0])) with horizontal(region[i_start + 1, :], region[i_end + 2, :]): al = ppm.c3 * q[-1, 0, 0] + ppm.c2 * q[0, 0, 0] + ppm.c1 * q[1, 0, 0] return al
def compute_al(q: FloatField, dya: FloatFieldIJ): """ Interpolate q at interface. Inputs: q: transported scalar centered along the y-direction dya: dy on A-grid (?) Returns: q interpolated to y-interfaces """ from __externals__ import j_end, j_start, jord compile_assert(jord < 8) al = ppm.p1 * (q[0, -1, 0] + q) + ppm.p2 * (q[0, -2, 0] + q[0, 1, 0]) if __INLINED(jord < 0): compile_assert(False) al = max(al, 0.0) with horizontal(region[:, j_start - 1], region[:, j_end]): al = ppm.c1 * q[0, -2, 0] + ppm.c2 * q[0, -1, 0] + ppm.c3 * q with horizontal(region[:, j_start], region[:, j_end + 1]): al = 0.5 * (((2.0 * dya[0, -1] + dya[0, -2]) * q[0, -1, 0] - dya[0, -1] * q[0, -2, 0]) / (dya[0, -2] + dya[0, -1]) + ((2.0 * dya[0, 0] + dya[0, 1]) * q[0, 0, 0] - dya[0, 0] * q[0, 1, 0]) / (dya[0, 0] + dya[0, 1])) with horizontal(region[:, j_start + 1], region[:, j_end + 2]): al = ppm.c3 * q[0, -1, 0] + ppm.c2 * q[0, 0, 0] + ppm.c1 * q[0, 1, 0] return al
def compute_blbr_ord8plus(q: FloatField, dxa: FloatFieldIJ): from __externals__ import i_end, i_start, iord dm = dm_iord8plus(q) al = al_iord8plus(q, dm) compile_assert(iord == 8) bl, br = blbr_iord8(q, al, dm) bl, br = bl_br_edges(bl, br, q, dxa, al, dm) with horizontal(region[i_start - 1:i_start + 2, :], region[i_end - 1:i_end + 2, :]): bl, br = ppm.pert_ppm_standard_constraint_fcn(q, bl, br) return bl, br
def compute_blbr_ord8plus(q: FloatField, dya: FloatFieldIJ): from __externals__ import j_end, j_start, jord dm = dm_jord8plus(q) al = al_jord8plus(q, dm) compile_assert(jord == 8) bl, br = blbr_jord8(q, al, dm) bl, br = bl_br_edges(bl, br, q, dya, al, dm) with horizontal(region[:, j_start - 1:j_start + 2], region[:, j_end - 1:j_end + 2]): bl, br = ppm.pert_ppm_standard_constraint_fcn(q, bl, br) return bl, br
def get_bl_br(u, dx, dxa): """ Args: u: covariant x-wind on D-grid dx: gridcell spacing in x-direction dxa: gridcell spacing in x-direction on A-grid Returns: bl: ??? br: ??? """ from __externals__ import i_end, i_start, iord, j_end, j_start if __INLINED(iord < 8): u_on_cell_corners = xppm.compute_al(u, dx) bl = u_on_cell_corners[0, 0, 0] - u[0, 0, 0] br = u_on_cell_corners[1, 0, 0] - u[0, 0, 0] else: dm = xppm.dm_iord8plus(u) u_on_cell_corners = xppm.al_iord8plus(u, dm) compile_assert(iord == 8) bl, br = xppm.blbr_iord8(u, u_on_cell_corners, dm) bl, br = xppm.bl_br_edges(bl, br, u, dxa, u_on_cell_corners, dm) with horizontal(region[i_start + 1, :], region[i_end - 1, :]): bl, br = ppm.pert_ppm_standard_constraint_fcn(u, bl, br) # Zero corners with horizontal( region[i_start - 1:i_start + 1, j_start], region[i_start - 1:i_start + 1, j_end + 1], region[i_end:i_end + 2, j_start], region[i_end:i_end + 2, j_end + 1], ): bl = 0.0 br = 0.0 return bl, br
def get_bl_br(v, dy, dya): """ Args: v: covariant y-wind on D-grid dy: gridcell spacing in y-direction dya: gridcell spacing in y-direction on A-grid Returns: bl: ??? br: ??? """ from __externals__ import i_end, i_start, j_end, j_start, jord if __INLINED(jord < 8): v_on_cell_corners = yppm.compute_al(v, dy) bl = v_on_cell_corners[0, 0, 0] - v[0, 0, 0] br = v_on_cell_corners[0, 1, 0] - v[0, 0, 0] else: dm = yppm.dm_jord8plus(v) v_on_cell_corners = yppm.al_jord8plus(v, dm) compile_assert(jord == 8) bl, br = yppm.blbr_jord8(v, v_on_cell_corners, dm) bl, br = yppm.bl_br_edges(bl, br, v, dya, v_on_cell_corners, dm) with horizontal(region[:, j_start + 1], region[:, j_end - 1]): bl, br = ppm.pert_ppm_standard_constraint_fcn(v, bl, br) # Zero corners with horizontal( region[i_start, j_start - 1:j_start + 1], region[i_end + 1, j_start - 1:j_start + 1], region[i_start, j_end:j_end + 2], region[i_end + 1, j_end:j_end + 2], ): bl = 0.0 br = 0.0 return bl, br
def definition(inout_field: gtscript.Field[float]): with computation(PARALLEL), interval(...): compile_assert(inout_field[0, 0, 0] < 0)
def assert_in_func(field): compile_assert(GLOBAL_CONSTANT < 2) return field[0, 0, 0] + GLOBAL_CONSTANT
def definition(inout_field: gtscript.Field[float]): with computation(PARALLEL), interval(...): compile_assert(GLOBAL_VERY_NESTED_CONSTANTS.nested.A > 1) inout_field = inout_field[0, 0, 0] + GLOBAL_VERY_NESTED_CONSTANTS.nested.A
def definition(inout_field: gtscript.Field[float]): from gt4py.__externals__ import EXTERNAL with computation(PARALLEL), interval(...): compile_assert(EXTERNAL < 1) inout_field = inout_field[0, 0, 0] + EXTERNAL