iloc, jloc, kloc = CPL.map_glob2loc_cell(portion, [iglob, jglob, kglob]) if which_test == "cell_test": send_array[0:3, iloc, jloc, kloc] = [iglob, jglob, kglob] elif which_test == "coord_test": xglob, yglob, zglob = CPL.map_cell2coord(iglob, jglob, kglob) send_array[0:3, iloc, jloc, kloc] = [xglob, yglob, zglob] recv_array = np.zeros((3, 0, 0, 0), order="F", dtype=np.float64) CPL.scatter(send_array, olap_region, recv_array) # Receiving cell coordinates from MD if CPL.overlap(): recv_array = np.zeros((3, ncxl, ncyl, nczl), order="F", dtype=np.float64) send_array = np.zeros((3, 0, 0, 0), order="F", dtype=np.float64) CPL.gather(send_array, olap_region, recv_array) for icfd in xrange(portion[0], portion[1] + 1): for jcfd in xrange(portion[2], portion[3] + 1): for kcfd in xrange(portion[4], portion[5] + 1): iloc, jloc, kloc, = CPL.map_glob2loc_cell(portion, [icfd, jcfd, kcfd]) # Receive cell or coord depending on the test ixcfd, jycfd, kzcfd = icfd, jcfd, kcfd ixmd, jymd, kzmd = recv_array[0:3, iloc, jloc, kloc] if which_test == "cell_test": # This has to be true for every cell for the test to pass ixmd, jymd, kzmd = int(ixmd), int(jymd), int(kzmd) elif which_test == "coord_test": # This has to be true for every point for the test to pass ixcfd, jycfd, kzcfd = CPL.map_cell2coord(ixcfd, jycfd, kzcfd) ixcfd, jycfd, kzcfd = CPL.map_cfd2md_coord([ixcfd, jycfd, kzcfd])
velBCRegion[3] = velBCRegion[2] velBCPortion = CPL.my_proc_portion(velBCRegion) [velBCncx, velBCncy, velBCncz] = CPL.get_no_cells(velBCPortion) # Send dummy stress distribution (constant value of stress = 0) to MD scatter_array = np.random.rand(9, cnstncx, cnstncy, cnstncz) recv_array = np.zeros((9, 0, 0, 0), order='F', dtype=np.float64) CPL.scatter(scatter_array, cnstFRegion, recv_array) # Receive averaged velocities from LAMMPS socket recv_array = np.zeros((4, velBCncx, velBCncy, velBCncz), order='F', dtype=np.float64) gather_array = np.zeros((4, 0, 0, 0), order='F', dtype=np.float64) CPL.gather(gather_array, velBCRegion, recv_array) dx, dy, dz = (Lx / NCx, Ly / NCy, Lz / NCz) lines = "" md_cell_coords = np.array(3) dA = dx * dz if (cnstFPortion[2] >= 0): for i in xrange(cnstFPortion[0], cnstFPortion[1]+1): for j in xrange(cnstFPortion[2], cnstFPortion[3]+1): for k in xrange(cnstFPortion[4], cnstFPortion[5] + 1): md_cell_coords = CPL.map_cell2coord(i, j, k) md_cell_coords = CPL.map_cfd2md_coord(md_cell_coords) [i_loc, j_loc, k_loc] = CPL.map_glob2loc_cell(cnstFPortion, [i, j, k]) lines += str(md_cell_coords[0] + dx/2.0) + " "\
[velBCncx, velBCncy, velBCncz] = lib.get_no_cells(velBCPortion) for step in xrange(nsteps): # Send dummy stress distribution (constant value of stress = 0) to MD send_array = np.zeros((9, 0, 0, 0), order='F', dtype=np.float64) recv_array = np.ones((9, cnstncx, cnstncy, cnstncz), order='F', dtype=np.float64) lib.scatter(send_array, cnstFRegion, recv_array) #if (cnstFPortion[2] >= 0): # print (recv_array) #with open("forces.dat", "w") as forces_file: # forces_file.writelines( str (recv_array)) # Receive averaged velocities from LAMMPS socket #send_array = 0.5*np.ones((4, velBCncx, velBCncy, velBCncz), order='F', dtype=np.float64) send_array = np.random.rand(4, velBCncx, velBCncy, velBCncz) recv_array = np.zeros((4, 0, 0, 0), order='F', dtype=np.float64) lib.gather(send_array, velBCRegion, recv_array) """ dx, dy, dz = (Lx / NCx, Ly / NCy, Lz / NCz) lines = "" md_cell_coords = np.array(3) dA = dx * dz if (cnstFPortion[2] >= 0): for i in xrange(cnstFPortion[0], cnstFPortion[1] + 1): for j in xrange(cnstFPortion[2], cnstFPortion[3] + 1 ): for k in xrange(cnstFPortion[4], cnstFPortion[5] + 1): md_cell_coords = lib.grid_cell2xyz(i, j, k) md_cell_coords = lib.map_cfd2md_global(md_cell_coords) [i_loc, j_loc, k_loc] = lib.cell_glob2loc(cnstFPortion, [i, j, k]) lines += str(md_cell_coords[0] + dx/2.0) + " "\ + str(md_cell_coords[1] + dy/2.0) + " "\