Module hilbert2d_mod


Uses:
    module kinds_mod
Types:
    private type hilbert_table
Variables:
    type (hilbert_table), private, parameter, dimension (0:3) :: tab = (/ hilbert_table ((/ 2, 1, -2 /), (/ 1, 0, 0, 2 /), (/ 0, 2, 3, 1 /), (/ 0, 3, 1, 2 /)), hilbert_table ((/ 1, 2, -1 /), (/ 0, 1, 1, 3 /), (/ 0, 1, 3, 2 /), (/ 0, 1, 3, 2 /)), hilbert_table ((/ -1, -2, 1 /), (/ 3, 2, 2, 0 /), (/ 3, 2, 0, 1 /), (/ 2, 3, 1, 0 /)), hilbert_table ((/ -2, -1, 2 /), (/ 2, 3, 3, 1 /), (/ 3, 1, 0, 2 /), (/ 2, 1, 3, 0 /)) /)
Subroutines and functions:
    public subroutine hilbert2d_c2i (lev, p, idx)
    public subroutine hilbert2d_i2c (lev, idx, p)

Simple 2D Hilbert curve subroutines. Based on a table description of the curve.

Routines accept position and hilbert-index starting at 1.

Author: Matthias Lieber


Description of Types

hilbert_table

private type hilbert_table
    integer (kind=i_k), dimension (0:2) :: mv
    integer (kind=i_k), dimension (0:3) :: next
    integer (kind=i_k), dimension (0:3) :: num2ref
    integer (kind=i_k), dimension (0:3) :: ref2num
end type hilbert_table
Components:
mv spatial moves of the curve
next next states when refinining (quadrant is sequence number)
num2ref sequence number on curve primitve to reference (spatial) quadrant
ref2num reference (spatial) quadrant to sequence number on curve primitve
Type for one entry in the 2D Hilbert curve description table.

Values of the mv item are:


Description of Subroutines and Functions

hilbert2d_c2i

public subroutine hilbert2d_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 hilbert2d_c2i
Parameters:
lev level of the hilbert curve (1=2x2, 2=4x4, 3=8x8, etc)
p 2D coordinates [1 ... 2^lev]
idx index on the 2D hilbert curve [1 ... (2^lev)^2]
Get index on 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!


hilbert2d_i2c

public subroutine hilbert2d_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 hilbert2d_i2c
Parameters:
lev level of the hilbert curve (1=2x2, 2=4x4, 3=8x8, etc)
idx index on the 2D hilbert 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!