/** * 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()); }
private Cell[][] setUpCellValues() { int xcells = myPartGlobal.xsize() + Grid.EXTRA_CELLS_BEFORE_GRID + Grid.EXTRA_CELLS_AFTER_GRID; int ycells = myPartGlobal.ysize() + Grid.EXTRA_CELLS_BEFORE_GRID + Grid.EXTRA_CELLS_AFTER_GRID; Cell[][] myCells = new Cell[xcells][ycells]; int xmin = -Grid.EXTRA_CELLS_BEFORE_GRID; int xmax = myPartGlobal.xsize() + Grid.EXTRA_CELLS_AFTER_GRID - 1; int ymin = -Grid.EXTRA_CELLS_BEFORE_GRID; int ymax = myPartGlobal.ysize() + Grid.EXTRA_CELLS_AFTER_GRID - 1; for (int x = xmin; x <= xmax; x++) { for (int y = ymin; y <= ymax; y++) { myCells[realIndex(x)][realIndex(y)] = cellsFromMaster[realIndex(x)][realIndex(y)]; } } return myCells; }
/** * 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; }
/** * 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); } } } }