grid1 Derived Type

type, public :: grid1

1D grid class.


Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: name

variable name

character(len=:), public, allocatable :: scale

scale type

integer, public :: ncells

number of cells

real(kind=rk), public, allocatable :: edges(:)

vector(0:ncells) of cell edges

real(kind=rk), public, allocatable :: center(:)

vector(ncells) of cell centers,

real(kind=rk), public, allocatable :: width(:)

vector(ncells) of cell widths,

real(kind=rk), public, dimension(:), pointer :: left => null()

vector(ncells) of left cell boundaries,

real(kind=rk), public, dimension(:), pointer :: right => null()

vector(ncells) of right cell boundaries,


Type-Bound Procedures

procedure, public, pass(self) :: linear => grid1_linear

  • private pure subroutine grid1_linear(self, xmin, xmax, ncells, name)

    Initialize linear grid.
    Constant width:

         |  ...  |------(i)------|------(i+1)------|  ...  |
        xmin      <-  width(i) -> <- width(i+1)  ->       xmax
    

    Arguments

    Type IntentOptional Attributes Name
    class(grid1), intent(inout) :: self

    object

    real(kind=rk), intent(in) :: xmin

    lower boundary of grid domain

    real(kind=rk), intent(in) :: xmax

    upper boundary of grid domain

    integer, intent(in) :: ncells

    number of grid cells

    character(len=*), intent(in), optional :: name

    grid name (default="")

procedure, public, pass(self) :: bilinear => grid1_bilinear

  • private pure subroutine grid1_bilinear(self, xmin, xcross, xmax, ncells, name)

    Initialize bilinear grid. Equivalent to 2 linear grids in series.

         |  ...  |--|--|--| ... | ... |---|---|---|  ...  |
        xmin                  xcross                     xmax
    

    Arguments

    Type IntentOptional Attributes Name
    class(grid1), intent(inout) :: self

    object

    real(kind=rk), intent(in) :: xmin

    lower boundary of grid domain

    real(kind=rk), intent(in) :: xcross

    cross-over boundary of grid domain

    real(kind=rk), intent(in) :: xmax

    upper boundary of grid domain

    integer, intent(in) :: ncells(2)

    number of grid cells in range [xmin, xcross] and [xcross, xmax]

    character(len=*), intent(in), optional :: name

    grid name (default="")

procedure, public, pass(self) :: log => grid1_log

  • private pure subroutine grid1_log(self, xmin, xmax, ncells, name)

    Initialize logarithmic grid.
    Equivalent to a linear grid in terms of .

    Arguments

    Type IntentOptional Attributes Name
    class(grid1), intent(inout) :: self

    object

    real(kind=rk), intent(in) :: xmin

    lower boundary of grid domain (xmin>0)

    real(kind=rk), intent(in) :: xmax

    upper boundary of grid domain

    integer, intent(in) :: ncells

    number of grid cells

    character(len=*), intent(in), optional :: name

    grid name (default="")

procedure, public, pass(self) :: geometric => grid1_geometric

  • private subroutine grid1_geometric(self, xmin, xmax, ratio, ncells, name)

    Initialize geometric grid.
    Geometrically increasing/decreasing width:

         |  ...  |------(i)------|------(i+1)------|  ...  |
        xmin      <-  width(i) -> <- width(i+1)  ->       xmax
    

    Arguments

    Type IntentOptional Attributes Name
    class(grid1), intent(inout) :: self

    object

    real(kind=rk), intent(in) :: xmin

    lower boundary of grid domain

    real(kind=rk), intent(in) :: xmax

    upper boundary of grid domain

    real(kind=rk), intent(in) :: ratio

    constant ratio of geometric grid (R>0)

    integer, intent(in) :: ncells

    number of grid cells

    character(len=*), intent(in), optional :: name

    grid name (default="")

Source Code

   type :: grid1
    !! 1D grid class.
      character(:), allocatable :: name
        !! variable name
      character(:), allocatable :: scale
        !! scale type
      integer :: ncells
        !! number of cells
      real(rk), allocatable :: edges(:)
        !! vector(0:ncells) of cell edges
      real(rk), allocatable :: center(:)
        !! vector(ncells) of cell centers, \( x_i \)
      real(rk), allocatable :: width(:)
        !! vector(ncells) of cell widths,  \( x_{i+1/2} - x_{i-1/2} \)
      real(rk), dimension(:), pointer :: left => null()
        !! vector(ncells) of left cell boundaries, \( x_{i-1/2} \)
      real(rk), dimension(:), pointer :: right => null()
        !! vector(ncells) of right cell boundaries, \( x_{i+1/2} \)
   contains
      procedure, pass(self) :: linear => grid1_linear
      procedure, pass(self) :: bilinear => grid1_bilinear
      procedure, pass(self) :: log => grid1_log
      procedure, pass(self) :: geometric => grid1_geometric
      procedure, pass(self), private :: clear => grid1_clear
      procedure, pass(self), private :: compute => grid1_compute
   end type grid1