예제 #1
0
    # parse command line arguments
    parser = argparse.ArgumentParser(
        description='Simple PIC-Maxwell simulations')
    parser.add_argument('--conf',
                        dest='conf_filename',
                        default=None,
                        help='Name of the configuration file (default: None)')
    args = parser.parse_args()
    if args.conf_filename == None:
        conf = Configuration('config-landau.ini')
    else:
        print("Reading configuration setup from ", args.conf_filename)
        conf = Configuration(args.conf_filename)

    #grid = plasma.Grid(conf.Nx, conf.Ny)
    grid = corgi.Grid(conf.Nx, conf.Ny, conf.Nz)

    xmin = 0.0
    xmax = conf.Nx * conf.NxMesh  #XXX scaled length
    ymin = 0.0
    ymax = conf.Ny * conf.NyMesh

    grid.set_grid_lims(xmin, xmax, ymin, ymax)

    #init.loadMpiRandomly(grid)
    init.loadMpiXStrides(grid)

    loadTiles(grid, conf)

    ##################################################
    # Path to be created
예제 #2
0
 def setUp(self):
     self.grid = pycorgi.Grid(self.Nx, self.Ny)
     self.grid.set_grid_lims(self.xmin, self.xmax, self.ymin, self.ymax)
예제 #3
0
        plt.rc('xtick')
        plt.rc('ytick')

        gs = plt.GridSpec(1, 3)
        gs.update(hspace=0.5)

        axs = []
        axs.append(plt.subplot(gs[0]))
        axs.append(plt.subplot(gs[1]))
        axs.append(plt.subplot(gs[2]))

    #setup grid
    conf = Conf(args.Nx, args.Ny, args.Nz, args.Nr)
    conf.update_bbox()

    grid = pycorgi.Grid(conf.Nx, conf.Ny)
    grid.set_grid_lims(conf.xmin, conf.xmax, conf.ymin, conf.ymax)

    loadMpiRandomly(grid)
    #loadMpiXStrides(grid)

    load_tiles(grid, conf)

    # Path to be created
    if grid.master:
        if not os.path.exists(conf.outdir):
            os.makedirs(conf.outdir)
    MPI.COMM_WORLD.barrier()

    ##################################################
    rank = str(grid.rank())
예제 #4
0
    def test_send_recv(self):

        #set up
        grid = pycorgi.Grid(self.Nx, self.Ny)
        grid.set_grid_lims(self.xmin, self.xmax, self.ymin, self.ymax)

        # divide into upper and lower halfs
        #refGrid = np.zeros((self.Nx, self.Ny), np.int)
        #refGrid[:, 0] = 0
        #refGrid[:, 1] = 1

        #if grid.master():
        #    for j in range(grid.get_Ny()):
        #        for i in range(grid.get_Nx()):
        #            val = refGrid[i,j]
        #            grid.set_mpi_grid(i, j, val )
        #grid.bcast_mpi_grid()

        #load tiles
        if grid.rank() == 0:
            for j in range(grid.get_Ny()):
                for i in range(grid.get_Nx()):
                    #if grid.get_mpi_grid(i,j) == 0:
                    c = pycorgi.Tile()
                    grid.add_tile(c, (i, j))

        #0 sends
        if grid.rank() == 0 and grid.size() > 1:
            #load cell with info
            cid = grid.id(2, 1)
            #print("0:  send............cid:", cid)
            c = grid.get_tile(cid)

            #communication object
            c.communication.top_virtual_owner = 10
            c.communication.communications = 11
            c.communication.number_of_virtual_neighbors = 12

            c.set_tile_mins([1.0, 2.0])
            c.set_tile_maxs([1.1, 2.1])

            #get the same cell and send
            grid.send_tile(cid, 1)

        #1 does nothing but receives
        if grid.rank() == 1 and grid.size() > 1:
            grid.recv_tile(0)
            #print("1 recv............")

        #grid.wait()

        #assert that we received the tile properly
        if grid.rank() == 1 and grid.size() > 1:
            cid = grid.id(2, 1)
            c = grid.get_tile(cid)
            #print("1:  cid=", cid)

            #cid
            #owner
            #top_virtual_owner
            #communications
            #number_of_virtual_neighbors

            self.assertEqual(c.communication.cid, cid)
            self.assertEqual(c.communication.owner, 0)
            self.assertEqual(c.communication.top_virtual_owner, 10)
            self.assertEqual(c.communication.communications, 11)
            self.assertEqual(c.communication.number_of_virtual_neighbors, 12)

            #indices
            #mins
            #maxs
            self.assertEqual(c.communication.indices, [2, 1, 0])
            self.assertEqual(c.communication.mins, [1.0, 2.0, 0.0])
            self.assertEqual(c.communication.maxs, [1.1, 2.1, 0.0])

            #tile variables
            self.assertEqual(c.cid, cid)
            self.assertEqual(c.mins, [1.0, 2.0])
            self.assertEqual(c.maxs, [1.1, 2.1])
            self.assertEqual(c.index, (2, 1))

            #check that cell is reconstructed correctly from Communication obj
            self.assertEqual(c.cid, cid)