def setup():

    #Import CPL library
    from cplpy import CPL

    #initialise MPI
    from mpi4py import MPI
    comm = MPI.COMM_WORLD

    #Check run as part of a coupled run
    comm.rank

    # Parameters of the cpu topology (cartesian grid)
    npxyz = np.array([1, 1, 1], order='F', dtype=np.int32)
    xyzL = np.array([1., 1., 1.], order='F', dtype=np.float64)
    xyz_orig = np.array([0.0, 0.0, 0.0], order='F', dtype=np.float64)

    #initialise CPL
    CPL = CPL()
    MD_COMM = CPL.init(CPL.MD_REALM)
    CPL.setup_md(MD_COMM.Create_cart([npxyz[0], npxyz[1], npxyz[2]]), xyzL, xyz_orig)
    recvbuf, sendbuf = CPL.get_arrays(recv_size=9, send_size=8)

    #Analytical solution
    dt = 0.05
    U = 1.0
    nu = 1.004e-2
    Re = xyzL[1]/nu   #Note Reynolds in independent of velocity in analytical fn
    ncx = CPL.get("ncx")
    ncy = CPL.get("ncy")
    ncz = CPL.get("ncz")
    CAObj = CA(Re=Re, U=U, Lmin=0., Lmax=xyzL[1], npoints=2*ncy+1, nmodes=100*ncy)

    #Yield statement delineates end of setup and start of teardown
    yield [CPL, MD_COMM, recvbuf, sendbuf, CAObj, dt, U, nu]
    CPL.finalize()
    MPI.Finalize()
comm = MPI.COMM_WORLD
CPL = CPL()
MD_COMM = CPL.init(CPL.CFD_REALM)

print("After CPL init")

## Parameters of the cpu topology (cartesian grid)
npxyz = [1, 1, 1]
xyzL = [1.5E-003, 1.5E-003, 2.5E-003]
xyz_orig = [0.0, 0.0, 0.0]
ncxyz = [8, 8, 8]

#Setup coupled simulation
cart_comm = MD_COMM.Create_cart([npxyz[0], npxyz[1], npxyz[2]])
CPL.setup_cfd(cart_comm, xyzL, xyz_orig, ncxyz)
recv_array, send_array = CPL.get_arrays(recv_size=4, send_size=3)

print("After CPL setup")

ft = True
for time in range(100):

    # send data to update
    send_array[2, :, :, :] = mi * g
    CPL.send(send_array)

    # recv data and plot
    recv_array, ierr = CPL.recv(recv_array)

    print("CFD time = ", time)
#initialise MPI
comm = MPI.COMM_WORLD

# Parameters of the cpu topology (cartesian grid)
npxyz = np.array([1, 1, 1], order='F', dtype=np.int32)
xyzL = np.array([2., 10., 2.], order='F', dtype=np.float64)
xyz_orig = np.array([0.0, 0.0, 0.0], order='F', dtype=np.float64)

#initialise CPL
CPL = CPL()
MD_COMM = CPL.init(CPL.MD_REALM)
CPL.setup_md(MD_COMM.Create_cart([npxyz[0], npxyz[1], npxyz[2]]), xyzL,
             xyz_orig)

#Setup send and recv buffers
recvbuf, sendbuf = CPL.get_arrays(recv_size=9, send_size=8)

#Main time loop
for time in range(1):

    print(time)
    # Recv data:
    # [Ux, Uy, Uz, gradPx, gradPy, gradPz, divTaux, divTauy, divTauz]
    recvbuf, ierr = CPL.recv(recvbuf)

    # Zero send buffer and set porosity to one
    # [Ux, Uy, Uz, Fx, Fy, Fz, Cd, e]
    sendbuf[...] = 0
    sendbuf[7, :, :, :] = 0.
    CPL.send(sendbuf)
Esempio n. 4
0
from mpi4py import MPI
from cplpy import CPL

comm = MPI.COMM_WORLD
CPL = CPL()
MD_COMM = CPL.init(CPL.MD_REALM)
cart_comm = MD_COMM.Create_cart([1, 1, 1])
CPL.setup_md(cart_comm, xyzL=[1.0, 1.0, 1.0], xyz_orig=[0.0, 0.0, 0.0])
recv_array, send_array = CPL.get_arrays(recv_size=1, send_size=4)

for time in range(5):

    send_array[0, :, :, :] = 5. * time
    CPL.send(send_array)
    recv_array, ierr = CPL.recv(recv_array)
    print("MD", time, recv_array[0, 0, 0, 0])

CPL.finalize()

#Start again
MD_COMM = CPL.init(CPL.MD_REALM)
CPL.setup_md(cart_comm, xyzL=[1.0, 1.0, 1.0], xyz_orig=[0.0, 0.0, 0.0])
recv_array, send_array = CPL.get_arrays(recv_size=1, send_size=4)

for time in range(5):

    send_array[0, :, :, :] = 5. * time
    CPL.send(send_array)
    recv_array, ierr = CPL.recv(recv_array)
    print("MD", time, recv_array[0, 0, 0, 0])
Esempio n. 5
0
# Parameters of the cpu topology (cartesian grid)
npxyz = np.array([1, 1, 1], order='F', dtype=np.int32)
xyzL = np.array([2., 10., 2.], order='F', dtype=np.float64)
xyz_orig = np.array([0.0, 0.0, 0.0], order='F', dtype=np.float64)
ncxyz = np.array([5, 200, 5], order='F', dtype=np.int32)

#initialise CPL
CPL = CPL()
CFD_COMM = CPL.init(CPL.CFD_REALM)
cart_comm = CFD_COMM.Create_cart([npxyz[0], npxyz[1], npxyz[2]])
CPL.setup_cfd(cart_comm, xyzL, xyz_orig, ncxyz)
print("After CPL setup")

#Setup send and recv buffers
recv_array, send_array = CPL.get_arrays(recv_size=8, send_size=9)

#Main time loop
porousStart = 91
porousEnd = 108
phi = 0.74
Ub = 0.01
K = 435.
mu = 1.e-2
dp = 0.0565685

eps = 1. - phi
rp = 0.5 * dp
gradP = 4.5 * mu * phi * K * Ub / (rp**2)

for time in range(11):