Example #1
0
    gid = np.array([18, 19, 20], dtype=np.int32)

if rank == 3:
    num_particles = 4
    x = np.array([1.0, 2.0, 3.0, 4.0], dtype=np.float64)
    y = np.array([4.0, 4.0, 4.0, 4.0], dtype=np.float64)

    gid = np.array([21, 22, 23, 24], dtype=np.int32)

# create particle data structure
pc = ParticleContainer(num_particles)
pc['position-x'][:] = x
pc['position-y'][:] = y

pc.register_property(x.size, 'gid', 'long')
pc['gid'][:] = gid

# Gather the global data on root
X = np.zeros(shape=25, dtype=np.float64)
Y = np.zeros(shape=25, dtype=np.float64)
GID = np.zeros(shape=25, dtype=np.int32)

displacements = np.array([12, 6, 3, 4], dtype=np.int32)

comm.Gatherv(sendbuf=x, recvbuf=[X, (displacements, None)], root=0)
comm.Gatherv(sendbuf=y, recvbuf=[Y, (displacements, None)], root=0)
comm.Gatherv(sendbuf=gid, recvbuf=[GID, (displacements, None)], root=0)

# brodcast global X, Y and GID to everyone
comm.Bcast(buf=X, root=0)
Example #2
0
    #gid = np.array( [18, 19, 20], dtype=np.int32 )


if rank == 3:
    num_particles = 4*5
    x = np.array( 5*[1.0, 2.0, 3.0, 4.0], dtype=np.float64)
    y = np.array( 5*[4.0, 4.0, 4.0, 4.0], dtype=np.float64)
    z = np.repeat(np.arange(5), 4).astype(np.float64)

    gid = np.arange(105, 105 + num_particles, dtype=np.int32)
    #gid = np.array( [21, 22, 23, 24], dtype=np.int32 )


# create particle data structure
pa = ParticleContainer(num_particles)
pa.register_property(num_particles, 'position-z', 'double')
pa['position-x'][:] = x
pa['position-y'][:] = y
pa['position-z'][:] = z

pa.register_property(x.size, 'gid', 'long')
pa['gid'][:] = gid

# Gather the global data on root
X   = np.zeros(shape=125, dtype=np.float64)
Y   = np.zeros(shape=125, dtype=np.float64)
Z   = np.zeros(shape=125, dtype=np.float64)
GID = np.zeros(shape=125, dtype=np.int32)

displacements = 5*np.array([12, 6, 3, 4], dtype=np.int32)