Module section_mod


Uses:
    module kinds_mod
Types:
    public type section
Variables:
    integer (kind=i_k), private, parameter :: SECTION_RECT_MAX = 4
Subroutines and functions:
    public subroutine section_reset (sect, maxrect)
    public subroutine section_add (sect, rect)
    private pure subroutine section_add_update_uvol (sect, r)
    private pure subroutine section_add_check_unify (sect, r)
    public logical function section_intersect (sect, rect, opt_offset)
    public logical function section_contains (sect, pos)
    public pure subroutine section_volume (sect, volume)

A section of a 3D domain.

The section is made up of a very limited number of clusters each consisting of a 3D rectangle (cuboid).

Rectangles can be added to a section, the algorithm tries to reduce the total volume of all clusters.

Preprocessor options:

Author: Matthias Lieber


Description of Types

section

public type section
    integer (kind=i_k), dimension (3,2,SECTION_RECT_MAX) :: rect = 0
    integer (kind=i_k) :: nrect = 0
    integer (kind=i_k), dimension (3) :: maxext
    integer (kind=i_k), dimension (SECTION_RECT_MAX) :: vol = 0
    integer (kind=i_k), dimension (SECTION_RECT_MAX,SECTION_RECT_MAX) :: uvol = HUGE (SECTION_RECT_MAX)
end type section
Components:
rect a limited number of 3D cuboids
nrect number of used cuboids
vol volume of the 3D cuboids
uvol volume of unions of the existing cuboids
A 3D section consisting of a limited number of 3D cuboids

Description of Subroutines and Functions

section_reset

public subroutine section_reset (sect, maxrect)
    type (section), intent(inout) :: sect
    integer (kind=i_k), optional, intent(in), dimension (3,2) :: maxrect
end subroutine section_reset
Parameters:
sect the section
maxrect max allowed size
Reset sect (set volume to null).

Parameter maxrect will be used in section_add to estimate if it is useful to add a new cuboid or not. This argument required only if compiled with OLD_SECTION_ADD.


section_add

public subroutine section_add (sect, rect)
    type (section), intent(inout) :: sect
    integer (kind=i_k), intent(in), dimension (3,2) :: rect
end subroutine section_add
Parameters:
sect the section
rect 3D cuboid to add
Add rect to section sect (union).

If necessary it will create a new cuboid in sect to keep overall volume as small as possible.


section_add_update_uvol

private pure subroutine section_add_update_uvol (sect, r)
    type (section), intent(inout) :: sect
    integer (kind=i_k), intent(in) :: r
end subroutine section_add_update_uvol
Parameters:
sect the section
r cuboid to update
Update uvol for cuboid r.

Internal routine.


section_add_check_unify

private pure subroutine section_add_check_unify (sect, r)
    type (section), intent(inout) :: sect
    integer (kind=i_k), intent(in) :: r
end subroutine section_add_check_unify
Parameters:
sect the section
r cuboid to unify
Unify cuboid r with other cuboids if this is possible at no cost.

The processes is repeated for the unified cuboid.

Internal routine.


section_intersect

public logical function section_intersect (sect, rect, opt_offset)
    type (section), intent(inout) :: sect
    integer (kind=i_k), intent(in), dimension (3,2) :: rect
    integer (kind=i_k), optional, intent(in), dimension (3) :: opt_offset
end function section_intersect
Parameters:
sect the section
rect 3D cuboid to intersect
opt_offset optional offset for upper bound of sect
Return .true. if intersection of sect with cuboid rect is not empty.

Optionally, an offset used for the upper bound of sect can be given.


section_contains

public logical function section_contains (sect, pos)
    type (section), intent(inout) :: sect
    integer (kind=i_k), intent(in), dimension (3) :: pos
end function section_contains
Parameters:
sect the section
pos pos
Return .true. if sect contains the point at pos.

section_volume

public pure subroutine section_volume (sect, volume)
    type (section), intent(inout) :: sect
    integer (kind=i_k), intent(out) :: volume
end subroutine section_volume
Parameters:
sect the section
volume volume
Calculate total volume of the section.