Class defining a spatial grid, i.e. a matrix of double. The grid is padded, 3D grid. More...
Public Member Functions | |
SpatialGrid () | |
Blank constructor. More... | |
SpatialGrid (int nI, int nJ, int nK, double resolution) | |
Default constructor for an empty spatial grid. More... | |
SpatialGrid (int nI, int nJ, double resolution) | |
Default constructor for an empty 2D spatial grid. More... | |
boolean | isValid (DiscreteVector dC) |
Determine if a given discrete position is valid or outside the grid (Padding excluded) More... | |
boolean | isValidOrPadded (DiscreteVector dC) |
Determine if a given discrete position is valid or outside the grid (Padding included) More... | |
boolean | isValidorPadded (int i, int j, int k) |
Determine if a given voxel coordinate is valid or outside the grid. More... | |
boolean | isValid (ContinuousVector cc) |
Determine if a given continuous location is valid or outside the grid. More... | |
boolean | isValidOrPadded (ContinuousVector cc) |
Test if a location is valid or is outside the grid. Note padding is included as valid. More... | |
DiscreteVector | getDiscreteCoordinates (ContinuousVector cC) |
Transform a location, expressed as a continuous vector into a discrete position on the basis of the resolution of the grid. More... | |
ContinuousVector | getContinuousCoordinates (DiscreteVector dC) |
Transform a position, expressed as a discrete vector into a continuous location on the basis of the resolution of the grid. More... | |
ContinuousVector | getContinuousCoordinates (int i, int j, int k) |
Convert a set of voxel coordinates into a continuous vector. More... | |
double | getMax () |
Return the maximum value on this grid (padding included) More... | |
double | getAverage () |
Return the average value on this grid (padding included) More... | |
double | getSum () |
Return the sum of this grid. More... | |
double | getMin () |
Return the minimum value on this grid (padding included) More... | |
double | diff2X (int i, int j, int k) |
For a given location, calculate the 2nd spatial derivative according to X. More... | |
double | diff2X (DiscreteVector dV) |
For a given location, expressed as a discrete vector, calculate the 2nd spatial derivative according to X. More... | |
double | diffX (int i, int j, int k) |
For a given location, calculate the 1st spatial derivative according to X. More... | |
double | diffX (DiscreteVector dV) |
For a given location, expressed as a discrete vector, calculate the 1st spatial derivative according to X. More... | |
double | diff2Y (int i, int j, int k) |
For a given location, calculate the 2nd spatial derivative according to Y. More... | |
double | diff2Y (DiscreteVector dV) |
For a given location, expressed as a discrete vector, calculate the 2nd spatial derivative according to Y. More... | |
double | diffY (int i, int j, int k) |
For a given location, calculate the 1st spatial derivative according to Y. More... | |
double | diffY (DiscreteVector dV) |
For a given location, expressed as a discrete vector, calculate the 1st spatial derivative according to Y. More... | |
double | diff2Z (int i, int j, int k) |
For a given location, calculate the 2nd spatial derivative according to Z. More... | |
double | diffZ (int i, int j, int k) |
For a given location, calculate the 1st spatial derivative according to Z. More... | |
double | diffZ (DiscreteVector dV) |
For a given location, expressed as a discrete vector, calculate the 1st spatial derivative according to Z. More... | |
double | getValueAround (ContinuousVector cC, double extReso) |
Computes the average concentration seen in a sphere (or cube) centered around a given point. More... | |
double | getValueAround (LocatedAgent aLocAgent) |
Returns the average grid value seen in a sphere (or cube) located around a given agent. More... | |
double | getValueAt (ContinuousVector cC) |
Return the value stored at the location given by the stated continuous vector. More... | |
ContinuousVector | getGradient (ContinuousVector cC) |
Returns a vector of the first spatial derivatives in x, y & z. More... | |
ContinuousVector | getGradient2D (ContinuousVector cC) |
Returns a vector of the first spatial derivatives in x and y, for 2D simulations. More... | |
double | getValueAt (DiscreteVector dV) |
Return the value on the padded grid at a given position (the coordinates are NOT corrected) More... | |
double | getValueAt (int i, int j, int k) |
Return the value on the padded grid at a given position (the coordinates are NOT corrected) More... | |
void | setValueAt (double value, ContinuousVector cC) |
Set a grid location, expressed as a ContinuousVector, to a specified value. The coordinates are corrected. More... | |
void | setValueAt (double value, DiscreteVector dC) |
Set a grid location, expressed as a DiscreteVector, to a specified value. The coordinates are corrected. More... | |
void | setValueAt (double value, int i, int j, int k) |
Set a grid location to a specified value. Note the coordinates are NOT corrected. More... | |
void | addValueAt (double value, ContinuousVector cC) |
Add a value to that contained at the given discrete coordinates of this grid. Coordinates are corrected for padding. More... | |
void | addValueAt (double value, DiscreteVector dC) |
Add a value to that contained at the given discrete coordinates of this grid. Coordinates are corrected for padding. More... | |
void | addAllValues (double value) |
Add a value to all locations on this grid (including the padding) More... | |
void | truncateValueAt (int i, int j, int k) |
Checks a value at a given location and sets it to zero if the value is negative. More... | |
void | setAllValueAt (double value) |
Set all meshes of a grid with the same value (including the padding - if not a chemostat run) More... | |
int | getGridSizeI () |
Return the number of voxels in the X direction. More... | |
int | getGridSizeJ () |
Return the number of voxels in the Y direction. More... | |
int | getGridSizeK () |
Return the number of voxels in the Z direction. More... | |
int | getGridTotalSize (int axeCode) |
Return the number of voxels along a given direction (axeCode) More... | |
double | getGridLength (int axeCode) |
Returns the length (in distance unit) along a given direction. More... | |
double | getVoxelVolume () |
Return the volume of one voxel of the spatial grid. More... | |
double[][][] | getGrid () |
Return the whole grid including the padding. More... | |
double[][][] | getCloneGrid () |
Return a clone of this spatial grid. More... | |
double | getResolution () |
Returns the resolution of this spatial grid. More... | |
boolean | is3D () |
Determine if this spatial grid is 3D or 2D. More... | |
void | setGrid (double[][][] u) |
Set the values of this spatial grid to those contained in the supplied grid. More... | |
void | writeReport (ResultFile bufferState, ResultFile bufferSummary) throws Exception |
Write the contents of this grid to the XML results files. More... | |
Public Attributes | |
String | gridName |
String | gridUnit = "g.L-1" |
double[][][] | grid |
Protected Member Functions | |
void | initGrids () |
Creates the solute grid at the required size. More... | |
Protected Attributes | |
int | _nI |
int | _nJ |
int | _nK |
double | _reso |
boolean | _is3D |
Class defining a spatial grid, i.e. a matrix of double. The grid is padded, 3D grid.
Class defining a spatial grid, i.e. a matrix of double. The grid is padded, 3D grid
simulator.SpatialGrid.SpatialGrid | ( | ) |
Blank constructor.
Blank constructor
simulator.SpatialGrid.SpatialGrid | ( | int | nI, |
int | nJ, | ||
int | nK, | ||
double | resolution | ||
) |
Default constructor for an empty spatial grid.
Default constructor for an empty spatial grid. Sets the grid resolution and dimensions as provided in the simulation protocol file
nI | The number of grid locations in the I direction |
nJ | The number of grid locations in the J direction |
nK | The number of grid locations in the K direction |
resolution | the grid resolution |
simulator.SpatialGrid.SpatialGrid | ( | int | nI, |
int | nJ, | ||
double | resolution | ||
) |
Default constructor for an empty 2D spatial grid.
Default constructor for an empty 2D spatial grid. Sets the grid resolution and dimensions as provided in the simulation protocol file
nI | The number of grid locations in the I direction |
nJ | The number of grid locations in the J direction |
resolution | the grid resolution |
void simulator.SpatialGrid.addAllValues | ( | double | value | ) |
Add a value to all locations on this grid (including the padding)
Add a value to all locations on this grid (including the padding)
value | Value to be added to the contents of all grid voxels |
void simulator.SpatialGrid.addValueAt | ( | double | value, |
ContinuousVector | cC | ||
) |
Add a value to that contained at the given discrete coordinates of this grid. Coordinates are corrected for padding.
Add a value to that contained at the given discrete coordinates of this grid. Coordinates are corrected for padding
value | Value to add to the specified grid location |
cC | Continuous vector expressing the location of the grid to be increased |
void simulator.SpatialGrid.addValueAt | ( | double | value, |
DiscreteVector | dC | ||
) |
Add a value to that contained at the given discrete coordinates of this grid. Coordinates are corrected for padding.
Add a value to that contained at the given discrete coordinates of this grid. Coordinates are corrected for padding
value | Value to add to the specified grid location |
dC | Discrete vector expressing the location of the grid to be increased |
double simulator.SpatialGrid.diff2X | ( | int | i, |
int | j, | ||
int | k | ||
) |
For a given location, calculate the 2nd spatial derivative according to X.
For a given location, calculate the 2nd spatial derivative according to X
i | I position on the spatial grid |
j | J position on the spatial grid |
k | K position on the spatial grid |
double simulator.SpatialGrid.diff2X | ( | DiscreteVector | dV | ) |
For a given location, expressed as a discrete vector, calculate the 2nd spatial derivative according to X.
For a given location, expressed as a discrete vector, calculate the 2nd spatial derivative according to X
dV | DiscreteVector containing the position of a grid location |
double simulator.SpatialGrid.diff2Y | ( | int | i, |
int | j, | ||
int | k | ||
) |
For a given location, calculate the 2nd spatial derivative according to Y.
For a given location, calculate the 2nd spatial derivative according to Y
i | I position on the spatial grid |
j | J position on the spatial grid |
k | K position on the spatial grid |
double simulator.SpatialGrid.diff2Y | ( | DiscreteVector | dV | ) |
For a given location, expressed as a discrete vector, calculate the 2nd spatial derivative according to Y.
For a given location, expressed as a discrete vector, calculate the 2nd spatial derivative according to Y
dV | DiscreteVector containing the position of a grid location |
double simulator.SpatialGrid.diff2Z | ( | int | i, |
int | j, | ||
int | k | ||
) |
For a given location, calculate the 2nd spatial derivative according to Z.
For a given location, calculate the 2nd spatial derivative according to Z
i | I position on the spatial grid |
j | J position on the spatial grid |
k | K position on the spatial grid |
double simulator.SpatialGrid.diffX | ( | int | i, |
int | j, | ||
int | k | ||
) |
For a given location, calculate the 1st spatial derivative according to X.
For a given location, calculate the 1st spatial derivative according to X
i | I position on the spatial grid |
j | J position on the spatial grid |
k | K position on the spatial grid |
double simulator.SpatialGrid.diffX | ( | DiscreteVector | dV | ) |
For a given location, expressed as a discrete vector, calculate the 1st spatial derivative according to X.
For a given location, expressed as a discrete vector, calculate the 1st spatial derivative according to X
dV | DiscreteVector containing the position of a grid location |
double simulator.SpatialGrid.diffY | ( | int | i, |
int | j, | ||
int | k | ||
) |
For a given location, calculate the 1st spatial derivative according to Y.
For a given location, calculate the 1st spatial derivative according to Y
i | I position on the spatial grid |
j | J position on the spatial grid |
k | K position on the spatial grid |
double simulator.SpatialGrid.diffY | ( | DiscreteVector | dV | ) |
For a given location, expressed as a discrete vector, calculate the 1st spatial derivative according to Y.
For a given location, expressed as a discrete vector, calculate the 1st spatial derivative according to Y
dV | DiscreteVector containing the position of a grid location |
double simulator.SpatialGrid.diffZ | ( | int | i, |
int | j, | ||
int | k | ||
) |
For a given location, calculate the 1st spatial derivative according to Z.
For a given location, calculate the 1st spatial derivative according to Z
i | I position on the spatial grid |
j | J position on the spatial grid |
k | K position on the spatial grid |
double simulator.SpatialGrid.diffZ | ( | DiscreteVector | dV | ) |
For a given location, expressed as a discrete vector, calculate the 1st spatial derivative according to Z.
For a given location, expressed as a discrete vector, calculate the 1st spatial derivative according to Z
dV | DiscreteVector containing the position of a grid location |
double simulator.SpatialGrid.getAverage | ( | ) |
Return the average value on this grid (padding included)
Return the average value on this grid (padding included)
double [][][] simulator.SpatialGrid.getCloneGrid | ( | ) |
Return a clone of this spatial grid.
Return a clone of this spatial grid
ContinuousVector simulator.SpatialGrid.getContinuousCoordinates | ( | DiscreteVector | dC | ) |
Transform a position, expressed as a discrete vector into a continuous location on the basis of the resolution of the grid.
Transform a position, expressed as a discrete vector into a continuous location on the basis of the resolution of the grid
dC | DiscreteVector to be transformed |
ContinuousVector simulator.SpatialGrid.getContinuousCoordinates | ( | int | i, |
int | j, | ||
int | k | ||
) |
Convert a set of voxel coordinates into a continuous vector.
Convert a set of voxel coordinates into a continuous vector
i | I Coordinate of the grid location |
j | J Coordinate of the grid location |
k | K Coordinate of the grid location |
DiscreteVector simulator.SpatialGrid.getDiscreteCoordinates | ( | ContinuousVector | cC | ) |
Transform a location, expressed as a continuous vector into a discrete position on the basis of the resolution of the grid.
Transform a location, expressed as a continuous vector into a discrete position on the basis of the resolution of the grid
cC | ContinuousVector to be transformed |
ContinuousVector simulator.SpatialGrid.getGradient | ( | ContinuousVector | cC | ) |
Returns a vector of the first spatial derivatives in x, y & z.
Returns a vector of the first spatial derivatives in x, y & z (nabla cC - see http://en.wikipedia.org/wiki/Del). Does this by first converting the ContinuousVector to a DiscreteVector and then estimating then gradient using the Mean Value Theorem (http://en.wikipedia.org/wiki/Mean_value_theorem).
cC | ContinuousVector position used to calculate the gradient |
ContinuousVector simulator.SpatialGrid.getGradient2D | ( | ContinuousVector | cC | ) |
Returns a vector of the first spatial derivatives in x and y, for 2D simulations.
Returns a vector of the first spatial derivatives in x and y (nabla cC - see http://en.wikipedia.org/wiki/Del). Does this by first converting the ContinuousVector to a DiscreteVector and then estimating then gradient using the Mean Value Theorem (http://en.wikipedia.org/wiki/Mean_value_theorem).
cC | ContinuousVector position used to calculate the gradient |
double [][][] simulator.SpatialGrid.getGrid | ( | ) |
Return the whole grid including the padding.
Return the whole grid including the padding
double simulator.SpatialGrid.getGridLength | ( | int | axeCode | ) |
Returns the length (in distance unit) along a given direction.
Returns the length (in distance unit) along a given direction. The direction is stated as an integer: 1 for X, 2 for Y, 3 for Z
axeCode | The direction of which the length is required: 1-X, 2-Y, 3-Z |
int simulator.SpatialGrid.getGridSizeI | ( | ) |
Return the number of voxels in the X direction.
Return the number of voxels in the X direction (ignoring the padding)
int simulator.SpatialGrid.getGridSizeJ | ( | ) |
Return the number of voxels in the Y direction.
Return the number of voxels in the Y direction (ignoring the padding)
int simulator.SpatialGrid.getGridSizeK | ( | ) |
Return the number of voxels in the Z direction.
Return the number of voxels in the Z direction (ignoring the padding)
int simulator.SpatialGrid.getGridTotalSize | ( | int | axeCode | ) |
Return the number of voxels along a given direction (axeCode)
Return the number of voxels along a given direction (axeCode): 1-X, 2-Y,3-Z
axeCode | Integer noting the direction to query |
double simulator.SpatialGrid.getMax | ( | ) |
Return the maximum value on this grid (padding included)
Return the maximum value on this grid (padding included)
double simulator.SpatialGrid.getMin | ( | ) |
Return the minimum value on this grid (padding included)
Return the minimum value on this grid (padding included)
double simulator.SpatialGrid.getResolution | ( | ) |
Returns the resolution of this spatial grid.
Returns the resolution of this spatial grid
double simulator.SpatialGrid.getSum | ( | ) |
Return the sum of this grid.
Return the sum of this grid
double simulator.SpatialGrid.getValueAround | ( | ContinuousVector | cC, |
double | extReso | ||
) |
Computes the average concentration seen in a sphere (or cube) centered around a given point.
Computes the average concentration seen in a sphere (or cube) centered around a given point
cC | ContinuousVector containing the point to use as the centre of this search |
extReso | Resolution to use in this search |
double simulator.SpatialGrid.getValueAround | ( | LocatedAgent | aLocAgent | ) |
Returns the average grid value seen in a sphere (or cube) located around a given agent.
Returns the average grid value seen in a sphere (or cube) located around a given agent
aLocAgent | The agent to use as the centre of the search |
double simulator.SpatialGrid.getValueAt | ( | ContinuousVector | cC | ) |
Return the value stored at the location given by the stated continuous vector.
Return the value stored at the location given by the stated continuous vector
cC | ContinuousVector containing the grid location to return |
double simulator.SpatialGrid.getValueAt | ( | DiscreteVector | dV | ) |
Return the value on the padded grid at a given position (the coordinates are NOT corrected)
Return the value on the padded grid at a given position (the coordinates are NOT corrected)
dV | DiscreteVector containing the location of the grid whos value should be returned |
double simulator.SpatialGrid.getValueAt | ( | int | i, |
int | j, | ||
int | k | ||
) |
Return the value on the padded grid at a given position (the coordinates are NOT corrected)
Return the value on the padded grid at a given position (the coordinates are NOT corrected)
i | I Coordinate of the grid location to set |
j | J Coordinate of the grid location to set |
k | K Coordinate of the grid location to set |
double simulator.SpatialGrid.getVoxelVolume | ( | ) |
Return the volume of one voxel of the spatial grid.
Return the volume of one voxel of the spatial grid
|
protected |
Creates the solute grid at the required size.
Creates the solute grid at the required size. If this is a chemostat, this will simple be a 1x1x1, if not there are further checks to determine whether we are simulating 3D or not
boolean simulator.SpatialGrid.is3D | ( | ) |
Determine if this spatial grid is 3D or 2D.
Determine if this spatial grid is 3D or 2D
boolean simulator.SpatialGrid.isValid | ( | DiscreteVector | dC | ) |
Determine if a given discrete position is valid or outside the grid (Padding excluded)
Determine if a given discrete position is valid or outside the grid (Padding excluded)
dC | DiscreteVector to validate |
boolean simulator.SpatialGrid.isValid | ( | ContinuousVector | cc | ) |
Determine if a given continuous location is valid or outside the grid.
Determine if a given continuous location is valid or outside the grid
cc | ContinuousVector to validate |
boolean simulator.SpatialGrid.isValidOrPadded | ( | DiscreteVector | dC | ) |
Determine if a given discrete position is valid or outside the grid (Padding included)
Determine if a given discrete position is valid or outside the grid
dC | DiscreteVector to validate |
boolean simulator.SpatialGrid.isValidorPadded | ( | int | i, |
int | j, | ||
int | k | ||
) |
Determine if a given voxel coordinate is valid or outside the grid.
Determine if a given voxel coordinate is valid or outside the grid
i | I Coordinate of the grid location |
j | J Coordinate of the grid location |
k | K Coordinate of the grid location |
boolean simulator.SpatialGrid.isValidOrPadded | ( | ContinuousVector | cc | ) |
Test if a location is valid or is outside the grid. Note padding is included as valid.
Test if a location is valid or is outside the grid. Note padding is included as valid
cc | ContinuousVector containing the location to be tested |
void simulator.SpatialGrid.setAllValueAt | ( | double | value | ) |
Set all meshes of a grid with the same value (including the padding - if not a chemostat run)
Set all meshes of a grid with the same value (including the padding if not a chemostat simulation)
value | Value at which to set all the elements of the grid |
void simulator.SpatialGrid.setGrid | ( | double | u[][][] | ) |
Set the values of this spatial grid to those contained in the supplied grid.
u | Matrix of values which to set the spatial grid to |
void simulator.SpatialGrid.setValueAt | ( | double | value, |
ContinuousVector | cC | ||
) |
Set a grid location, expressed as a ContinuousVector, to a specified value. The coordinates are corrected.
Set a grid location, expressed as a ContinuousVector, to a specified value. The coordinates are corrected
value | Value to set the specified location to |
cC | Continuous vector stating the location of the grid to be set to the given value |
void simulator.SpatialGrid.setValueAt | ( | double | value, |
DiscreteVector | dC | ||
) |
Set a grid location, expressed as a DiscreteVector, to a specified value. The coordinates are corrected.
Set a grid location, expressed as a DiscreteVector, to a specified value. The coordinates are corrected
value | Value to set the specified location to |
dC | Discrete vector stating the location of the grid to be set to the given value |
void simulator.SpatialGrid.setValueAt | ( | double | value, |
int | i, | ||
int | j, | ||
int | k | ||
) |
Set a grid location to a specified value. Note the coordinates are NOT corrected.
Set a grid location to a specified value. Note the coordinates are NOT corrected
value | Value to set the grid location to |
i | I Coordinate of the grid location to set |
j | J Coordinate of the grid location to set |
k | K Coordinate of the grid location to set |
void simulator.SpatialGrid.truncateValueAt | ( | int | i, |
int | j, | ||
int | k | ||
) |
Checks a value at a given location and sets it to zero if the value is negative.
Checks a value at a given location and sets it to zero if the value is negative
i | Voxel coordinate in I direction |
j | Voxel coordinate in J direction |
k | Voxel coordinate in K direction |
void simulator.SpatialGrid.writeReport | ( | ResultFile | bufferState, |
ResultFile | bufferSummary | ||
) | throws Exception |
Write the contents of this grid to the XML results files.
Write the contents of this grid to the XML results files. This shows the level of solute in each of the grid spaces
bufferState | The output buffer writing the env_state file for this iteration |
bufferSummary | The output buffer writing the env_sum file for this iteration |
Exception | Exception thrown if these buffers cannot be opened for writing to |
|
protected |
Boolean noting whether this grid is 3D (true) or 2D (false)
|
protected |
Number of grid voxels in I direction
|
protected |
Number of grid voxels in J direction
|
protected |
Number of grid voxels in K direction
|
protected |
Grid resolution = side length of a voxel
double [][][] simulator.SpatialGrid.grid |
The solute grid - a three dimesional array of double values
String simulator.SpatialGrid.gridName |
Name assigned to this spacial grid. Taken from an XML tag in the protocol file
String simulator.SpatialGrid.gridUnit = "g.L-1" |
The unit for all values stored on this grid