Package org.openpixi.pixi.distributed

Examples of org.openpixi.pixi.distributed.NeighborMap


    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);

    // Test boundary corner regions

    int region = BoundaryRegions.X_MIN + BoundaryRegions.Y_MIN;
    int neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(NeighborMap.NO_NEIGHBOR, neighbor);
    Point direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertNull(direction);

    region = BoundaryRegions.X_MAX + BoundaryRegions.Y_MAX;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(3, neighbor);
    direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertEquals(new Point(1, 1), direction);

    region = BoundaryRegions.X_MIN + BoundaryRegions.Y_MAX;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(1, neighbor);
    direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertEquals(new Point(0, 1), direction);

    // Test boundary edge regions

    region = BoundaryRegions.X_MIN + BoundaryRegions.Y_CENTER;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(NeighborMap.NO_NEIGHBOR, neighbor);
    direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertNull(direction);

    region = BoundaryRegions.X_MAX + BoundaryRegions.Y_CENTER;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(2, neighbor);
    direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertEquals(new Point(1, 0), direction);

    region = BoundaryRegions.X_CENTER + BoundaryRegions.Y_MAX;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(1, neighbor);
    direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertEquals(new Point(0, 1), direction);

    // Test border corner regions

    region = BorderRegions.X_BORDER_MIN + BorderRegions.Y_BORDER_MAX;
    int[] neighbors = neighborMap.getBorderNeighbors(region);
    int on1 = assertContains(neighbors, 1);
    assertContains(neighbors, NeighborMap.NO_NEIGHBOR);
    Point[] directions = neighborMap.getBorderNeighborsDirections(region);
    int od1 = assertContainsPoint(directions, new Point(0, 1));
    // Test order
    Assert.assertEquals(on1, od1);

    region = BorderRegions.X_BORDER_MAX + BorderRegions.Y_BORDER_MAX;
    neighbors = neighborMap.getBorderNeighbors(region);
    on1 = assertContains(neighbors, 1);
    int on2 = assertContains(neighbors, 2);
    int on3 = assertContains(neighbors, 3);
    directions = neighborMap.getBorderNeighborsDirections(region);
    od1 = assertContainsPoint(directions, new Point(0, 1));
    int od2 = assertContainsPoint(directions, new Point(1, 0));
    int od3 = assertContainsPoint(directions, new Point(1, 1));
    // Test order
    Assert.assertEquals(on1, od1);
    Assert.assertEquals(on2, od2);
    Assert.assertEquals(on3, od3);

    // Test border outside corner regions

    region = BorderRegions.X_BORDER_MAX + BorderRegions.Y_BOUNDARY_MIN;
    neighbors = neighborMap.getBorderNeighbors(region);
    assertContains(neighbors, 2);
    directions = neighborMap.getBorderNeighborsDirections(region);
    assertContainsPoint(directions, new Point(1, 0));

    region = BorderRegions.X_BOUNDARY_MAX + BorderRegions.Y_BORDER_MIN;
    neighbors = neighborMap.getBorderNeighbors(region);
    assertContains(neighbors, NeighborMap.NO_NEIGHBOR);
    directions = neighborMap.getBorderNeighborsDirections(region);
    Assert.assertEquals(1, directions.length);
    Assert.assertNull(directions[0]);

    // Test border edge regions

    region = BorderRegions.X_CENTER + BorderRegions.Y_BORDER_MAX;
    neighbors = neighborMap.getBorderNeighbors(region);
    assertContains(neighbors, 1);
    directions = neighborMap.getBorderNeighborsDirections(region);
    assertContainsPoint(directions, new Point(0, 1));

    region = BorderRegions.X_BORDER_MAX + BorderRegions.Y_CENTER;
    neighbors = neighborMap.getBorderNeighbors(region);
    assertContains(neighbors, 2);
    directions = neighborMap.getBorderNeighborsDirections(region);
    assertContainsPoint(directions, new Point(1, 0));
  }
