Esempio n. 1
0
  /**
   * If the local simulation is at the edge of global simulation, we also need to include the extra
   * cells to the master (because of hardwall boundaries).
   */
  private Cell[][] getFinalCells(Grid grid) {
    IntBox mypart = partitions[workerID];

    int xstart = 0;
    int ystart = 0;
    int xend = mypart.xsize() - 1;
    int yend = mypart.ysize() - 1;
    if (mypart.xmin() == 0) {
      xstart -= Grid.EXTRA_CELLS_BEFORE_GRID;
    }
    if (mypart.xmax() == globalSettings.getGridCellsX() - 1) {
      xend += Grid.EXTRA_CELLS_AFTER_GRID;
    }
    if (mypart.ymin() == 0) {
      ystart -= Grid.EXTRA_CELLS_BEFORE_GRID;
    }
    if (mypart.ymax() == globalSettings.getGridCellsY() - 1) {
      yend += Grid.EXTRA_CELLS_AFTER_GRID;
    }

    Cell[][] finalCells = new Cell[xend - xstart + 1][yend - ystart + 1];
    for (int x = xstart; x <= xend; ++x) {
      for (int y = ystart; y <= yend; ++y) {
        finalCells[x - xstart][y - ystart] = grid.getCell(x, y);
      }
    }
    return finalCells;
  }