Example #1
0
#!/bin/py
#
# run the channel and create plots comparable to keefe (92)
#
import os
import sys
sys.path.append("..")
import channel 

# for plotting
import pylab as pl
import numpy as np

# reynolds number
channel.Re=2000

# invoke init
channel.init(100, 0, None)

C = channel.get_solution(0) * 0
channel.primal(C)

y, w = channel.quad()

for i in [0, 2, 10, 40, 100]:
    u = channel.spec2phys(i)
    pl.plot(y, u[0].mean(0).mean(1), '.-')

Example #2
0
# invoke init
n_steps = 10000

restart_file = '../keefe_runup_stage_5_qiqi.hd5'

for i_stage in range(1000000):
    next_restart = 'Re{0:04d}_{1:06d}.hd5'.format(channel.Re, i_stage)

    if not os.path.exists(next_restart):
        print('restarting from ', restart_file, ' writing to ', next_restart)
        sys.stdout.flush()

        channel.init(n_steps, 0, restart_file)
        
        u_mean, u2_mean = [], []
        for i in range(0, n_steps + 1, 400):
            U = channel.spec2phys(i)
            u_mean.append(U.mean(1).mean(2))
            u2_mean.append((U**2).mean(1).mean(2))
        
        u_mean, u2_mean = array(u_mean).mean(0), array(u2_mean).mean(0)
        
        savetxt('Re{0:04d}_{1:06d}.txt'.format(channel.Re, i_stage),
                vstack([u_mean, u2_mean]).T)
        channel.save_solution(next_restart, channel.get_solution(n_steps))

        channel.destroy()

    restart_file = next_restart
Example #3
0
channel.Lx=1.6
channel.Lz=1.6

# time step and number of steps
channel.dt = .01

# flux (mean pressure gradient)
channel.meanU = 1

# ============================================
# STAGES -- reynolds number
Re = [10000, 5000, 3000, 2500, 2000]
restart = None

for i in range(len(Re)):
    channel.Re = Re[i]
    
    # STAGE i -- time steps
    ru_steps = 4999
    n_steps = 1
    
    # STAGE i -- invoke init
    channel.init(n_steps, ru_steps, restart=restart)

    filename = 'keefe_runup_stage_{0}'.format(i+1)
    channel.save_solution(filename, channel.get_solution(0))
    channel.destroy()

    restart = filename

Example #4
0
import sys
sys.path.append("..")
import channel
from numpy import *

# TANGENT WITH FORCING
Re = 200
dRe = 1E-6
ru_steps = 0
n_steps = int(sys.argv[1])
i_restart = int(sys.argv[2])
restart = 'keefe_runup_stage_5.hd5' if i_restart else None
channel.dt = 0.01
channel.meanU = 1.0
channel.Re = Re
channel.init(n_steps, ru_steps, restart=restart)

# tangent 
IC = zeros_like(channel.get_solution(0))
channel.tangent(0, n_steps, IC, 1)

from pylab import *
y, w = channel.quad()
IU = channel.spec2phys(IC)
plot(y, IU[0].mean(0).mean(1))
savefig('testTanManu{0:06d}_restart{1:1d}'.format(n_steps, restart is not None))

# channel.destroy()
Example #5
0
# initial condition
u0 = zeros([channel.Nz,2,channel.Ny-2,channel.Nx/2],complex) 

# solve portion of primal on each processor
if mpi_rank == 0:
    print "Starting Primal ..."

if mpi_rank > 0:
    mpi_comm.Recv(u0, mpi_rank - 1, 1)
    channel.para_init(n_steps, u0)
else:
    restart = "keefe_runup_stage_5"
    channel.init(n_steps,ru_steps, restart = restart)

if mpi_rank < mpi_size - 1:
    u0 = channel.get_solution(n_steps, copy=True)
    mpi_comm.Send(u0, mpi_rank + 1, 1)

if mpi_rank == (mpi_size-1):
    print "Primal Complete!"

pde = Wrapper(channel.Nx, channel.Ny, channel.Nz, n_chunk, chunk_bounds,
              channel.dt * chunk_steps,
              channel.tangent, channel.adjoint, channel.ddt_project)

# construct matrix rhs
nvw = 2 * pde.n - (1 if mpi_rank == 0 else 0)
x = zeros(2 * pde.m * nvw)


# INITIAL GUESS HERE!