View Full Code Here


    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);
      testSinglePeriodicMap(i, neighborMap, partitions.length);
    }
  }
View Full Code Here

    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);
      testSingleHardwallBoundaryMap(i, partitions, globalSimulation, neighborMap);
      testSingleHardwallBorderMap(i, partitions, globalSimulation, neighborMap);
    }
  }
View Full Code Here

    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);

    // Test boundary corner regions

    int region = BoundaryRegions.X_MIN + BoundaryRegions.Y_MIN;
    int neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(7, neighbor);
    Point direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertEquals(new Point(-1, -1), direction);

    region = BoundaryRegions.X_MAX + BoundaryRegions.Y_MAX;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(3, neighbor);
    direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertEquals(new Point(1, 1), direction);

    region = BoundaryRegions.X_MIN + BoundaryRegions.Y_MAX;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(3, neighbor);
    direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertEquals(new Point(-1, 1), direction);

    // Test boundary edge regions

    region = BoundaryRegions.X_MIN + BoundaryRegions.Y_CENTER;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(2, neighbor);
    direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertEquals(new Point(-1, 0), direction);

    region = BoundaryRegions.X_MAX + BoundaryRegions.Y_CENTER;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(2, neighbor);
    direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertEquals(new Point(1, 0), direction);

    region = BoundaryRegions.X_CENTER + BoundaryRegions.Y_MIN;
    neighbor = neighborMap.getBoundaryNeighbor(region);
    Assert.assertEquals(5, neighbor);
    direction = neighborMap.getBoundaryNeighborsDirections(region);
    Assert.assertEquals(new Point(0, -1), direction);

    // Test border corner regions

    region = BorderRegions.X_BORDER_MIN + BorderRegions.Y_BORDER_MIN;
    int[] neighbors = neighborMap.getBorderNeighbors(region);
    int on1 = assertContains(neighbors, 2);
    int on2 = assertContains(neighbors, 5);
    int on3 = assertContains(neighbors, 7);
    Point[] directions = neighborMap.getBorderNeighborsDirections(region);
    int od1 = assertContainsPoint(directions, new Point(-1, 0));
    int od2 = assertContainsPoint(directions, new Point(0, -1));
    int od3 = assertContainsPoint(directions, new Point(-1, -1));
    // Test order
    Assert.assertEquals(on1, od1);
    Assert.assertEquals(on2, od2);
    Assert.assertEquals(on3, od3);

    region = BorderRegions.X_BORDER_MAX + BorderRegions.Y_BORDER_MAX;
    neighbors = neighborMap.getBorderNeighbors(region);
    on1 = assertContains(neighbors, 1);
    on2 = assertContains(neighbors, 2);
    on3 = assertContains(neighbors, 3);
    directions = neighborMap.getBorderNeighborsDirections(region);
    od1 = assertContainsPoint(directions, new Point(0, 1));
    od2 = assertContainsPoint(directions, new Point(1, 0));
    od3 = assertContainsPoint(directions, new Point(1, 1));
    // Test order
    Assert.assertEquals(on1, od1);
    Assert.assertEquals(on2, od2);
    Assert.assertEquals(on3, od3);

    // Test border edge regions

    region = BorderRegions.X_CENTER + BorderRegions.Y_BORDER_MIN;
    neighbors = neighborMap.getBorderNeighbors(region);
    assertContains(neighbors, 5);
    directions = neighborMap.getBorderNeighborsDirections(region);
    assertContainsPoint(directions, new Point(0, -1));

    region = BorderRegions.X_BORDER_MAX + BorderRegions.Y_CENTER;
    neighbors = neighborMap.getBorderNeighbors(region);
    assertContains(neighbors, 2);
    directions = neighborMap.getBorderNeighborsDirections(region);
    assertContainsPoint(directions, new Point(1, 0));
  }
View Full Code Here

TOP

Related Classes of org.openpixi.pixi.distributed.NeighborMap

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.