Package org.openpixi.pixi.physics.util

Examples of org.openpixi.pixi.physics.util.IntBox


  public void testPeriodicMapsGeneric() {

    // Create partitions
    Partitioner partitioner = new SimplePartitioner();
    IntBox[] partitions = partitioner.partition(NUM_CELLS_X_GEN, NUM_CELLS_Y_GEN, NUM_PARTITIONS_GEN);
    IntBox globalSimulation = new IntBox(0, NUM_CELLS_X_GEN - 1, 0, NUM_CELLS_Y_GEN - 1);

    // Go through each partition and test its neighbor map
    for (int i = 0; i < partitions.length; ++i) {
      NeighborMap neighborMap = new NeighborMap(
          i, partitions, globalSimulation, GeneralBoundaryType.Periodic);
View Full Code Here


  public void testHardwallMapsGeneric() {

    // Create partitions
    Partitioner partitioner = new SimplePartitioner();
    IntBox[] partitions = partitioner.partition(NUM_CELLS_X_GEN, NUM_CELLS_Y_GEN, NUM_PARTITIONS_GEN);
    IntBox globalSimulation = new IntBox(0, NUM_CELLS_X_GEN - 1, 0, NUM_CELLS_Y_GEN - 1);

    // Go through each partition and test its neighbor map
    for (int i = 0; i < partitions.length; ++i) {
      NeighborMap neighborMap = new NeighborMap(
          i, partitions, globalSimulation, GeneralBoundaryType.Hardwall);
View Full Code Here

  public void testPeriodicMapSpecific() {

    // Create partitions
    Partitioner partitioner = new SimplePartitioner();
    IntBox[] partitions = partitioner.partition(NUM_CELLS_X_SPC, NUM_CELLS_Y_SPC, NUM_PARTITIONS_SPC);
    IntBox globalSimulation = new IntBox(0, NUM_CELLS_X_SPC - 1, 0, NUM_CELLS_Y_SPC - 1);

    int myPartID = 0;
    NeighborMap neighborMap = new NeighborMap(
        myPartID, partitions, globalSimulation, GeneralBoundaryType.Periodic);
View Full Code Here

  public void testHardwallMapSpecific() {

    // Create partitions
    Partitioner partitioner = new SimplePartitioner();
    IntBox[] partitions = partitioner.partition(NUM_CELLS_X_SPC, NUM_CELLS_Y_SPC, NUM_PARTITIONS_SPC);
    IntBox globalSimulation = new IntBox(0, NUM_CELLS_X_SPC - 1, 0, NUM_CELLS_Y_SPC - 1);

    int myPartID = 0;
    NeighborMap neighborMap = new NeighborMap(
        myPartID, partitions, globalSimulation, GeneralBoundaryType.Hardwall);
View Full Code Here

   * Tests only one corner and one edge region.
   */
  private void testSingleHardwallBoundaryMap(
      int myPartID, IntBox[] partitions, IntBox globalSimulation, NeighborMap neighborMap) {

    IntBox myPart = partitions[myPartID];

    // Test upper-left corner

    int region = BoundaryRegions.X_MIN + BoundaryRegions.Y_MIN;
    int neighbor = neighborMap.getBoundaryNeighbor(region);
    String identification = identificationString(
        GeneralBoundaryType.Hardwall, myPartID, region, "boundary-corner");

    if (myPart.xmin() != globalSimulation.xmin() || myPart.ymin() != globalSimulation.ymin()) {

      // If the region is not a simulation corner it must have one neighbor
      testForAnyNeighbor(neighbor, partitions.length, identification);
    } else {

      // At the global simulation corner there should be no neighbor
      testForNoNeighbor(neighbor, identification);
    }

    // Test bottom edge

    region = BoundaryRegions.X_CENTER + BoundaryRegions.Y_MAX;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    identification = identificationString(
        GeneralBoundaryType.Hardwall, myPartID, region, "boundary-edge");

    if (myPart.ymax() != globalSimulation.ymax()) {

      // If the region is not at the bottom of global simulation
      // then it must have one neighbor
      testForAnyNeighbor(neighbor, partitions.length, identification);
    } else {
View Full Code Here

   * Tests only one corner, one outside corner and one edge region.
   */
  private void testSingleHardwallBorderMap(
      int myPartID, IntBox[] partitions, IntBox globalSimulation, NeighborMap neighborMap) {

    IntBox myPart = partitions[myPartID];

    // Test bottom-right corner

    int region = BorderRegions.X_BORDER_MAX + BorderRegions.Y_BORDER_MAX;
    int[] neighbors = neighborMap.getBorderNeighbors(region);
    String identification = identificationString(
        GeneralBoundaryType.Hardwall, myPartID, region, "border-corner");

    testPotentialNeighborsCount(3, neighbors.length,  identification);

    if (myPart.xmax() == globalSimulation.xmax() && myPart.ymax() == globalSimulation.ymax()) {

      // If the region is at global simulation corner it can not have any neighbors
      for (int neighbor: neighbors) {
        testForNoNeighbor(neighbor, identification);
      }
    }
    else if (myPart.xmax() == globalSimulation.xmax() || myPart.ymax() == globalSimulation.ymax()) {

      // If the region is not at global simulation corner but at its edge
      // it must have exactly one neighbor
      testForSingleNeighbor(neighbors, partitions.length, identification);
    } else {

      // If the region is inside the global simulation it must have exactly 3 neighbors
      for (int neighbor: neighbors) {
        testForAnyNeighbor(neighbor, partitions.length, identification);
      }
    }

    // Test right-top outside corner

    region = BorderRegions.X_BOUNDARY_MAX + BorderRegions.Y_BORDER_MIN;
    neighbors = neighborMap.getBorderNeighbors(region);
    identification = identificationString(
        GeneralBoundaryType.Hardwall, myPartID, region, "border-outside-corner");

    testPotentialNeighborsCount(1, neighbors.length,  identification);

    if (myPart.xmax() == globalSimulation.xmax() && myPart.ymin() != globalSimulation.ymin()) {
      testForAnyNeighbor(neighbors[0], partitions.length, identification);
    }
    else {
      testForNoNeighbor(neighbors[0], identification);
    }

    // Test left edge

    region = BorderRegions.X_BORDER_MIN + BorderRegions.Y_CENTER;
    neighbors = neighborMap.getBorderNeighbors(region);
    identification = identificationString(
        GeneralBoundaryType.Hardwall, myPartID, region, "border-edge");

    testPotentialNeighborsCount(1, neighbors.length,  identification);

    if (myPart.xmin() != globalSimulation.xmin()) {
      testForAnyNeighbor(neighbors[0], partitions.length, identification);
    }
    else {
      testForNoNeighbor(neighbors[0], identification);
    }
View Full Code Here

   * 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) {
View Full Code Here

   * 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());
  }
 
View Full Code Here

        sharedDataManager, zoneOfLocalInfluence, localSettings.getParticleIterator());
  }


  private SharedDataManager createSharedDataManager() {
    IntBox simulationAreaInCellDimensions = new IntBox(
        0, globalSettings.getGridCellsX() - 1, 0, globalSettings.getGridCellsY() - 1);
    return new SharedDataManager(
        workerID,
        partitions,
        simulationAreaInCellDimensions,
View Full Code Here

  /**
   * In this mode the iterator does not calculate the extra cells.
   */
  public void setNormalMode(int numCellsX, int numCellsY) {
    dimensions = new IntBox(
        0, numCellsX - 1,
        0, numCellsY - 1);
  }
View Full Code Here

TOP

Related Classes of org.openpixi.pixi.physics.util.IntBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.