

def evolve(self, dt):
    ' \n        Evolve the incompressible equations through one timestep. \n        '
    u = self.cc_data.get_var('x-velocity')
    v = self.cc_data.get_var('y-velocity')
    gradp_x = self.cc_data.get_var('gradp_x')
    gradp_y = self.cc_data.get_var('gradp_y')
    phi = self.cc_data.get_var('phi')
    myg = self.cc_data.grid
    dtdx = (dt / myg.dx)
    dtdy = (dt / myg.dy)
    limiter = self.rp.get_param('incompressible.limiter')
    if (limiter == 0):
        limitFunc = reconstruction_f.nolimit
    elif (limiter == 1):
        limitFunc = reconstruction_f.limit2
    else:
        limitFunc = reconstruction_f.limit4
    ldelta_ux = limitFunc(1, u, myg.qx, myg.qy, myg.ng)
    ldelta_vx = limitFunc(1, v, myg.qx, myg.qy, myg.ng)
    ldelta_uy = limitFunc(2, u, myg.qx, myg.qy, myg.ng)
    ldelta_vy = limitFunc(2, v, myg.qx, myg.qy, myg.ng)
    '\n        the advective velocities are the normal velocity through each cell\n        interface, and are defined on the cell edges, in a MAC type\n        staggered form\n\n                         n+1/2 \n                        v \n                         i,j+1/2 \n                    +------+------+\n                    |             | \n            n+1/2   |             |   n+1/2  \n           u        +     U       +  u  \n            i-1/2,j |      i,j    |   i+1/2,j \n                    |             |      \n                    +------+------+  \n                         n+1/2 \n                        v \n                         i,j-1/2   \n\n        '
    print('  making MAC velocities')
    (u_MAC, v_MAC) = incomp_interface_f.mac_vels(myg.qx, myg.qy, myg.ng, myg.dx, myg.dy, dt, u, v, ldelta_ux, ldelta_vx, ldelta_uy, ldelta_vy, gradp_x, gradp_y)
    print('  MAC projection')
    mg = MG.CellCenterMG2d(myg.nx, myg.ny, xl_BC_type=self.cc_data.BCs['phi-MAC'].xlb, xr_BC_type=self.cc_data.BCs['phi-MAC'].xrb, yl_BC_type=self.cc_data.BCs['phi-MAC'].ylb, yr_BC_type=self.cc_data.BCs['phi-MAC'].yrb, xmin=myg.xmin, xmax=myg.xmax, ymin=myg.ymin, ymax=myg.ymax, verbose=0)
    divU = mg.soln_grid.scratch_array()
    divU[mg.ilo:(mg.ihi + 1), mg.jlo:(mg.jhi + 1)] = (((u_MAC[(myg.ilo + 1):(myg.ihi + 2), myg.jlo:(myg.jhi + 1)] - u_MAC[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)]) / myg.dx) + ((v_MAC[myg.ilo:(myg.ihi + 1), (myg.jlo + 1):(myg.jhi + 2)] - v_MAC[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)]) / myg.dy))
    mg.init_zeros()
    mg.init_RHS(divU)
    mg.solve(rtol=1e-12)
    phi_MAC = self.cc_data.get_var('phi-MAC')
    solution = mg.get_solution()
    phi_MAC[(myg.ilo - 1):(myg.ihi + 2), (myg.jlo - 1):(myg.jhi + 2)] = solution[(mg.ilo - 1):(mg.ihi + 2), (mg.jlo - 1):(mg.jhi + 2)]
    u_MAC[myg.ilo:(myg.ihi + 2), myg.jlo:(myg.jhi + 1)] -= ((phi_MAC[myg.ilo:(myg.ihi + 2), myg.jlo:(myg.jhi + 1)] - phi_MAC[(myg.ilo - 1):(myg.ihi + 1), myg.jlo:(myg.jhi + 1)]) / myg.dx)
    v_MAC[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 2)] -= ((phi_MAC[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 2)] - phi_MAC[myg.ilo:(myg.ihi + 1), (myg.jlo - 1):(myg.jhi + 1)]) / myg.dy)
    print('  making u, v edge states')
    (u_xint, v_xint, u_yint, v_yint) = incomp_interface_f.states(myg.qx, myg.qy, myg.ng, myg.dx, myg.dy, dt, u, v, ldelta_ux, ldelta_vx, ldelta_uy, ldelta_vy, gradp_x, gradp_y, u_MAC, v_MAC)
    print('  doing provisional update of u, v')
    advect_x = myg.scratch_array()
    advect_y = myg.scratch_array()
    advect_x[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)] = ((((0.5 * (u_MAC[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)] + u_MAC[(myg.ilo + 1):(myg.ihi + 2), myg.jlo:(myg.jhi + 1)])) * (u_xint[(myg.ilo + 1):(myg.ihi + 2), myg.jlo:(myg.jhi + 1)] - u_xint[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)])) / myg.dx) + (((0.5 * (v_MAC[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)] + v_MAC[myg.ilo:(myg.ihi + 1), (myg.jlo + 1):(myg.jhi + 2)])) * (u_yint[myg.ilo:(myg.ihi + 1), (myg.jlo + 1):(myg.jhi + 2)] - u_yint[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)])) / myg.dy))
    advect_y[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)] = ((((0.5 * (u_MAC[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)] + u_MAC[(myg.ilo + 1):(myg.ihi + 2), myg.jlo:(myg.jhi + 1)])) * (v_xint[(myg.ilo + 1):(myg.ihi + 2), myg.jlo:(myg.jhi + 1)] - v_xint[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)])) / myg.dx) + (((0.5 * (v_MAC[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)] + v_MAC[myg.ilo:(myg.ihi + 1), (myg.jlo + 1):(myg.jhi + 2)])) * (v_yint[myg.ilo:(myg.ihi + 1), (myg.jlo + 1):(myg.jhi + 2)] - v_yint[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)])) / myg.dy))
    proj_type = self.rp.get_param('incompressible.proj_type')
    if (proj_type == 1):
        u[:, :] -= ((dt * advect_x[:, :]) + (dt * gradp_x[:, :]))
        v[:, :] -= ((dt * advect_y[:, :]) + (dt * gradp_y[:, :]))
    elif (proj_type == 2):
        u[:, :] -= (dt * advect_x[:, :])
        v[:, :] -= (dt * advect_y[:, :])
    self.cc_data.fill_BC('x-velocity')
    self.cc_data.fill_BC('y-velocity')
    print('  final projection')
    mg = MG.CellCenterMG2d(myg.nx, myg.ny, xl_BC_type=self.cc_data.BCs['phi'].xlb, xr_BC_type=self.cc_data.BCs['phi'].xrb, yl_BC_type=self.cc_data.BCs['phi'].ylb, yr_BC_type=self.cc_data.BCs['phi'].yrb, xmin=myg.xmin, xmax=myg.xmax, ymin=myg.ymin, ymax=myg.ymax, verbose=0)
    divU[mg.ilo:(mg.ihi + 1), mg.jlo:(mg.jhi + 1)] = (((0.5 * (u[(myg.ilo + 1):(myg.ihi + 2), myg.jlo:(myg.jhi + 1)] - u[(myg.ilo - 1):myg.ihi, myg.jlo:(myg.jhi + 1)])) / myg.dx) + ((0.5 * (v[myg.ilo:(myg.ihi + 1), (myg.jlo + 1):(myg.jhi + 2)] - v[myg.ilo:(myg.ihi + 1), (myg.jlo - 1):myg.jhi])) / myg.dy))
    mg.init_RHS((divU / dt))
    phiGuess = mg.soln_grid.scratch_array()
    phiGuess[(mg.ilo - 1):(mg.ihi + 2), (mg.jlo - 1):(mg.jhi + 2)] = phi[(myg.ilo - 1):(myg.ihi + 2), (myg.jlo - 1):(myg.jhi + 2)]
    mg.init_solution(phiGuess)
    mg.solve(rtol=1e-12)
    solution = mg.get_solution()
    phi[(myg.ilo - 1):(myg.ihi + 2), (myg.jlo - 1):(myg.jhi + 2)] = solution[(mg.ilo - 1):(mg.ihi + 2), (mg.jlo - 1):(mg.jhi + 2)]
    gradphi_x = myg.scratch_array()
    gradphi_y = myg.scratch_array()
    gradphi_x[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)] = ((0.5 * (phi[(myg.ilo + 1):(myg.ihi + 2), myg.jlo:(myg.jhi + 1)] - phi[(myg.ilo - 1):myg.ihi, myg.jlo:(myg.jhi + 1)])) / myg.dx)
    gradphi_y[myg.ilo:(myg.ihi + 1), myg.jlo:(myg.jhi + 1)] = ((0.5 * (phi[myg.ilo:(myg.ihi + 1), (myg.jlo + 1):(myg.jhi + 2)] - phi[myg.ilo:(myg.ihi + 1), (myg.jlo - 1):myg.jhi])) / myg.dy)
    u[:, :] -= (dt * gradphi_x)
    v[:, :] -= (dt * gradphi_y)
    if (proj_type == 1):
        gradp_x[:, :] += gradphi_x[:, :]
        gradp_y[:, :] += gradphi_y[:, :]
    elif (proj_type == 2):
        gradp_x[:, :] = gradphi_x[:, :]
        gradp_y[:, :] = gradphi_y[:, :]
    self.cc_data.fill_BC('x-velocity')
    self.cc_data.fill_BC('y-velocity')

dataset/ETHPy150Open zingale/pyro2/lm_combustion/simulation.py Simulation.evolve/original