de.tubs.cs.sc.casim
Class Lattice3D

java.lang.Object
  |
  +--de.tubs.cs.sc.casim.Lattice
        |
        +--de.tubs.cs.sc.casim.CALattice
              |
              +--de.tubs.cs.sc.casim.Lattice3D
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Lattice3DNative

public class Lattice3D
extends CALattice

represents a three dimensional Lattice of cells. All cells are arranged in rows and columns and levels. The data structure is a three dimensional array of Cells.

See Also:
Lattice, Cell, Serialized Form

Field Summary
 
Fields inherited from class de.tubs.cs.sc.casim.CALattice
neighborhoodIndexes
 
Fields inherited from class de.tubs.cs.sc.casim.Lattice
boundaryHandler, lx, ly, lz
 
Constructor Summary
Lattice3D(java.lang.Class state, de.tubs.cs.sc.casim.LatticeDefinition ldef)
          Constructor creates the three dimensional array of cells and 6 BoundaryHandler calls reset to initialize all cells
 
Method Summary
protected  void backup()
          calls backup for each cell
 int getDimension()
           
protected  de.tubs.cs.sc.casim.State getNeighborRelative(de.tubs.cs.sc.casim.Cell cell, int x, int y, int z)
          returns the relative neighbor of cell with given relative coordinates.
protected  de.tubs.cs.sc.casim.State[] getNeighborsArbitrary(de.tubs.cs.sc.casim.Cell cell)
          returns a previously defined arbitrary neighborhood.
protected  de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell c)
          returns the Moore neighborhood with radius 1.
protected  de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell cell, int r)
          returns the Moore neighborhood with radius r.
protected  de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell)
          returns the von Neumann neighborhood with radius 1.
protected  de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell, int r)
          returns the von Neumann neighborhood with radius r.
protected  int getNrOfNeighbors()
           
 de.tubs.cs.sc.casim.State getOldState(int x, int y, int z)
          returns the old state at the given coordinates.
 de.tubs.cs.sc.casim.State getState(int x)
          always throws a RuntimeException
 de.tubs.cs.sc.casim.State getState(int x, int y)
          always throws a RuntimeException
 de.tubs.cs.sc.casim.State getState(int x, int y, int z)
          returns the current state at the given coordinates.
protected  void reset()
          reallocates all cells and calls again State.initialize for one cell
protected  void setIs(int i1, int i2, int i3)
          Set the position in the lattice for neighborhood accesses.
protected  void transition()
          calls transition for each cells state
 
Methods inherited from class de.tubs.cs.sc.casim.CALattice
defineNeighborsArbitrary, getNeighbors, reversetransition
 
Methods inherited from class de.tubs.cs.sc.casim.Lattice
addBoundaryHandler, beginBlock, callAnalyze, callInitialize, endBlock, finish, getBoundaryHandler, getDefinition, getStateClass, getX, getY, getZ, setNeighborhood, waitForReadyForBackup, waitForReadyForTransition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lattice3D

public Lattice3D(java.lang.Class state,
                 de.tubs.cs.sc.casim.LatticeDefinition ldef)
          throws CAException
Constructor creates the three dimensional array of cells and 6 BoundaryHandler calls reset to initialize all cells

Parameters:
state - the Java class of the State of the cells of the lattice
ldef - the LatticeDefinition with further lattice parameters
Method Detail

getDimension

public int getDimension()
Specified by:
getDimension in class Lattice
Returns:
the dimension of the lattice

reset

protected void reset()
              throws CAException
reallocates all cells and calls again State.initialize for one cell

Specified by:
reset in class Lattice
CAException

getState

public de.tubs.cs.sc.casim.State getState(int x)
always throws a RuntimeException

Specified by:
getState in class Lattice
Returns:
the current state at position x
See Also:
Lattice1D.getState(int)

getState

public de.tubs.cs.sc.casim.State getState(int x,
                                          int y)
always throws a RuntimeException

Specified by:
getState in class Lattice
Returns:
the current state at position x,y
See Also:
Lattice2D.getState(int)

getState

public de.tubs.cs.sc.casim.State getState(int x,
                                          int y,
                                          int z)
returns the current state at the given coordinates. getState should be used in State's override initialize to init all states of the CA. The returned reference must be casted to a class derived from abstract class State.

Specified by:
getState in class Lattice
Returns:
the current state at position x,y,z

getOldState

public de.tubs.cs.sc.casim.State getOldState(int x,
                                             int y,
                                             int z)
returns the old state at the given coordinates. getOldState is used by Cell to calculate the neighborhood set and by BoundaryHandlers.getOutSideState.

Specified by:
getOldState in class Lattice
Returns:
the old state at position x,y,z
See Also:
Cell.getNeighbors(), BoundaryHandler.getOutsideState(int)

backup

protected void backup()
calls backup for each cell

Specified by:
backup in class Lattice
See Also:
Lattice.backup()

transition

protected void transition()
calls transition for each cells state

Specified by:
transition in class Lattice
See Also:
Lattice.transition()

getNrOfNeighbors

protected int getNrOfNeighbors()
Specified by:
getNrOfNeighbors in class CALattice
Returns:
the number of neighbors of every cell in the lattice

getNeighborsMoore

protected de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell cell,
                                                        int r)
returns the Moore neighborhood with radius r.

Specified by:
getNeighborsMoore in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsvonNeumann

protected de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell,
                                                             int r)
returns the von Neumann neighborhood with radius r.

Specified by:
getNeighborsvonNeumann in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsMoore

protected de.tubs.cs.sc.casim.State[] getNeighborsMoore(de.tubs.cs.sc.casim.Cell c)
returns the Moore neighborhood with radius 1.

Specified by:
getNeighborsMoore in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsvonNeumann

protected de.tubs.cs.sc.casim.State[] getNeighborsvonNeumann(de.tubs.cs.sc.casim.Cell cell)
returns the von Neumann neighborhood with radius 1.

Specified by:
getNeighborsvonNeumann in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborRelative

protected de.tubs.cs.sc.casim.State getNeighborRelative(de.tubs.cs.sc.casim.Cell cell,
                                                        int x,
                                                        int y,
                                                        int z)
returns the relative neighbor of cell with given relative coordinates.

Specified by:
getNeighborRelative in class CALattice
Returns:
a State, the reference must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

getNeighborsArbitrary

protected de.tubs.cs.sc.casim.State[] getNeighborsArbitrary(de.tubs.cs.sc.casim.Cell cell)
returns a previously defined arbitrary neighborhood.

Specified by:
getNeighborsArbitrary in class CALattice
Returns:
an array of States, all references must be casted to the State subclass.
See Also:
CALattice.getNeighbors(de.tubs.cs.sc.casim.Cell)

setIs

protected void setIs(int i1,
                     int i2,
                     int i3)
Set the position in the lattice for neighborhood accesses. This is used for subclasses that implement transition directly, but need to access th eoriginal trnasition function at the borders.