myLoop.save_current(0) # prepare monitors # linear solver residuals are added by default # divergence p_corr_eqn.add_monitor("divU_pred") p_corr_eqn.add_monitor("divU_corr") # global mass balance p_corr_eqn.add_monitor("global_mass_cons") if start_time == 0.: U_eqn.save_residual_header("U") p_corr_eqn.save_residual_header("p") # build Laplace term coefficient matrix now as it will not change U_lapl = implicit_operators.LaplaceVec(U, nu) p_lapl = implicit_operators.Laplace(p_corr) # calculate or load PLU decomposition of p_corr_eqn loadPLU = False if start_time == 0. and loadPLU == False: print "\ncalculating lu decomposition for pressure..." tlu = time.time() if Config_.__sparse__: p_corr_eqn.p, p_corr_eqn.l, p_corr_eqn.u = mylin.lu_decomp( p_lapl.A.todense()) else: p_corr_eqn.p, p_corr_eqn.l, p_corr_eqn.u = mylin.lu_decomp(p_lapl.A) print "DONE in " + str(time.time() - tlu) + " s" print "saving plu matrices..." p_corr_eqn.save_plu() print "DONE"
stop_time = 2. time_step = 1. save_step = 1. myLoop = time_loop.TimeLoop(save_fields, start_time, stop_time, time_step) myLoop.uniform_save_times(save_step) # set up equation for phi phi_eqn = generic_equation.GenericScalarEquation(myMesh, phi, "bicg") # save initial condition myLoop.save_current(0) # iteration loop for time_ in myLoop.times: myLoop.time = time_ myLoop.print_time() phi_eqn.reset() # phi_eqn += implicit_operators.DdtEuler(phi, myLoop.dt) phi_eqn -= implicit_operators.Laplace(phi) phi_eqn.solve() myLoop.save_time() phi_eqn.save_residual(myLoop.times) print "" print "testDiffusion_SmithHutton_explicit FINSHED"