예제 #1
0
chunk_bounds = chunk_steps * arange(0,n_chunk + 1)
# Lx, Lz, meanU
channel.Lx = 1.6
channel.Lz = 1.6
channel.meanU = 1.0

# Initial Condition
#restart = "keefe_runup_stage_5"
restart = None

channel.init(n_steps,ru_steps, restart = restart)


# compute time averaged objective function Jbar
T = n_steps * channel.dt 
Jbar = channel.velAvg(0,n_steps,T,profile=False)

print "Total sim time:", T, "Jbar:", Jbar

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
x = zeros(2 * pde.m * (2 * pde.n - 1))
rhs = - pde.matvec(x,1) - pde.matvec(x, 0)
print "RHS norm: ", norm(rhs)
# solve
from scipy import sparse
import scipy.sparse.linalg as splinalg
예제 #2
0
    channel.para_init(n_steps, u0)
else:
    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!"

# Compute time averaged objective function over all time (and processors), Jbar
# Compute Gradient
T = ((mpi_size - 1) * (n_steps-1) + n_steps)*channel.dt
if mpi_rank == (mpi_size-1): 
    Jbar = channel.velAvg(0,n_steps,T,profile=False)
else:
    Jbar = channel.velAvg(0,n_steps-1,T,profile=False)

Jbar = mpi_comm.allreduce(Jbar)

if mpi_rank == 0: print "Total sim time:", T, "Jbar:", Jbar


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)