Poisson2D Derived Type

type, public :: Poisson2D

Base type used to define a Poisson2D matrix on a rectangular domain discretized with nx and ny points in each direction and corresponding grid spacings dx and dy.


Constructor

public interface Poisson2D

Constructor for generating a Poisson2D matrix. The matrix corresponds to the standard second-order accurate finite-difference approximation of the Laplace operator with homogeneous Dirichlet boundary conditions.

Syntax

  • Construct the finite-difference approximation of the Laplace operator on the rectangular domain using 128 points in the horizontal direction and 256 in the vertical one.
   type(Poisson2D)     :: A
   integer, parameter  :: nx = 128, ny = 256
   real(dp), parameter :: Lx = 1.0_dp, Ly = 2.0_dp

   A = Poisson2D(nx, ny, Lx, Ly)

Note

Only doube precision is currently supported for this matrix type.

Note

Note that Lx and Ly are optional. If not specified, they default to 1.0_dp.

  • private pure module function initialize(nx, ny, Lx, Ly) result(A)

    Utility function to construct a Poisson2D matrix.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=ilp), intent(in) :: nx

    Number of grid points in each direction.

    integer(kind=ilp), intent(in) :: ny

    Number of grid points in each direction.

    real(kind=dp), intent(in), optional :: Lx

    Physical extent of each dimension.

    real(kind=dp), intent(in), optional :: Ly

    Physical extent of each dimension.

    Return Value type(Poisson2D)

    Corresponding Poisson2D matrix.


Source Code

   type :: Poisson2D
      !! Base type used to define a `Poisson2D` matrix on a rectangular domain
      !! discretized with `nx` and `ny` points in each direction and
      !! corresponding grid spacings `dx` and `dy`.
      private
      integer(ilp) :: nx, ny
      !! Dimension of the grid in each direction.
      real(dp) :: dx, dy
      !! Grid spacing in each direction.
   end type Poisson2D