Package HAL.GridsAndAgents
Class PDEGrid2D
- java.lang.Object
-
- HAL.GridsAndAgents.PDEGrid2D
-
- All Implemented Interfaces:
Grid2D,java.io.Serializable
public class PDEGrid2D extends java.lang.Object implements Grid2D, java.io.Serializable
PDEGrid2D class facilitates 2D 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 prev values will be written to after updates, Update is called to set the prev field as the current field.- See Also:
- Serialized Form
-
-
Method Summary
Modifier and Type Method Description voidAdd(double x, double y, double val)voidAdd(int i, double val)adds to the prev field value at the specified indexvoidAdd(int x, int y, double val)sets the prev field value at the specified coordinatesvoidAddAll(double val)adds specified value to all entries of the delta fieldvoidAdvection(double[] xVels, double[] yVels)runs discontinuous advectionvoidAdvection(double[] xVels, double[] yVels, Coords2DDouble BoundaryyConditionFn, Coords2DDouble BoundaryXvels, Coords2DDouble BoundaryYvels)runs discontinuous advectionvoidAdvection(double xVel, double yVel)voidAdvection(double xVel, double yVel, double boundaryValue)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.voidAdvection(double xVel, double yVel, Coords2DDouble 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 valuevoidAdvection(Grid2Ddouble xVels, Grid2Ddouble yVels)runs discontinuous advectionvoidAdvection(Grid2Ddouble xVels, Grid2Ddouble yVels, Coords2DDouble BoundaryyConditionFn, Coords2DDouble BoundaryXvels, Coords2DDouble BoundaryYvels)runs discontinuous advectionvoidDiffusion(double diffCoef)runs diffusion on the current field, adding the deltas to the delta field.voidDiffusion(double[] diffRatesX, double[] diffRatesY)runs diffusion with discontinuous diffusion ratesvoidDiffusion(double[] diffRatesX, double[] diffRatesY, Coords2DDouble BoundaryConditionFn, Coords2DDouble BoundaryDiffusionRatesX, Coords2DDouble BoundaryDiffusionRatesY)runs diffusion with discontinuous diffusion ratesvoidDiffusion(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 aroundvoidDiffusion(double diffCoef, Coords2DDouble 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 valuevoidDiffusion(Grid2Ddouble diffRatesX, Grid2Ddouble diffRatesY)runs diffusion with discontinuous diffusion ratesvoidDiffusion(Grid2Ddouble diffRatesX, Grid2Ddouble diffRatesY, Coords2DDouble BoundaryConditionFn, Coords2DDouble BoundaryDiffusionRatesX, Coords2DDouble BoundaryDiffusionRatesY)runs diffusion with discontinuous diffusion ratesstatic voidDiffusion2DADIBetweenAction(double[] field, double[] scratch, double[] deltas, double diffRate, int xDim, int yDim, boolean wrapX, boolean wrapY, Coords2DDouble BC, TdmaSolver tdma, DoubleArrayToVoid BetweenAction)voidDiffusionADI(double diffCoef)voidDiffusionADI(double diffCoef, double boundaryCond)voidDiffusionADI(double diffCoef, double boundaryCond, DoubleArrayToVoid BetweenAction)doubleGet(double x, double y)doubleGet(int i)gets the prev field value at the specified indexdoubleGet(int x, int y)gets the prev field value at the specified coordinatesdoubleGetAvg()gets the average value of all squares in the current fielddouble[]GetDeltas()double[]GetField()doubleGetMax()returns the max value in the griddoubleGetMin()returns the min value in the griddoubleGradientX(double x, double y)doubleGradientX(double x, double y, double boundaryCond)doubleGradientX(int x, int y)returns the gradient of the diffusible in the X direction at the coordinates specifieddoubleGradientX(int x, int y, 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 boundarydoubleGradientY(double x, double y)doubleGradientY(double x, double y, double boundaryCond)doubleGradientY(int x, int y)returns the gradient of the diffusible in the Y direction at the coordinates specifieddoubleGradientY(int x, int y, 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 boundarybooleanIsWrapX()booleanIsWrapY()intLength()doubleMaxDelta()returns the maximum difference as stored on the delta field, call right before calling Update()doubleMaxDeltaScaled(double denomOffset)like MaxDelta only the differences are scaled relative to the value in the current field.voidMul(double x, double y, double val)voidMul(int i, double val)multiplies a value in the “current field” and adds the change to the “delta field”voidMul(int x, int y, double val)multiplies a value in the “current field” and adds the change to the “delta field”voidMulAll(double val)multiplies all values in the “current field” and puts the results into the “delta field”voidSet(double x, double y, double val)voidSet(int i, double val)sets the prev field value at the specified indexvoidSet(int x, int y, double val)sets the prev field value at the specified coordinatesvoidSetAll(double val)sets all squares in the delta field to the specified valuevoidSetAll(double[] vals)sets all squares in the delta field using the vals arrayvoidSetNonNegative()ensures that all values will be non-negative on the next timestep, call before UpdatevoidUpdate()adds the delta field into the current fieldintUpdateCt()intXdim()intYdim()-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface HAL.Interfaces.Grid2D
AlongLineIs, ApplyHood, ApplyHood, ApplyHoodMapped, ApplyRectangle, BoundaryIs, ContainsValidI, ContainsValidI, DispX, DispY, Dist, DistSquared, GetHoodI, I, I, In, In, InWrap, ItoX, ItoY, MapHood, MapHood, MapHood, MapHood, MapI, MapXpt, MapXsq, MapYpt, MapYsq, RandomHoodI, WrapI
-
-
-
-
Method Detail
-
UpdateCt
public int UpdateCt()
-
GetField
public double[] GetField()
-
GetDeltas
public double[] GetDeltas()
-
DiffusionADI
public void DiffusionADI(double diffCoef)
-
DiffusionADI
public void DiffusionADI(double diffCoef, double boundaryCond)
-
DiffusionADI
public void DiffusionADI(double diffCoef, double boundaryCond, DoubleArrayToVoid BetweenAction)
-
Diffusion2DADIBetweenAction
public static void Diffusion2DADIBetweenAction(double[] field, double[] scratch, double[] deltas, double diffRate, int xDim, int yDim, boolean wrapX, boolean wrapY, Coords2DDouble BC, TdmaSolver tdma, DoubleArrayToVoid BetweenAction)
-
Get
public double Get(int x, int y)gets the prev field value at the specified coordinates
-
Get
public double Get(double x, double y)
-
Get
public double Get(int i)
gets the prev field value at the specified index
-
Set
public void Set(int x, int y, double val)sets the prev field value at the specified coordinates
-
Set
public void Set(double x, double y, double val)
-
Set
public void Set(int i, double val)sets the prev field value at the specified index
-
Add
public void Add(int x, int y, double val)sets the prev field value at the specified coordinates
-
Add
public void Add(double x, double y, double val)
-
Add
public void Add(int i, double val)adds to the prev field value at the specified index
-
Mul
public void Mul(int x, int y, 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 val)
-
Mul
public void Mul(int i, double val)multiplies a value in the “current field” and adds the change to the “delta field”
-
GetMax
public double GetMax()
returns the max value in the grid
-
GetMin
public double GetMin()
returns the min value in the grid
-
Update
public void Update()
adds the delta field into the current field
-
Advection
public void Advection(double xVel, double yVel)
-
Advection
public void Advection(double xVel, double yVel, double boundaryValue)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, Coords2DDouble 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)runs discontinuous advection
-
Advection
public void Advection(Grid2Ddouble xVels, Grid2Ddouble yVels)
runs discontinuous advection
-
Advection
public void Advection(double[] xVels, double[] yVels, Coords2DDouble BoundaryyConditionFn, Coords2DDouble BoundaryXvels, Coords2DDouble BoundaryYvels)runs discontinuous advection
-
Advection
public void Advection(Grid2Ddouble xVels, Grid2Ddouble yVels, Coords2DDouble BoundaryyConditionFn, Coords2DDouble BoundaryXvels, Coords2DDouble BoundaryYvels)
runs discontinuous advection
-
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, Coords2DDouble 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)runs diffusion with discontinuous diffusion rates
-
Diffusion
public void Diffusion(Grid2Ddouble diffRatesX, Grid2Ddouble diffRatesY)
runs diffusion with discontinuous diffusion rates
-
Diffusion
public void Diffusion(double[] diffRatesX, double[] diffRatesY, Coords2DDouble BoundaryConditionFn, Coords2DDouble BoundaryDiffusionRatesX, Coords2DDouble BoundaryDiffusionRatesY)runs diffusion with discontinuous diffusion rates
-
Diffusion
public void Diffusion(Grid2Ddouble diffRatesX, Grid2Ddouble diffRatesY, Coords2DDouble BoundaryConditionFn, Coords2DDouble BoundaryDiffusionRatesX, Coords2DDouble BoundaryDiffusionRatesY)
runs diffusion with discontinuous diffusion rates
-
SetAll
public void SetAll(double val)
sets all squares in the delta field to the specified value
-
MulAll
public void MulAll(double val)
multiplies all values in the “current field” and puts the results into the “delta field”
-
SetAll
public void SetAll(double[] vals)
sets all squares in the delta field using the vals array
-
AddAll
public void AddAll(double val)
adds specified value to all entries of the delta field
-
GetAvg
public double GetAvg()
gets the average value of all squares in the current field
-
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
-
GradientX
public double GradientX(int x, int y)returns the gradient of the diffusible in the X direction at the coordinates specified
-
GradientX
public double GradientX(double x, double y)
-
GradientY
public double GradientY(int x, int y)returns the gradient of the diffusible in the Y direction at the coordinates specified
-
GradientY
public double GradientY(double x, double y)
-
GradientX
public double GradientX(int x, int y, 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 boundaryCond)
-
GradientY
public double GradientY(int x, int y, 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 boundaryCond)
-
SetNonNegative
public void SetNonNegative()
ensures that all values will be non-negative on the next timestep, call before Update
-
-