Class PDEGrid1D

  • All Implemented Interfaces:
    Grid1D, java.io.Serializable

    public class PDEGrid1D
    extends java.lang.Object
    implements Grid1D, java.io.Serializable
    a 1D
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int length  
      boolean wrapX  
      int xDim  
    • Constructor Summary

      Constructors 
      Constructor Description
      PDEGrid1D​(int xDim)  
      PDEGrid1D​(int xDim, boolean wrapX)  
    • Method Summary

      Modifier and Type Method Description
      void Add​(double x, double val)  
      void Add​(int x, double val)
      adds to the prev field value at the specified index
      void AddAll​(double val)
      adds specified value to all entries of the delta field
      void Advection​(double xVel)  
      void Advection​(double[] xVels)
      runs discontinuous advection
      void Advection​(double[] xVels, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryXvel)
      runs discontinuous advection
      void Advection​(double xVel, 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.
      void Advection​(double xVel, Coords1DDouble 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)
      runs discontinuous advection
      void Advection​(Grid2Ddouble xVels, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryXvel)
      runs discontinuous advection
      void Diffusion​(double diffCoef)
      runs diffusion on the current field, adding the deltas to the delta field.
      void Diffusion​(double[] diffRates)
      runs diffusion with discontinuous diffusion rates
      void Diffusion​(double[] diffRates, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryDiffusionRateFn)
      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, Coords1DDouble 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​(Grid1Ddouble diffRates)
      runs diffusion with discontinuous diffusion rates
      void Diffusion​(Grid1Ddouble diffRates, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryDiffusionRateFn)
      runs diffusion with discontinuous diffusion rates
      void DiffusionCrank​(double diffCoef)  
      void DiffusionCrank​(double diffCoef, Coords1DDouble BC)  
      double Get​(double x)  
      double Get​(int x)
      gets the prev field value at the specified coordinates
      double GetAvg()
      gets the average value of all squares in the current field
      double[] GetDeltas()  
      double[] GetField()  
      boolean IsWrapX()  
      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.
      void Mul​(double x, double val)  
      void Mul​(int x, 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 val)  
      void Set​(int x, double val)
      sets the prev field value at the specified coordinates
      void SetAll​(double val)
      sets all squares in the delta field to the specified value
      void SetAll​(double[] vals)
      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()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • xDim

        public final int xDim
      • length

        public final int length
      • wrapX

        public boolean wrapX
    • Constructor Detail

      • PDEGrid1D

        public PDEGrid1D​(int xDim)
      • PDEGrid1D

        public PDEGrid1D​(int xDim,
                         boolean wrapX)
    • Method Detail

      • GetField

        public double[] GetField()
      • GetDeltas

        public double[] GetDeltas()
      • Get

        public double Get​(int x)
        gets the prev field value at the specified coordinates
      • Get

        public double Get​(double x)
      • Set

        public void Set​(int x,
                        double val)
        sets the prev field value at the specified coordinates
      • Set

        public void Set​(double x,
                        double val)
      • Add

        public void Add​(int x,
                        double val)
        adds to the prev field value at the specified index
      • Add

        public void Add​(double x,
                        double val)
      • Mul

        public void Mul​(int x,
                        double val)
        multiplies a value in the “current field” and adds the change to the “delta field”
      • Mul

        public void Mul​(double x,
                        double val)
      • Update

        public void Update()
        adds the delta field into the current field, also increments the tick.
      • UpdateCt

        public int UpdateCt()
      • Advection

        public void Advection​(double xVel)
      • Advection

        public void Advection​(double xVel,
                              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,
                              Coords1DDouble 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)
        runs discontinuous advection
      • Advection

        public void Advection​(Grid2Ddouble xVels)
        runs discontinuous advection
      • Advection

        public void Advection​(double[] xVels,
                              Coords1DDouble BoundaryConditionFn,
                              Coords1DDouble BoundaryXvel)
        runs discontinuous advection
      • DiffusionCrank

        public void DiffusionCrank​(double diffCoef)
      • DiffusionCrank

        public void DiffusionCrank​(double diffCoef,
                                   Coords1DDouble BC)
      • 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.5, 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,
                              Coords1DDouble 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[] diffRates)
        runs diffusion with discontinuous diffusion rates
      • Diffusion

        public void Diffusion​(Grid1Ddouble diffRates)
        runs diffusion with discontinuous diffusion rates
      • Diffusion

        public void Diffusion​(double[] diffRates,
                              Coords1DDouble BoundaryConditionFn,
                              Coords1DDouble BoundaryDiffusionRateFn)
        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
      • SetNonNegative

        public void SetNonNegative()
        ensures that all values will be non-negative on the next timestep, call before Update
      • Xdim

        public int Xdim()
        Specified by:
        Xdim in interface Grid1D
      • Length

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

        public boolean IsWrapX()
        Specified by:
        IsWrapX in interface Grid1D