Class 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
    • Constructor Summary

      Constructors 
      Constructor Description
      PDEGrid3D​(int xDim, int yDim, int zDim)  
      PDEGrid3D​(int xDim, int yDim, int zDim, boolean wrapX, boolean wrapY, boolean wrapZ)  
    • 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 index
      void Add​(int x, int y, int z, double val)
      adds to the delta field value at the specified index
      void AddAll​(double val)
      adds specified value to all entries of the delta field
      void Advection​(double[] xVels, double[] yVels, double[] zVels)
      runs discontinuous advection
      void Advection​(double[] xVels, double[] yVels, double[] zVels, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryXvels, Coords3DDouble BondaryYvels, Coords3DDouble BoundaryZvels)
      runs discontinuous advection
      void 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 value
      void Advection​(Grid2Ddouble xVels, Grid2Ddouble yVels, Grid2Ddouble zVels)
      runs discontinuous advection
      void Advection​(Grid2Ddouble xVels, Grid2Ddouble yVels, Grid2Ddouble zVels, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryXvels, Coords3DDouble BondaryYvels, Coords3DDouble BoundaryZvels)
      runs discontinuous advection
      void BoundAllSwap​(double min, double max)
      Bounds all values in the delta field between min and max
      void 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 rates
      void Diffusion​(double[] diffRatesX, double[] diffRatesY, double[] diffRatesZ, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryDiffusionRatesX, Coords3DDouble BoundaryDiffusionRatesY, Coords3DDouble BoundaryDiffusionRatesZ)
      runs diffusion with discontinuous diffusion rates
      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
      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
      void Diffusion​(Grid3Ddouble diffRatesX, Grid3Ddouble diffRatesY, Grid3Ddouble diffRatesZ)
      runs diffusion with discontinuous diffusion rates
      void Diffusion​(Grid3Ddouble diffRatesX, Grid3Ddouble diffRatesY, Grid3Ddouble diffRatesZ, Coords3DDouble BoundaryConditionFn, Coords3DDouble BoundaryDiffusionRatesX, Coords3DDouble BoundaryDiffusionRatesY, Coords3DDouble BoundaryDiffusionRatesZ)
      runs diffusion with discontinuous diffusion rates
      void 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 index
      double Get​(int x, int y, int z)
      gets to the current field value at the specified coordinates
      double GetAvg()
      gets the average value of all squares in the current field
      double[] 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 specified
      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
      double 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 specified
      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
      double 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 specified
      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
      boolean 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 index
      void Set​(int x, int y, int z, double val)
      sets to the current field value at the specified coordinates
      void SetAll​(double val)
      sets all squares in the delta field using the vals array
      void SetNonNegative()
      ensures that all values will be non-negative on the next timestep, call before Update
      void 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
    • 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
    • Constructor Detail

      • PDEGrid3D

        public PDEGrid3D​(int xDim,
                         int yDim,
                         int zDim,
                         boolean wrapX,
                         boolean wrapY,
                         boolean wrapZ)
      • PDEGrid3D

        public PDEGrid3D​(int xDim,
                         int yDim,
                         int zDim)
    • 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​(double[] diffRatesX,
                              double[] diffRatesY,
                              double[] 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
      • 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)
      • Xdim

        public int Xdim()
        Specified by:
        Xdim in interface Grid3D
      • Ydim

        public int Ydim()
        Specified by:
        Ydim in interface Grid3D
      • Zdim

        public int Zdim()
        Specified by:
        Zdim in interface Grid3D
      • Length

        public int Length()
        Specified by:
        Length in interface Grid3D
      • IsWrapX

        public boolean IsWrapX()
        Specified by:
        IsWrapX in interface Grid3D
      • IsWrapY

        public boolean IsWrapY()
        Specified by:
        IsWrapY in interface Grid3D
      • IsWrapZ

        public boolean IsWrapZ()
        Specified by:
        IsWrapZ in interface Grid3D