Package HAL.GridsAndAgents
Class PDEGrid3D
- java.lang.Object
-
- HAL.GridsAndAgents.PDEGrid3D
-
- All Implemented Interfaces:
Grid3D
,java.io.Serializable
public class PDEGrid3D extends java.lang.Object implements Grid3D, java.io.Serializable
PDEGrid3D class facilitates 3D diffusion with two arrays of doubles called fields the intended usage is that during a diffusion tick, the current values will be read, and the next values will be written to after updates, Update is called to set the delta field as the current field.- See Also:
- Serialized Form
-
-
Method Summary
Modifier and Type Method Description void
Add(double x, double y, double z, double val)
void
Add(int i, double val)
adds to the delta field value at the specified indexvoid
Add(int x, int y, int z, double val)
adds to the delta field value at the specified indexvoid
AddAll(double val)
adds specified value to all entries of the delta fieldvoid
Advection(double[] xVels, double[] yVels, double[] zVels)
runs discontinuous advectionvoid
Advection(double[] xVels, double[] yVels, double[] zVels, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryXvels, Coords3DDouble BondaryYvels, Coords3DDouble BoundaryZvels)
runs discontinuous advectionvoid
Advection(double xVel, double yVel, double zVel)
void
Advection(double xVel, double yVel, double zVel, double boundaryVal)
runs advection as described above with a boundary value, meaning that the boundary value will advect in from the upwind direction, and the concentration will disappear in the downwind direction.void
Advection(double xVel, double yVel, double zVel, Coords3DDouble BoundaryConditionFn)
runs advection as described above with a boundary condition function, which will be evaluated with the out of bounds coordinates as arguments whenever a boundary value is needed, and should return the boundary valuevoid
Advection(Grid2Ddouble xVels, Grid2Ddouble yVels, Grid2Ddouble zVels)
runs discontinuous advectionvoid
Advection(Grid2Ddouble xVels, Grid2Ddouble yVels, Grid2Ddouble zVels, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryXvels, Coords3DDouble BondaryYvels, Coords3DDouble BoundaryZvels)
runs discontinuous advectionvoid
BoundAllSwap(double min, double max)
Bounds all values in the delta field between min and maxvoid
Diffusion(double diffCoef)
/** runs diffusion on the current field, adding the deltas to the delta field.void
Diffusion(double[] diffRatesX, double[] diffRatesY, double[] diffRatesZ)
runs diffusion with discontinuous diffusion ratesvoid
Diffusion(double[] diffRatesX, double[] diffRatesY, double[] diffRatesZ, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryDiffusionRatesX, Coords3DDouble BoundaryDiffusionRatesY, Coords3DDouble BoundaryDiffusionRatesZ)
runs diffusion with discontinuous diffusion ratesvoid
Diffusion(double diffCoef, double boundaryValue)
has the same effect as the above diffusion function without the boundary value argument, except rather than assuming zero flux, the boundary condition is set to either the boundaryValue, or wrap aroundvoid
Diffusion(double diffCoef, Coords3DDouble BoundaryConditionFn)
has the same effect as the above diffusion function with a boundary condition function, which will be evaluated with the out of bounds coordinates as arguments whenever a boundary value is needed, and should return the boundary valuevoid
Diffusion(Grid3Ddouble diffRatesX, Grid3Ddouble diffRatesY, Grid3Ddouble diffRatesZ)
runs diffusion with discontinuous diffusion ratesvoid
Diffusion(Grid3Ddouble diffRatesX, Grid3Ddouble diffRatesY, Grid3Ddouble diffRatesZ, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryDiffusionRatesX, Coords3DDouble BoundaryDiffusionRatesY, Coords3DDouble BoundaryDiffusionRatesZ)
runs diffusion with discontinuous diffusion ratesvoid
DiffusionADI(double diffRate)
void
DiffusionADI(double diffRate, double boundaryValue)
double
Get(double x, double y, double z)
double
Get(int i)
gets the delta field value at the specified indexdouble
Get(int x, int y, int z)
gets to the current field value at the specified coordinatesdouble
GetAvg()
gets the average value of all squares in the current fielddouble[]
GetDeltas()
double[]
GetField()
double
GradientX(double x, double y, double z)
double
GradientX(double x, double y, double z, double boundaryCond)
double
GradientX(int x, int y, int z)
returns the gradient of the diffusible in the X direction at the coordinates specifieddouble
GradientX(int x, int y, int z, double boundaryCond)
returns the gradient of the diffusible in the X direction at the coordinates specified, will use the boundary condition value if computing the gradient next to the boundarydouble
GradientY(double x, double y, double z)
double
GradientY(double x, double y, double z, double boundaryCond)
double
GradientY(int x, int y, int z)
returns the gradient of the diffusible in the Y direction at the coordinates specifieddouble
GradientY(int x, int y, int z, double boundaryCond)
returns the gradient of the diffusible in the Y direction at the coordinates specified, will use the boundary condition value if computing the gradient next to the boundarydouble
GradientZ(double x, double y, double z)
double
GradientZ(double x, double y, double z, double boundaryCond)
double
GradientZ(int x, int y, int z)
returns the gradient of the diffusible in the Z direction at the coordinates specifieddouble
GradientZ(int x, int y, int z, double boundaryCond)
returns the gradient of the diffusible in the Z direction at the coordinates specified, will use the boundary condition value if computing the gradient next to the boundaryboolean
IsWrapX()
boolean
IsWrapY()
boolean
IsWrapZ()
int
Length()
double
MaxDelta()
returns the maximum difference as stored on the delta field, call right before calling Update()double
MaxDeltaScaled(double denomOffset)
like MaxDelta only the differences are scaled relative to the value in the current field.double
MaxDifInternal()
returns the maximum difference between the field passed in and the current field.void
Mul(double x, double y, double z, double val)
void
Mul(int i, double val)
multiplies a value in the “current field” and adds the change to the “delta field”void
Mul(int x, int y, int z, double val)
multiplies a value in the “current field” and adds the change to the “delta field”void
MulAll(double val)
multiplies all values in the “current field” and puts the results into the “delta field”void
Set(double x, double y, double z, double val)
void
Set(int i, double val)
sets the current field value at the specified indexvoid
Set(int x, int y, int z, double val)
sets to the current field value at the specified coordinatesvoid
SetAll(double val)
sets all squares in the delta field using the vals arrayvoid
SetNonNegative()
ensures that all values will be non-negative on the next timestep, call before Updatevoid
Update()
adds the delta field into the current field, also increments the tick.int
UpdateCt()
int
Xdim()
int
Ydim()
int
Zdim()
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface HAL.Interfaces.Grid3D
ApplyHood, ApplyHood, ApplyHoodMapped, ApplyRectangle, BoundaryIs, ContainsValidI, ContainsValidI, ConvI, ConvXpt, ConvXsq, ConvYpt, ConvYsq, ConvZpt, ConvZsq, DispX, DispY, DispZ, Dist, DistSquared, GetHoodI, I, I, In, In, InWrap, InWrap, ItoX, ItoY, ItoZ, MapHood, MapHood, MapHood, MapHood, RandomHoodI, WrapI
-
-
-
-
Field Detail
-
xDim
public final int xDim
-
yDim
public final int yDim
-
zDim
public final int zDim
-
length
public final int length
-
wrapX
public boolean wrapX
-
wrapY
public boolean wrapY
-
wrapZ
public boolean wrapZ
-
field
public double[] field
-
deltas
public double[] deltas
-
scratch
public double[] scratch
-
scratch2
public double[] scratch2
-
maxDifscratch
public double[] maxDifscratch
-
-
Method Detail
-
GetField
public double[] GetField()
-
GetDeltas
public double[] GetDeltas()
-
Get
public double Get(int x, int y, int z)
gets to the current field value at the specified coordinates
-
Get
public double Get(double x, double y, double z)
-
Get
public double Get(int i)
gets the delta field value at the specified index
-
Set
public void Set(int x, int y, int z, double val)
sets to the current field value at the specified coordinates
-
Set
public void Set(double x, double y, double z, double val)
-
Set
public void Set(int i, double val)
sets the current field value at the specified index
-
Add
public void Add(int x, int y, int z, double val)
adds to the delta field value at the specified index
-
Add
public void Add(double x, double y, double z, double val)
-
Add
public void Add(int i, double val)
adds to the delta field value at the specified index
-
Mul
public void Mul(int i, double val)
multiplies a value in the “current field” and adds the change to the “delta field”
-
Mul
public void Mul(int x, int y, int z, double val)
multiplies a value in the “current field” and adds the change to the “delta field”
-
Mul
public void Mul(double x, double y, double z, double val)
-
Update
public void Update()
adds the delta field into the current field, also increments the tick.
-
UpdateCt
public int UpdateCt()
-
BoundAllSwap
public void BoundAllSwap(double min, double max)
Bounds all values in the delta field between min and max
-
Diffusion
public void Diffusion(double diffCoef)
/** runs diffusion on the current field, adding the deltas to the delta field. This form of the function assumes either a reflective or wrapping boundary (depending on how the PDEGrid was specified). the diffCoef variable is the nondimensionalized diffusion conefficient. If the dimensionalized diffusion coefficient is x then diffCoef can be found by computing (x*SpaceStep)/TimeStep^2 Note that if the diffCoef exceeds 0.25, this diffusion method will become numerically unstable.
-
Diffusion
public void Diffusion(double diffCoef, double boundaryValue)
has the same effect as the above diffusion function without the boundary value argument, except rather than assuming zero flux, the boundary condition is set to either the boundaryValue, or wrap around
-
Diffusion
public void Diffusion(double diffCoef, Coords3DDouble BoundaryConditionFn)
has the same effect as the above diffusion function with a boundary condition function, which will be evaluated with the out of bounds coordinates as arguments whenever a boundary value is needed, and should return the boundary value
-
Diffusion
public void Diffusion(double[] diffRatesX, double[] diffRatesY, double[] diffRatesZ)
runs diffusion with discontinuous diffusion rates
-
Diffusion
public void Diffusion(Grid3Ddouble diffRatesX, Grid3Ddouble diffRatesY, Grid3Ddouble diffRatesZ)
runs diffusion with discontinuous diffusion rates
-
Diffusion
public void Diffusion(double[] diffRatesX, double[] diffRatesY, double[] diffRatesZ, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryDiffusionRatesX, Coords3DDouble BoundaryDiffusionRatesY, Coords3DDouble BoundaryDiffusionRatesZ)
runs diffusion with discontinuous diffusion rates
-
Diffusion
public void Diffusion(Grid3Ddouble diffRatesX, Grid3Ddouble diffRatesY, Grid3Ddouble diffRatesZ, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryDiffusionRatesX, Coords3DDouble BoundaryDiffusionRatesY, Coords3DDouble BoundaryDiffusionRatesZ)
runs diffusion with discontinuous diffusion rates
-
MaxDelta
public double MaxDelta()
returns the maximum difference as stored on the delta field, call right before calling Update()
-
MaxDeltaScaled
public double MaxDeltaScaled(double denomOffset)
like MaxDelta only the differences are scaled relative to the value in the current field. the denomOffset is used to prevent a division by zero
-
Advection
public void Advection(double xVel, double yVel, double zVel)
-
Advection
public void Advection(double xVel, double yVel, double zVel, double boundaryVal)
runs advection as described above with a boundary value, meaning that the boundary value will advect in from the upwind direction, and the concentration will disappear in the downwind direction.
-
Advection
public void Advection(double xVel, double yVel, double zVel, Coords3DDouble BoundaryConditionFn)
runs advection as described above with a boundary condition function, which will be evaluated with the out of bounds coordinates as arguments whenever a boundary value is needed, and should return the boundary value
-
Advection
public void Advection(double[] xVels, double[] yVels, double[] zVels)
runs discontinuous advection
-
Advection
public void Advection(Grid2Ddouble xVels, Grid2Ddouble yVels, Grid2Ddouble zVels)
runs discontinuous advection
-
Advection
public void Advection(double[] xVels, double[] yVels, double[] zVels, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryXvels, Coords3DDouble BondaryYvels, Coords3DDouble BoundaryZvels)
runs discontinuous advection
-
Advection
public void Advection(Grid2Ddouble xVels, Grid2Ddouble yVels, Grid2Ddouble zVels, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryXvels, Coords3DDouble BondaryYvels, Coords3DDouble BoundaryZvels)
runs discontinuous advection
-
MaxDifInternal
public double MaxDifInternal()
returns the maximum difference between the field passed in and the current field. call right after Update()
-
DiffusionADI
public void DiffusionADI(double diffRate)
-
DiffusionADI
public void DiffusionADI(double diffRate, double boundaryValue)
-
SetAll
public void SetAll(double val)
sets all squares in the delta field using the vals array
-
SetNonNegative
public void SetNonNegative()
ensures that all values will be non-negative on the next timestep, call before Update
-
GetAvg
public double GetAvg()
gets the average value of all squares in the current field
-
AddAll
public void AddAll(double val)
adds specified value to all entries of the delta field
-
MulAll
public void MulAll(double val)
multiplies all values in the “current field” and puts the results into the “delta field”
-
GradientX
public double GradientX(int x, int y, int z)
returns the gradient of the diffusible in the X direction at the coordinates specified
-
GradientX
public double GradientX(double x, double y, double z)
-
GradientY
public double GradientY(int x, int y, int z)
returns the gradient of the diffusible in the Y direction at the coordinates specified
-
GradientY
public double GradientY(double x, double y, double z)
-
GradientZ
public double GradientZ(int x, int y, int z)
returns the gradient of the diffusible in the Z direction at the coordinates specified
-
GradientZ
public double GradientZ(double x, double y, double z)
-
GradientX
public double GradientX(int x, int y, int z, double boundaryCond)
returns the gradient of the diffusible in the X direction at the coordinates specified, will use the boundary condition value if computing the gradient next to the boundary
-
GradientX
public double GradientX(double x, double y, double z, double boundaryCond)
-
GradientY
public double GradientY(int x, int y, int z, double boundaryCond)
returns the gradient of the diffusible in the Y direction at the coordinates specified, will use the boundary condition value if computing the gradient next to the boundary
-
GradientY
public double GradientY(double x, double y, double z, double boundaryCond)
-
GradientZ
public double GradientZ(int x, int y, int z, double boundaryCond)
returns the gradient of the diffusible in the Z direction at the coordinates specified, will use the boundary condition value if computing the gradient next to the boundary
-
GradientZ
public double GradientZ(double x, double y, double z, double boundaryCond)
-
-