예제 #1
0
def initialize(solver, context):
    global OS, e0
    params = config.params
    OS = OrrSommerfeld(Re=params.Re, N=128)
    eigvals, eigvectors = OS.solve(False)
    OS.eigvals, OS.eigvectors = eigvals, eigvectors
    U = context.U
    X = context.X
    FST = context.FST
    initOS(OS, eigvals, eigvectors, U, X)

    U_hat = solver.set_velocity(**context)
    U = solver.get_velocity(**context)

    # Compute convection from data in context (i.e., context.U_hat and context.g)
    # This is the convection at t=0
    e0 = 0.5 * dx(U[0]**2 + (U[1] - (1 - X[0]**2))**2, FST)
    acc[0] = 0.0

    if 'RK3' not in params.solver:
        # Initialize at t = dt
        context.H_hat1[:] = solver.get_convection(**context)
        context.U_hat0[:] = U_hat
        context.U0[:] = U
        initOS(OS, eigvals, eigvectors, U, X, t=params.dt)
        U_hat = solver.set_velocity(**context)
        U = solver.get_velocity(**context)
        params.t = params.dt
        params.tstep = 1
        e1 = 0.5 * dx(U[0]**2 + (U[1] - (1 - X[0]**2))**2, FST)

        if solver.rank == 0:
            acc[0] += abs(e1 / e0 -
                          exp(2 * imag(OS.eigval) * params.t)) * params.dt

    else:
        params.t = 0
        params.tstep = 0

    if not ("KMM" in params.solver or "Coupled" in params.solver):
        P_hat = solver.compute_pressure(**context)
        P = P_hat.backward(context.P)
        if params.convection == 'Vortex':
            P += 0.5 * sum(U**2, axis=0)
            P_hat = context.P.forward(P_hat)

    else:
        try:
            context.g[:] = 0
        except AttributeError:
            pass
예제 #2
0
def initialize(solver, context):
    global OS, e0
    params = config.params
    OS = OrrSommerfeld(Re=params.Re, N=128)
    eigvals, eigvectors = OS.solve(False)
    OS.eigvals, OS.eigvectors = eigvals, eigvectors
    U = context.U
    X = context.X
    FST = context.FST
    initOS(OS, eigvals, eigvectors, U, X)

    U_hat = solver.set_velocity(**context)
    U = solver.get_velocity(**context)

    # Compute convection from data in context (i.e., context.U_hat and context.g)
    # This is the convection at t=0
    if hasattr(context.FST, 'dx'):
        e0 = 0.5 * FST.dx(U[0]**2 + (U[1] - (1 - X[0]**2))**2, context.ST.quad)
    else:
        e0 = 0.5 * dx(U[0]**2 + (U[1] - (1 - X[0]**2))**2, context.FST)
    #print(e0)
    acc[0] = 0.0

    if not 'KMMRK3' in params.solver:
        # Initialize at t = dt
        context.H_hat1[:] = solver.get_convection(**context)
        initOS(OS, eigvals, eigvectors, U, X, t=params.dt)
        U_hat = solver.set_velocity(**context)
        U = solver.get_velocity(**context)
        context.U_hat0[:] = U_hat
        params.t = params.dt
        params.tstep = 1
        if hasattr(context.FST, 'dx'):
            e1 = 0.5 * FST.dx(U[0]**2 + (U[1] -
                                         (1 - X[0]**2))**2, context.ST.quad)
        else:
            e1 = 0.5 * dx(U[0]**2 + (U[1] - (1 - X[0]**2))**2, context.FST)

        if solver.rank == 0:
            acc[0] += abs(e1 / e0 - exp(2 * imag(OS.eigval) * params.t))

    else:
        params.t = 0
        params.tstep = 0

    if not "KMM" in params.solver:
        P_hat = solver.compute_pressure(**context)
        P = FST.backward(P_hat, context.P, context.SN)

    else:
        context.g[:] = 0
예제 #3
0
def initialize(solver, context):
    global OS, e0
    params = config.params
    OS = OrrSommerfeld(Re=params.Re, N=128)
    eigvals, eigvectors = OS.solve(False)
    OS.eigvals, OS.eigvectors = eigvals, eigvectors
    U = context.U
    X = context.X
    FST = context.FST
    initOS(OS, eigvals, eigvectors, U, X)

    U_hat = solver.set_velocity(**context)
    U = solver.get_velocity(**context)

    # Compute convection from data in context (i.e., context.U_hat and context.g)
    # This is the convection at t=0
    e0 = 0.5*dx(U[2]**2+(U[0]-(1-X[2]**2))**2, context.FST, axis=2)
    #print(e0)
    acc[0] = 0.0

    if not 'KMMRK3' in params.solver:
        # Initialize at t = dt
        context.H_hat1[:] = solver.get_convection(**context)
        initOS(OS, eigvals, eigvectors, U, X, t=params.dt)
        U_hat = solver.set_velocity(**context)
        U = solver.get_velocity(**context)
        context.U_hat0[:] = U_hat
        params.t = params.dt
        params.tstep = 1
        e1 = 0.5*dx(U[2]**2+(U[0]-(1-X[2]**2))**2, context.FST, axis=2)

        if solver.rank == 0:
            acc[0] += abs(e1/e0 - exp(2*imag(OS.eigval)*params.t))

    else:
        params.t = 0
        params.tstep = 0

    if not "KMM" in params.solver:
        P_hat = solver.compute_pressure(**context)
        P = FST.backward(P_hat, context.P, context.SN)

    else:
        context.g[:] = 0