Пример #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
 private Interpolation createInterpolationIterator(SharedDataManager sharedDataManager) {
   DoubleBox zoneOfLocalInfluence =
       new DoubleBox(
           (Grid.INTERPOLATION_RADIUS - 1) * localSettings.getCellWidth(),
           localSettings.getSimulationWidth()
               - Grid.INTERPOLATION_RADIUS * localSettings.getCellWidth(),
           (Grid.INTERPOLATION_RADIUS - 1) * localSettings.getCellHeight(),
           localSettings.getSimulationHeight()
               - Grid.INTERPOLATION_RADIUS * localSettings.getCellHeight());
   return new DistributedInterpolation(
       localSettings.getInterpolator(),
       sharedDataManager,
       zoneOfLocalInfluence,
       localSettings.getParticleIterator());
 }
Пример #4
0
 private ParticleBoundaries createParticleBoundaries(SharedDataManager sharedDataManager) {
   DoubleBox simulationAreaInParticleDimensions =
       new DoubleBox(
           0, localSettings.getSimulationWidth(), 0, localSettings.getSimulationHeight());
   DoubleBox innerSimulationArea =
       new DoubleBox(
           0, localSettings.getSimulationWidth() - localSettings.getCellWidth(),
           0, localSettings.getSimulationHeight() - localSettings.getCellHeight());
   return new DistributedParticleBoundaries(
       simulationAreaInParticleDimensions,
       innerSimulationArea,
       localSettings.getParticleBoundary(),
       sharedDataManager);
 }
Пример #5
0
  /**
   * Some settings (e.g. simulation width and height) pertain to the global simulation and are
   * incorrect for the local simulation. Thus, we need to correct them, so that they correspond to
   * the local simulation.
   */
  private void createLocalSettings() {
    IntBox mypart = partitions[workerID];

    double cellWidth = globalSettings.getCellWidth();
    double cellHeight = globalSettings.getCellHeight();

    localSettings = ClassCopier.copy(globalSettings);

    localSettings.setGridCellsX(mypart.xsize());
    localSettings.setGridCellsY(mypart.ysize());
    localSettings.setSimulationWidth(cellWidth * mypart.xsize());
    localSettings.setSimulationHeight(cellHeight * mypart.ysize());
  }
Пример #6
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);
 }
Пример #7
0
  /**
   * Determines the border cells and the indices of the corresponding ghost cells at remote nodes.
   * Since the corresponding border and ghost cells must have the same order, the ghost cells are
   * registered once the ghost cell indices (border cells map) is exchanged.
   */
  private void setUpBorderCells(Cell[][] myCells) {
    DoubleBox simAreaDouble =
        new DoubleBox(0, settings.getSimulationWidth(), 0, settings.getSimulationHeight());
    DoubleBox innerSimAreaDouble =
        new DoubleBox(
            settings.getCellWidth(),
            settings.getSimulationWidth() - settings.getCellWidth(),
            settings.getCellHeight(),
            settings.getSimulationHeight() - settings.getCellHeight());

    BorderRegions borders = new BorderRegions(simAreaDouble, innerSimAreaDouble);

    int xmin = -Grid.INTERPOLATION_RADIUS;
    int xmax = myPartGlobal.xsize() + Grid.INTERPOLATION_RADIUS - 1;
    int ymin = -Grid.INTERPOLATION_RADIUS;
    int ymax = myPartGlobal.ysize() + Grid.INTERPOLATION_RADIUS - 1;

    for (int x = xmin; x <= xmax; x++) {
      for (int y = ymin; y <= ymax; y++) {
        double simX = x * settings.getCellWidth() + settings.getCellWidth() / 2;
        double simY = y * settings.getCellHeight() + settings.getCellHeight() / 2;

        int region = borders.getRegion(simX, simY);

        List<SharedData> sharedDatas = sharedDataManager.getBorderSharedData(region);
        List<Point> directions = sharedDataManager.getBorderDirections(region);
        assert sharedDatas.size() == directions.size();

        for (int i = 0; i < sharedDatas.size(); ++i) {
          Point remoteGhostCellIndex = getRemoteGhostCellIndex(x, y, directions.get(i));

          sharedDatas
              .get(i)
              .registerBorderCell(myCells[realIndex(x)][realIndex(y)], remoteGhostCellIndex);
        }
      }
    }
  }