Package xal.tools.math.r3
Class Grid
java.lang.Object
xal.tools.math.r3.Grid
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
PoissonGrid
Represents a regular grid in three dimensions. Grid resolution may vary in each dimension, however, no uneven mesh spacing is permitted. Consequently, operations on this grid are less general but faster.
This class was originally meant to be used in a multi-particle probe for multi-particle simulations. I don't believe it is being used for anything right now.
- Since:
- Jan 24, 2003
- Author:
- Christopher Allen
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected xal.tools.math.r3.Grid.GridCell[][][]
allocateCells
(int n1, int n2, int n3) Allocates the array of grid cell objects.protected xal.tools.math.r3.Grid.GridPt[][][]
allocatePts
(int n1, int n2, int n3) Allocates the array of grid point objects.xal.tools.math.r3.Grid.GridCell
compCellContaining
(R3 pt) Return the grid cell containing this point.compCellIndex
(R3 pt) Compute the base vertex index of grid cell containing this point.compPtCoords
(int i, int j, int k) Return the coordinates in R3 of the grid point at index (i,j,k)compPtCoords
(Z3 vecIndex) Return the coordinates in R3 of the grid point at index (i,j,k)protected xal.tools.math.r3.Grid.GridCell
getGridCell
(int i, int j, int k) Return the grid cell object located at grid point index.protected xal.tools.math.r3.Grid.GridCell
getGridCell
(Z3 vecInd) Return the grid cell object located at grid cell index.Get the domain of the grid in R3.Get the coordinates of the grid origin, i.e., the first grid vertex.protected xal.tools.math.r3.Grid.GridPt
getGridPt
(int i, int j, int k) Return the grid point object located at grid point index.protected xal.tools.math.r3.Grid.GridPt
Return the grid point object located at grid point index.Get grid resolution.Get the size of the supporting object array.double
getPtValue
(int i, int j, int k) Get the function value at the grid point indexed by (i,j,k)Compute and return the interpolated function gradient at the point pt.double
interpolateValue
(R3 pt) Compute and return the interpolated function value at the point ptstatic void
Testing engineboolean
membershipGrid
(R3 pt) Determine whether a point is an element of the domain of definition for this grid.void
print
(PrintWriter os) Print out grid parameters on an output streamvoid
setGridDomain
(ClosedBox boxDom) Set the domain in R3 which the grid occupies.void
setPtValue
(int i, int j, int k, double dblVal) Set the function value at grid point given by index
-
Constructor Details
-
Grid
Allocate a new Grid- Parameters:
n1
- number of grid points in first dimensionn2
- number of grid points in second dimensionn3
- number of grid points in third dimension- Throws:
GridException
- unable to allocate grid objects
-
Grid
Allocate a new instance of GridR3 and set the domain.- Parameters:
n1
- number of grid points in first dimensionn2
- number of grid points in second dimensionn3
- number of grid points in third dimensionboxDom
- descriptor of grid domain in R3- Throws:
GridException
- invalid size vector encountered
-
-
Method Details
-
setGridDomain
Set the domain in R3 which the grid occupies. All grid point locations are determined by this descriptor.- Parameters:
boxDom
- description of the grid position and size in R3- Throws:
GridException
-
setPtValue
public void setPtValue(int i, int j, int k, double dblVal) Set the function value at grid point given by index- Parameters:
i
- first dimension index of grid pointj
- second dimension index of grid pointk
- third dimension index of grid pointdblVal
- value of the function at grid point (i,j,k)
-
getGridSize
Get the size of the supporting object array.- Returns:
- vector of array dimensions (nx, ny, nz)
-
getGridDomain
Get the domain of the grid in R3.- Returns:
- a ClosedBox object describing the domain of definition for this grid
-
getGridResolution
Get grid resolution.- Returns:
- vector (dx,dy,dz) of spacing between grid points
-
getGridOrigin
Get the coordinates of the grid origin, i.e., the first grid vertex.- Returns:
- (x,y,z) coordinates of grid origin
-
getPtValue
public double getPtValue(int i, int j, int k) Get the function value at the grid point indexed by (i,j,k)- Parameters:
i
- index of the first grid dimensionj
- index of the second grid dimensionk
- index of the third grid dimension- Returns:
- function value stored at grid point (i,j,k)
-
membershipGrid
Determine whether a point is an element of the domain of definition for this grid.- Parameters:
pt
- point in R3 to check membership- Returns:
- true if pt is in domain of definition
-
compCellIndex
Compute the base vertex index of grid cell containing this point. The base vertex is the vertex of the grid cell with smallest l1 norm. Grid cells are assigned by this index.- Parameters:
pt
- pt in R3 (within the grid's domain of definition)- Returns:
- index of grid cell owning pt
-
compPtCoords
Return the coordinates in R3 of the grid point at index (i,j,k)- Parameters:
i
- x-dimension index of grid pointj
- y-dimension index of grid pointk
- k-dimension index of grid point- Returns:
- (x,y,z) coordinate of grid point at (i,j,k)
-
compPtCoords
Return the coordinates in R3 of the grid point at index (i,j,k)- Parameters:
vecIndex
- (i,j,k) index vector of grid point- Returns:
- (x,y,z) coordinate of grid point at (i,j,k)
-
compCellContaining
Return the grid cell containing this point.- Parameters:
pt
- pt in R3 (within the grid's domain of definition)- Returns:
- grid cell object contain pt
-
interpolateValue
Compute and return the interpolated function value at the point pt- Parameters:
pt
- interpolation point- Returns:
- interpolated function value
-
interpolateGradient
Compute and return the interpolated function gradient at the point pt. The gradient is taken with respect to the local coordinates of a grid cell. Thus, the true gradient must be scaled by the grid resolution and any other differential element particular to the coordinate system being used.- Parameters:
pt
- interpolation point- Returns:
- gradient (w.r.t. local cell coords) of function
-
print
Print out grid parameters on an output stream- Parameters:
os
- output stream to receive text description of grid
-
main
Testing engine -
getGridPt
protected xal.tools.math.r3.Grid.GridPt getGridPt(int i, int j, int k) Return the grid point object located at grid point index.- Parameters:
i
- 1st dimension grid point indexj
- 2nd dimension grid point indexk
- 3rd dimension grid point index- Returns:
- object located at grid point (i,j,k)
-
getGridPt
Return the grid point object located at grid point index.- Parameters:
vecInd
- vector index (i,j,k) of grid point- Returns:
- object located at grid point (i,j,k)
-
getGridCell
protected xal.tools.math.r3.Grid.GridCell getGridCell(int i, int j, int k) Return the grid cell object located at grid point index.- Parameters:
i
- 1st dimension grid cell indexj
- 2nd dimension grid cell indexk
- 3rd dimension grid cell index- Returns:
- object located at grid cell (i,j,k)
-
getGridCell
Return the grid cell object located at grid cell index.- Parameters:
vecInd
- vector index (i,j,k) of grid cell- Returns:
- object located at grid cell (i,j,k)
-
allocatePts
protected xal.tools.math.r3.Grid.GridPt[][][] allocatePts(int n1, int n2, int n3) Allocates the array of grid point objects. Derived classes may create grid point objects derived from GridPt to perform specific tasks. Derived classes must override this method if the GridPt class also sub-classed. The array of appropriate child class of GridPt should be returned.- Parameters:
n1
- , n2, n3 dimensions of the array (n1, n2, n3)- Returns:
- array of objects living at grid points
-
allocateCells
protected xal.tools.math.r3.Grid.GridCell[][][] allocateCells(int n1, int n2, int n3) Allocates the array of grid cell objects. Derived classes may create grid cell objects derived from GridCell to perform specific tasks. Derived classes must override this method if the GridCell class also subclassed. The array of appropriate child class of GridCell should be returned.- Parameters:
n1
- , n2, n3 dimensions of the array (nx, ny, nz)- Returns:
- array of objects composing grid cells
-