Module morton_mod


Uses:
    module kinds_mod
Subroutines and functions:
    public subroutine morton2d_c2i (lev, p, idx)
    public subroutine morton2d_i2c (lev, idx, p)
    public subroutine morton_c2i (lev, p, idx)

Simple 3D and 2D Morton curve subroutines.

Uses simple bit-interleaving algorithm as described in M.J. Aftosmis, M.J. Berger and S.M. Murman, "Applications of Space-Filling Curves to Cartesian Methods for CFD", 2004

Routines accept position and morton-index starting at 1!

Author: Matthias Lieber


Description of Subroutines and Functions

morton2d_c2i

public subroutine morton2d_c2i (lev, p, idx)
    integer (kind=i_k), intent(in) :: lev
    integer (kind=i_k), intent(in), dimension (2) :: p
    integer (kind=i_k), intent(out) :: idx
end subroutine morton2d_c2i
Parameters:
lev level of the morton curve (1=2x2, 2=4x4, 3=8x8, etc)
p 2D coordinates [1 ... 2^lev]
idx index on the 2D morton curve [1 ... (2^lev)^2]
Get index on Morton curve at given 2D coordinate (coordinates-to-index).

Has logarithmic complexity: number of loop iterations = lev. Due to performance reasons, no checking of arguments is performend!


morton2d_i2c

public subroutine morton2d_i2c (lev, idx, p)
    integer (kind=i_k), intent(in) :: lev
    integer (kind=i_k), intent(in) :: idx
    integer (kind=i_k), intent(out), dimension (2) :: p
end subroutine morton2d_i2c
Parameters:
lev level of the morton curve (1=2x2, 2=4x4, 3=8x8, etc)
idx index on the 2D morton curve [1 ... (2^lev)^2]
p 2D coordinates [1 ... 2^lev]
Get 2D coordinate at given index on curve (index-to-coordinates).

Has logarithmic complexity: number of loop iterations = lev. Due to performance reasons, no checking of arguments is performend!


morton_c2i

public subroutine morton_c2i (lev, p, idx)
    integer (kind=i_k), intent(in) :: lev
    integer (kind=i_k), intent(in), dimension (3) :: p
    integer (kind=i_k), intent(out) :: idx
end subroutine morton_c2i
Parameters:
lev level of the morton curve (1=2x2x2, 2=4x4x4, 3=8x8x8, etc)
p 3D coordinates [1 ... 2^lev]
idx index on the 3D morton curve [1 ... (2^lev)^3]
Get index on Morton curve at given 3D coordinate (coordinates-to-index).

Has logarithmic complexity: number of loop iterations = lev. Due to performance reasons, no checking of arguments is performend!