mesh_cart_m Module

Module implementing the 2d mesh



Interfaces

interface

  • public pure module function get_phi(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value real(kind=fp)

interface

  • public pure module function get_lvl(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value integer

interface

  • public pure module function get_lvst(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value integer

interface

  • public pure module function get_n_points(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value integer

interface

  • public pure module function get_spacing_f(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value real(kind=fp)

interface

  • public pure module function get_spacing_c(self)

    Returns mesh distance of level, spacing_c = spacing_f*lvst

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value real(kind=fp)

interface

  • public pure module function get_size_neighbor(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value integer

interface

  • public pure module function get_cart_i(self, ind)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: ind

    Mesh index

    Return Value integer

interface

  • public pure module function get_cart_j(self, ind)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: ind

    Mesh index

    Return Value integer

interface

  • public pure module function get_x(self, ind)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: ind

    Mesh index

    Return Value real(kind=fp)

interface

  • public pure module function get_y(self, ind)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: ind

    Mesh index

    Return Value real(kind=fp)

interface

  • public pure module function get_n_points_inner(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value integer

interface

  • public pure module function get_n_points_boundary(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value integer

interface

  • public pure module function get_n_points_ghost(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value integer

interface

  • public pure module function get_xmin(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value real(kind=fp)

interface

  • public pure module function get_ymin(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value real(kind=fp)

interface

  • public pure module function get_n_points_red(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value integer

interface

  • public pure module function get_n_points_black(self)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    Return Value integer

interface

  • public pure module function get_index_neighbor(self, ishift, jshift, ind)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: ishift

    Shift in horizontal direction w.r.t. point ind

    integer, intent(in) :: jshift

    Shift in vertical direction w.r.t. point ind

    integer, intent(in) :: ind

    Mesh index

    Return Value integer

interface

  • public module function cart_to_mesh_index(self, i, j)

    Given Cartesian indizes (i,j) returns mesh index if no point could be found 0 is returned

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: i

    Horizontal Cartesian index

    integer, intent(in) :: j

    Vertical Cartesian index

    Return Value integer

interface

  • public pure module function is_inner_point(self, ind)

    Indicates if point is inner grid point

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: ind

    Mesh index

    Return Value logical

interface

  • public pure module function is_boundary_point(self, ind)

    Indicates if point is boundary point

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: ind

    Mesh index

    Return Value logical

interface

  • public pure module function is_ghost_point(self, ind)

    Indicates if point is ghost point

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: ind

    Mesh index

    Return Value logical

interface

  • public pure module function get_district(self, ind)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: ind

    Mesh index

    Return Value integer

interface

  • public module function point_inside(self, district)

    Definition which district (point location in logical sense) is inside the mesh

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: district

    District descriptor

    Return Value logical

interface

  • public module subroutine set_phi(self, new_phi)

    Sets phi value of mesh to a new value

    Arguments

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

    Instance of the type

    real(kind=FP), intent(in) :: new_phi

    New phi value

interface

  • public module subroutine build_shaped_cart_arrays(self)

    Builds a 2D array where shaped_cart_l(i,j) = l gives the index where cart_i(l) == i and cart_j(l) == j, or zero if no point is found. Used to accelerate cart_to_mesh_index

    Arguments

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

interface

  • public module subroutine deallocate_shaped_cart_arrays(self)

    Deallocates the shaped_cart_l array to reduce the memory requirement for the grid

    Arguments

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

interface

  • public module subroutine determine_interpolation_stencil(self, xp, yp, intorder, ns_max_nearest, ns_stencil, intorder_actual, ind_interpol_stencil)

    Finds ns_stencil x ns_stencil indices of interpolation stencil around (xp, yp), if possible of order intorder

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    real(kind=FP), intent(in) :: xp

    x-coordinate of point

    real(kind=FP), intent(in) :: yp

    y-coordinate of point

    integer, intent(in) :: intorder

    Requested stencil order

    integer, intent(in) :: ns_max_nearest

    Size of area that is searched for nearest point

    integer, intent(out) :: ns_stencil

    Size of determined stencil

    integer, intent(out) :: intorder_actual

    Order of determined stencil

    integer, intent(out), allocatable, dimension(:,:) :: ind_interpol_stencil

    Indices of determined stencil

interface

  • public module subroutine get_surrounding_indices(self, xp, yp, ns, ind_sur, ns_complete, ind_nearest)

    Finds ns x ns indices of points surrounding (xp, yp)

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    real(kind=FP), intent(in) :: xp

    x-coordinate of point

    real(kind=FP), intent(in) :: yp

    y-coordinate of point

    integer, intent(in) :: ns

    Dimension of surrounding local grid

    integer, intent(out), optional, dimension(ns, ns) :: ind_sur

    Indices of surrounding grid points

    integer, intent(out), optional :: ns_complete

    Dimension of surrounding local grid, that is complete (w/o missing points)

    integer, intent(out), optional :: ind_nearest

    Index of nearest point on surrounding grid

interface

  • public module subroutine normal_to_boundary(self, ind, nbx, nby)

    Returns the discrete normal vector to the boundary

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: ind

    Mesh index, must be index of a boundary point

    integer, intent(out) :: nbx

    x-component of discrete normal vector

    integer, intent(out) :: nby

    y-component of discrete normal vector

interface

  • public module subroutine display_mesh_cart(self)

    Displays information for mesh

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

interface

  • public module subroutine write_netcdf_mesh_cart(self, fgid)

    Writes the mesh to netcdf

    Arguments

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

    Instance of the type

    integer, intent(in) :: fgid

    File or group id number of existing Netcdf4 file

interface

  • public module subroutine read_netcdf_mesh_cart(self, fgid)

    Reads mesh from netcdf

    Arguments

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

    Instance of the type

    integer, intent(in) :: fgid

    File or group id number of existing Netcdf4 file

interface

  • public module subroutine init_mesh_cart(self, equi, phi, lvl, spacing_f, size_neighbor, size_ghost_layer, extend_beyond_wall, dbgout)

    Builds complete mesh

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(out) :: self

    Instance of the type

    class(equilibrium_t), intent(inout) :: equi

    Equilibrium

    real(kind=FP), intent(in) :: phi

    Toroidal angle

    integer, intent(in) :: lvl

    Coarseness level

    real(kind=FP), intent(inout) :: spacing_f

    Grid spacing on finest level

    integer, intent(in) :: size_neighbor

    Number of neighbor points determined in each direction

    integer, intent(in) :: size_ghost_layer

    Depth of ghost point layer

    logical, intent(in) :: extend_beyond_wall

    If true, mesh is extended beyond the wall

    integer, intent(in), optional :: dbgout

    Debug output level

interface

  • public module subroutine build_cart(self, equi, lvl, spacing_f)

    Builds Cartesian grid

    Arguments

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

    Instance of the type

    class(equilibrium_t), intent(inout) :: equi

    Equilibrium

    integer, intent(in) :: lvl

    Coarseness level

    real(kind=FP), intent(in) :: spacing_f

    Grid spacing on finest level

interface

  • public module subroutine build_connectivity(self, size_neighbor)

    Establishes connectivity among grid points

    Arguments

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

    Instance of the type

    integer, intent(in) :: size_neighbor

    Number of neighbor points in each direction (left, right, bottom, top)

interface

  • public module subroutine build_boundary(self)

    Builds discrete boundary, i.e. finds point that are located on boundary

    Arguments

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

    Instance of the type

interface

  • public module subroutine build_ghost_layer(self, size_ghost_layer)

    Builds ghost layer surrounding inner grid

    Arguments

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

    Instance of the type

    integer, intent(in) :: size_ghost_layer

    Depth of ghost layer

interface

  • public module subroutine build_pinfo(self)

    Build information for individual mesh points

    Arguments

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

    Instance of the type

interface

  • public module subroutine build_district(self, equi)

    Build district (logical location) for individual mesh points

    Arguments

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

    Instance of the type

    class(equilibrium_t), intent(in) :: equi

    Equilibrium

interface

  • public module subroutine build_patch(self)

    Applies patch to mesh boundary points without connection to inner points are moved the ghost points

    Arguments

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

    Instance of the type

interface

  • public module subroutine build_redblack(self)

    Builds index list identifying red and black points (chequerboard) of mesh

    Arguments

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

    Instance of the type

interface

  • public module subroutine build_cart_slab(self, equi, lvl, npwr)

    Builds Cartesian grid for slab geometry

    Arguments

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

    Instance of the type

    class(equilibrium_t), intent(inout) :: equi

    Equilibrium

    integer, intent(in) :: lvl

    Coarseness level

    integer, intent(in) :: npwr

    Power exponent for number of grid points in x direction nxf = 2^npwr+1

interface

  • public module subroutine reorder(self, grid_reorder_block, dbgout)

    Reorders mesh indices for cache optimisation

    Arguments

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

    Instance of the type

    integer, intent(in) :: grid_reorder_block

    Size of basic unshuffled grid square

    integer, intent(in), optional :: dbgout

    Debug output level

interface

  • public module subroutine exchange_mesh_mpi(self, comm, step, mesh_received)

    MPI communication of mesh Sends mesh to rank-step and receives from rank+step

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in) :: self

    Instance of the type

    integer, intent(in) :: comm

    MPI communicator

    integer, intent(in) :: step

    Step size of MPI communication

    type(mesh_cart_t), intent(out) :: mesh_received

    Mesh received from rank+step

interface

  • public module subroutine expose_data(self, data_object)

    Exposes mesh data through mesh_cart_data_t object

    Arguments

    Type IntentOptional Attributes Name
    class(mesh_cart_t), intent(in), target :: self

    Instance of the type

    type(mesh_cart_data_t), intent(out) :: data_object

    Destination mesh cart data object. Warning: the purpose of this method is to allow access to the data of the instance.


Derived Types

type, public, bind(C) ::  mesh_cart_data_t

Data type used to expose mesh_cart_t data to C/C++ Please see mesh_cart_t for descriptions of individual properties/members. Values are copied directly. Arrays are exposed with pointers.

Components

Type Visibility Attributes Name Initial
logical(kind=c_bool), public :: extend_beyond_wall
integer(kind=c_int32_t), public :: lvl
integer(kind=c_int32_t), public :: lvst
real(kind=FP), public :: spacing_f
real(kind=FP), public :: spacing_c
integer(kind=c_int32_t), public :: n_points
real(kind=FP), public :: phi
real(kind=FP), public :: xmin
real(kind=FP), public :: ymin
integer(kind=c_int32_t), public :: nx_f
integer(kind=c_int32_t), public :: ny_f
type(c_ptr), public :: cart_i
type(c_ptr), public :: cart_j
integer(kind=c_int32_t), public :: size_neighbor
type(c_ptr), public :: index_neighbor
integer(kind=c_int32_t), public :: size_ghost_layer
integer(kind=c_int32_t), public :: n_points_inner
type(c_ptr), public :: inner_indices
integer(kind=c_int32_t), public :: n_points_boundary
type(c_ptr), public :: boundary_indices
integer(kind=c_int32_t), public :: n_points_ghost
type(c_ptr), public :: ghost_indices
type(c_ptr), public :: pinfo
type(c_ptr), public :: district
integer(kind=c_int32_t), public :: n_points_red
integer(kind=c_int32_t), public :: n_points_black
type(c_ptr), public :: redblack_indices

type, public ::  mesh_cart_t

Datatype for a mesh_2d

Components

Type Visibility Attributes Name Initial
real(kind=FP), public :: spacing_c

Grid spacing on the actual level (coarse) NOTE: This variable is set public only temporarily and must not be changed from outside of this module. In normal circumstances use the routine get_spacing_c. (It needs to be accessed directly in helmholtz_operators, to circumvent the known issue of OMP scaling with intel compiler)

integer, public :: n_points

Number of total mesh points NOTE: This variable is set public only temporarily and must not be changed from outside of this module. In normal circumstances use the routine get_n_points. (It needs to be accessed directly in helmholtz_operators, to circumvent the known issue of OMP scaling with intel compiler)

integer, public, allocatable, dimension(:,:,:) :: index_neighbor

Index of neighbor points

integer, public, allocatable, dimension(:) :: inner_indices

Indices of inner points

integer, public, allocatable, dimension(:) :: boundary_indices

Indices of boundary points

integer, public, allocatable, dimension(:) :: ghost_indices

Indices of ghost points

integer, public, allocatable, dimension(:) :: redblack_indices

Index list of redblack points, eventually needed for red-black gauss seidel smoother First nred entries are indices of red points Following nblack entries are indices of black points Final nboundary+nghost entries are indices of boundary and ghost points

Type-Bound Procedures

procedure, public :: get_phi
procedure, public :: set_phi
procedure, public :: get_lvl
procedure, public :: get_lvst
procedure, public :: get_n_points
procedure, public :: get_spacing_f
procedure, public :: get_spacing_c
procedure, public :: get_size_neighbor
procedure, public :: get_cart_i
procedure, public :: get_cart_j
procedure, public :: get_x
procedure, public :: get_y
procedure, public :: get_n_points_inner
procedure, public :: get_n_points_boundary
procedure, public :: get_n_points_ghost
procedure, public :: get_xmin
procedure, public :: get_ymin
procedure, public :: get_n_points_red
procedure, public :: get_n_points_black
procedure, public :: is_inner_point
procedure, public :: is_boundary_point
procedure, public :: is_ghost_point
procedure, public :: get_district
procedure, public :: cart_to_mesh_index
procedure, public :: build_shaped_cart_arrays
procedure, public :: deallocate_shaped_cart_arrays
procedure, public :: get_index_neighbor
procedure, public :: determine_interpolation_stencil
procedure, public :: get_surrounding_indices
procedure, public :: normal_to_boundary
procedure, public :: display => display_mesh_cart
procedure, public :: write_netcdf => write_netcdf_mesh_cart
procedure, public :: read_netcdf => read_netcdf_mesh_cart
procedure, public :: init => init_mesh_cart
procedure, public :: reorder
procedure, public :: exchange_mesh_mpi
procedure, public :: expose_data