Class IterativeCentralDifference

  • All Implemented Interfaces:
    PDESolver

    public class IterativeCentralDifference
    extends Object
    implements PDESolver
    An iterative central difference algorithm to obtain a numerical approximation to Poisson's equations with Dirichlet boundary conditions.

    It proceeds as follows: The area (0,0), (a,0), (0,b), (a,b) is divided into a grid of the specified size. The value at each interior point is initialized as the average of the boundary points. At each iteration, successive over-relaxation (SOR) (an extension of the Gauss-Seidel or Liebmann's method, which is a special case when α is 1) is used to compute improved estimates from the three-point central difference approximation to Poisson's equation: \[ \frac{u_{k+1,j} - 2u_{k,j} + u_{k-1,j}}{\Delta x^2} + \frac{u_{k,j+1} - 2u_{k,j} + u_{k,j-1}}{\Delta y^2} = f_{k, j} \] where \(u_{k,j} = u(x_k, y_j)\) is the estimate at \((k, j)\) in the grid.

    This is a second-order method with a truncation error of order \(O(\Delta x^2 + \Delta y^2)\).

    See Also:
    Wikipedia: Gauss-Seidel SOR
    • Constructor Detail

      • IterativeCentralDifference

        public IterativeCentralDifference​(double errorBound,
                                          int maxIterations)
        Create an instance of this method with the given error bound as the convergence criterion, and the maximum number of iterations allowed. The iteration stops when the difference between successive iterations is within the given error bound.
        Parameters:
        errorBound - the error bound (convergence criterion)
        maxIterations - the maximum number of iterations allowed
    • Method Detail

      • solve

        public PDESolutionGrid2D solve​(PoissonEquation2D pde,
                                       int m,
                                       int n)
        Solve a Poisson's equation problem, with the given grid resolution parameters.

        UnsatisfiableErrorCriterionException is thrown when the iteration cannot converge to the specified error bound within the maximum allowed number of iterations.

        Parameters:
        pde - the Poisson's equation
        m - the number of points along the x-axis of the grid
        n - the number of points along the y-axis of the grid
        Returns:
        the solution grid