stop_time  = 0.2
time_step  = 0.001
save_step  = 0.01

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.GenericVectorEquation(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.DdtEulerVec(phi, myLoop.dt)    
    phi_eqn += implicit_operators.DivergenceVec(phi, m_dot, "STOIC")
    
    phi_eqn.solve()
        
    myLoop.save_time()
    
phi_eqn.save_residual(myLoop.times)

print ""
print "testConvection_45degFlow_UDS FINSHED"
Exemplo n.º 2
0
    # update boundary conditions, reset matrices and right hand sides, update m_dot
    U_eqn.reset()
    p_corr_eqn.reset()
    p.update_boundary_values()

    if time_ > 0.5:
        p_under_relaxation = 0.5
    if time_ > 1.0:
        p_under_relaxation = 0.9
    if time_ > 1.5:
        p_under_relaxation = 0.95

    if Config_.__IMEX__ == False:
        ## PREDICTOR EULER
        # assemble momentum equation
        U_eqn += implicit_operators.DdtEulerVec(U_eqn, myLoop.dt)
        Dt = fields.ScalarField(myMesh, "Dt_time")
        Dt.initialize_cell_with_vector(U_eqn.diag())
        U_eqn += explicit_operators.DivergenceVec(U, m_dot, "UDS")
        # use pre-calculated coefficient matrix for the laplace operator
        U_eqn -= implicit_operators.LaplaceVec(U, nu, "", False)
        U_eqn.A = U_eqn.A - U_lapl.A
        U_eqn += explicit_operators.Gradient(p, one_over_rho)

    if Config_.__IMEX__ == True:
        ## PREDICTOR IMEX
        ## convection, gradient: Adams-Bashfort
        ## diffusion:            Crank-Nicolson
        # assemble momentum equation
        U_eqn += implicit_operators.DdtEulerVec(U_eqn, myLoop.dt)
        Dt = fields.ScalarField(myMesh, "Dt_time")