

def preevolve(self):
    ' \n        preevolve is called before we being the timestepping loop.  For\n        the incompressible solver, this does an initial projection on the\n        velocity field and then goes through the full evolution to get the\n        value of phi.  The fluid state (u, v) is then reset to values\n        before this evolve.\n        '
    myg = self.cc_data.grid
    u = self.cc_data.get_var('x-velocity')
    v = self.cc_data.get_var('y-velocity')
    self.cc_data.fill_BC('x-velocity')
    self.cc_data.fill_BC('y-velocity')
    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.soln_grid.scratch_array()
    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))
    new_gp_x.init_zeros()
    mg.init_RHS(divU)
    mg.solve(rtol=1e-10)
    phi = self.cc_data.get_var('phi')
    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)]
    gradp_x = myg.scratch_array()
    gradp_y = myg.scratch_array()
    gradp_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)
    gradp_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[:, :] -= gradp_x
    v[:, :] -= gradp_y
    self.cc_data.fill_BC('x-velocity')
    self.cc_data.fill_BC('y-velocity')
    orig_data = patch.cell_center_data_clone(self.cc_data)
    dt = self.timestep()
    self.evolve(dt)
    new_gp_x = self.cc_data.get_var('gradp_x')
    new_gp_y = self.cc_data.get_var('gradp_y')
    orig_gp_x = orig_data.get_var('gradp_x')
    orig_gp_y = orig_data.get_var('gradp_y')
    orig_gp_x[:, :] = new_gp_x[:, :]
    orig_gp_y[:, :] = new_gp_y[:, :]
    self.cc_data = orig_data
    print('done with the pre-evolution')

dataset/ETHPy150Open zingale/pyro2/lm_combustion/simulation.py Simulation.preevolve/VarMisuse@334/583 `mg`->`new_gp_x`