Пример #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;
  }
Пример #2
0
 private SharedDataManager createSharedDataManager() {
   IntBox simulationAreaInCellDimensions =
       new IntBox(0, globalSettings.getGridCellsX() - 1, 0, globalSettings.getGridCellsY() - 1);
   return new SharedDataManager(
       workerID,
       partitions,
       simulationAreaInCellDimensions,
       localSettings.getBoundaryType(),
       communicator.getRegistry());
 }
Пример #3
0
 /** Translates the local border cell index to remote ghost cell index. */
 private Point getRemoteGhostCellIndex(int x, int y, Point direction) {
   int xoffset = direction.x * settings.getGridCellsX();
   int yoffset = direction.y * settings.getGridCellsY();
   return new Point(x - xoffset, y - yoffset);
 }