|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.sim.space.Diffuse2D
uchicago.src.sim.space.Diffuse2DHexagonal
public class Diffuse2DHexagonal
Discrete 2nd order approximation of 2d diffusion with evaporation on a hexagonal grid. Based on the Objective C implementation of Diffuse2d in the Swarm simulation toolkit, with the addition of a hexagonal grid. Toroidal in shape and works with number values. This space simulates concurency through the use of a read and write matrix. Any writes to the space, write to the write matrix, and any reads to the read matrix. The diffuse() method then diffuses the write matrix and copies the new values into the read matrix.
The hexagonal cells are referenced by x, y coordinates as follows:
_
_ / 1 \ _
/ 0 \ _ / 2 \
\ _ / 4 \ _ /
/ 3 \ _ / 5 \
\ _ / 7 \ _ /
/ 6 \ _ / 8 \
\ _ / \ _ /
Here we have a 3 x 3 hexagonal grid. The first row of cells is 0,
1, 2 such that 0,0 refers to cell 0, and 0,2 refers to cell 2. The
next row of cells is 3, 4, 5, so 1,0 refers to cell 3 and so
on. The last row of cells is 6, 7, and 8, so 2, 0 refers to cell 6.
The ring of neighbors with radius one that surrounds cell 4 is
composed of 1, 2, 5, 7, 3, and 0. The grid wraps as a toriod such
that cell -1, 0 refers to cell 2 and cell 0, -1 is cell 6.
See diffuse for a brief explanation of the diffusion
algorithm.
| Field Summary |
|---|
| Fields inherited from class uchicago.src.sim.space.Diffuse2D |
|---|
diffCon, evapRate, MAX, MIN, nextX, nextY, prevX, prevY, readMatrix, writeMatrix, x, xSize, y, ySize |
| Fields inherited from interface uchicago.src.sim.space.Discrete2DSpace |
|---|
MOORE, VON_NEUMANN |
| Constructor Summary | |
|---|---|
Diffuse2DHexagonal(double diffusionConstant,
double evaporationRate,
int xSize,
int ySize)
Constructs a Diffuse2DHexagonal space with the specified diffusion constant, evaporation rate, and dimensions |
|
Diffuse2DHexagonal(int xSize,
int ySize)
Constructs a Diffuse2DHexagonal space with the specificed dimensions |
|
| Method Summary | |
|---|---|
void |
diffuse()
Runs the diffusion with the current rates and values. |
double[] |
findMaximum(int x,
int y,
int radius,
boolean includeOrigin)
Finds the maximum grid cell value within a specified radius from the specified origin coordinate. |
double[] |
findMinimum(int x,
int y,
int radius,
boolean includeOrigin)
Finds the maximum grid cell value within a specified radius from the specified origin coordinate. |
double[] |
getMooreNeighbors(int x,
int y)
The notion of a Moore neighborhood is incoherent on a hexagonal grid. |
double[] |
getMooreNeighbors(int x,
int y,
int xExtent,
int yExtent)
The notion of a Moore neighborhood is incoherent for a hexagonal grid. |
double[] |
getNeighbors(int x,
int y)
Returns the ring of neighbors with a radius of 1 surrounding the cell at x, y. |
double[] |
getNeighbors(int x,
int y,
int radius)
Returns the rings of neighbors surrounding the cell at x, y. |
double[] |
getVonNeumannNeighbors(int x,
int y)
The notion of a vonNeumann neighborhood is incoherent for a hexagonal grid. |
double[] |
getVonNeumannNeighbors(int x,
int y,
int xExtent,
int yExtent)
The notion of a vonNeumann neighborhood is incoherent for a hexagonal grid. |
| Methods inherited from class uchicago.src.sim.space.Diffuse2D |
|---|
compareMax, compareMin, findMaximum, findMinimum, getMatrix, getObjectAt, getSize, getSizeX, getSizeY, getValueAt, putObjectAt, putValueAt, setDiffusionConstant, setEvaporationRate, update, xnorm, ynorm |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Diffuse2DHexagonal(int xSize,
int ySize)
xSize - size of the x dimensionySize - size of the y dimension
public Diffuse2DHexagonal(double diffusionConstant,
double evaporationRate,
int xSize,
int ySize)
diffusionConstant - the diffusion constantevaporationRate - the evaporation ratexSize - size of the x dimensionySize - size of the y dimension| Method Detail |
|---|
public void diffuse()
Values from the readMatrix are used to calculate diffusion. This value is then written to the writeMatrix. When this has been done for every cell in the grid, the writeMatrix is copied to the readMatrix.
diffuse in class Diffuse2D
public double[] getVonNeumannNeighbors(int x,
int y)
getNeighbors or
getNeighbors.
getVonNeumannNeighbors in class Diffuse2Dx - the x coordinate of the objecty - the y coordinate of the object
java.lang.UnsupportedOperationException - when called
public double[] getVonNeumannNeighbors(int x,
int y,
int xExtent,
int yExtent)
getNeighbors or
getNeighbors.
getVonNeumannNeighbors in class Diffuse2Dx - the x coordinate of the objecty - the y coordinate of the objectxExtent - the extension of the neighborhood in the x directionyExtent - the extension of the neighborhood in the y direction
java.lang.UnsupportedOperationException - when called
public double[] getMooreNeighbors(int x,
int y)
getNeighbors or
getNeighbors.
getMooreNeighbors in class Diffuse2Dx - the x coordinate of the objecty - the y coordinate of the object
java.lang.UnsupportedOperationException - when called
public double[] getMooreNeighbors(int x,
int y,
int xExtent,
int yExtent)
getNeighbors or
getNeighbors.
getMooreNeighbors in class Diffuse2Dx - the x coordinate of the objecty - the y coordinate of the objectxExtent - the extension of the neighborhood in the x directionyExtent - the extension of the neighborhood in the y direction
java.lang.UnsupportedOperationException - when called
public double[] getNeighbors(int x,
int y)
x - the x coordinate of the celly - the y coordinate of the cell
public double[] getNeighbors(int x,
int y,
int radius)
x - the x coordinate of the celly - the y coordinate of the cellradius - the number of neighbor rings to return
public double[] findMaximum(int x,
int y,
int radius,
boolean includeOrigin)
x - the x origin coordinatey - the y origin coordinateradius - the neighborhood radius defining the area to searchincludeOrigin - include object at origin in search
public double[] findMinimum(int x,
int y,
int radius,
boolean includeOrigin)
x - the x origin coordinatey - the y origin coordinateradius - the neighborhood radius defining the area to searchincludeOrigin - include object at origin in search
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||