aabbtree_t Derived Type

type, public :: aabbtree_t


Inherits

type~~aabbtree_t~~InheritsGraph type~aabbtree_t aabbtree_t type~node_t node_t type~aabbtree_t->type~node_t nodes type~aabb_t aabb_t type~node_t->type~aabb_t aabb

Contents

Source Code


Components

TypeVisibility AttributesNameInitial
type(node_t), public, dimension(:), allocatable:: nodes
integer, public, dimension(:), allocatable:: atnd_tab

Atom -> node map.

integer, public :: capacity

Maximum number of nodes that the tree can currently handle. This may increase as more atoms are inserted.

integer, public :: freestore

Pointer to head to the free store.

integer, public :: size

Number of nodes in the tree.

integer, public :: root

Pointer to the tree root.

real(kind=rp), public :: tskin

Thickness of the skin for fattened AABBs, as a fraction of the AABB base length.


Type-Bound Procedures

procedure, public :: init

  • interface

    private module subroutine init(this, natoms, tskin)

    Initializes an AABB tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(out) :: this

    An aabbtree_t instance.

    integer, intent(in) :: natoms

    Estimated number of atoms to be handled by this tree.

    real(kind=rp), intent(in) :: tskin

    Thickness of the skin for fattened AABBs, as a fraction of the AABB base length.

procedure, public :: print

  • interface

    private recursive module subroutine print(this, p)

    Prints a subtree of an AABB tree rooted at p in order.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    integer, intent(in), optional :: p

    Pointer to the root of the subtree. Default is the root of the whole tree.

procedure, public :: clear

  • interface

    private module subroutine clear(this)

    Clears an AABB tree. Associated memory is not deallocated.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

procedure, public :: delete

  • interface

    private module subroutine delete(this)

    Deletes an AABB tree. All associated memory is deallocated.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

procedure, public :: insert

  • interface

    private module subroutine insert(this, ia, pos, radius)

    Inserts an atom into an AABB tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

    integer, intent(in) :: ia

    Atom index

    real(kind=rp), intent(in), dimension(3):: pos

    Atom position

    real(kind=rp), intent(in) :: radius

    Atom radius (or cutoff distance for point particles)

procedure, public :: remove

  • interface

    private module subroutine remove(this, ia)

    Removes an atom from an AABB tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

    integer, intent(in) :: ia

    Atom index

procedure, public :: remove_all

  • interface

    private module subroutine remove_all(this)

    Removes all atoms from an AABB tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

procedure, public :: update_fatm

  • interface

    private module subroutine update_fatm(this, ia, pos, radius, lstat)

    Updates an AABB tree for the case when an atom leaves its fattened AABB.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

    integer, intent(in) :: ia

    Atom index

    real(kind=rp), intent(in), dimension(3):: pos

    Atom position

    real(kind=rp), intent(in) :: radius

    Atom radius (or cutoff distance for point particles)

    logical, intent(out) :: lstat

    true if the atom was reinserted, false otherwise.

procedure, public :: update_fatmaabb

  • interface

    private module subroutine update_fatmaabb(this, ia, lbnd, ubnd, lstat)

    Updates an AABB tree for the case when an atom leaves its fattened AABB, with the bounds of the new AABB for the atom as input.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

    integer, intent(in) :: ia

    Atom index

    real(kind=rp), intent(in), dimension(3):: lbnd

    Lower bound of atom AABB

    real(kind=rp), intent(in), dimension(3):: ubnd

    Upper bound of atom AABB

    logical, intent(out) :: lstat

    true if the atom was reinserted, false otherwise.

generic, public :: update => update_fatm, update_fatmaabb

procedure, public :: query_watm

  • interface

    private module subroutine query_watm(this, ia, nbrs)

    Query an AABB tree for a set of potential neighbors of an atom.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    integer, intent(in) :: ia

    Atom index

    type(ivector_t), intent(inout) :: nbrs

    List of potential neighbors.

procedure, public :: query_waabb

  • interface

    private module subroutine query_waabb(this, aabb, atms)

    Query an AABB tree for the set of atoms whose AABBS overlap with aabb.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    type(aabb_t), intent(in) :: aabb

    An aabb_t instance.

    type(ivector_t), intent(inout) :: atms

    List of potential neighbors.

procedure, public :: query_watmaabb

  • interface

    private module subroutine query_watmaabb(this, ia, aabb, nbrs)

    Query an AABB tree for a set of potential neighbors of an atom & its bounding AABB.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    integer, intent(in) :: ia

    Atom index.

    type(aabb_t), intent(in) :: aabb

    Bounding AABB for atom with index ia.

    type(ivector_t), intent(inout) :: nbrs

    List of potential neighbors.

generic, public :: query => query_watm, query_waabb, query_watmaabb

procedure, public :: get_num_atoms

  • interface

    private module function get_num_atoms(this) result(na)

    Returns the number of atoms in an AABB tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    Return Value integer

    Return value

procedure, public :: get_aabb

  • interface

    private module function get_aabb(this, ia) result(aabb)

    Returns a copy of the AABB associated with atom with index ia.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    integer, intent(in) :: ia

    Atom index.

    Return Value type(aabb_t)

    AABB of atom ia.

procedure, public :: get_height

  • interface

    private module function get_height(this) result(height)

    Returns the height of an AABB tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    Return Value integer

    Return value.

procedure, public :: get_max_balance

  • interface

    private module function get_max_balance(this) result(max_balance)

    Returns the maximum difference between the height of two children of a node.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    Return Value integer

    Return value.

procedure, public :: get_srfarea_ratio

  • interface

    private module function get_srfarea_ratio(this) result(saratio)

    Returns the ratio of the sum of the node surface area to the surface area of the root node.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    Return Value real(kind=rp)

    Return value.

procedure, public :: rebuild

  • interface

    private module subroutine rebuild(this)

    Rebuilds an optimal AABB tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

procedure, public :: validate

  • interface

    private module subroutine validate(this)

    Validates an AABB tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

procedure, private :: insert_leaf

  • interface

    private module subroutine insert_leaf(this, leaf)

    Inserts a leaf node into a tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

    integer, intent(in) :: leaf

    Pointer to a leaf node

procedure, private :: remove_leaf

  • interface

    private module subroutine remove_leaf(this, leaf)

    Removes a leaf node from a tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

    integer, intent(in) :: leaf

    Pointer to a leaf node

procedure, private :: balance

  • interface

    private module function balance(this, p) result(q)

    Balances an AABB tree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

    integer, intent(in) :: p

    Node index

    Return Value integer

procedure, private :: calc_height

  • interface

    private recursive module function calc_height(this, p) result(height)

    Calculates the height of a subtree.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    integer, intent(in), optional :: p

    Pointer to the root of the subtree. Default: Root of the whole tree.

    Return Value integer

    Return value

procedure, private :: fs_acquire

  • interface

    private module function fs_acquire(this) result(p)

    Acquires a new node from the free store and returns a pointer to it.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

    Return Value integer

    Return value

procedure, private :: fs_return

  • interface

    private module subroutine fs_return(this, p)

    Returns a node to the free store.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(inout) :: this

    An aabbtree_t instance.

    integer, intent(in) :: p

    Node pointer.

procedure, private :: validate_structure

  • interface

    private recursive module subroutine validate_structure(this, p)

    Asserts that an AABB subtree has a valid structure.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    integer, intent(in) :: p

    Pointer to the root of the subtree.

procedure, private :: validate_metrics

  • interface

    private recursive module subroutine validate_metrics(this, p)

    Asserts that an AABB subtree has a valid metric.

    Arguments

    Type IntentOptional AttributesName
    class(aabbtree_t), intent(in) :: this

    An aabbtree_t instance.

    integer, intent(in) :: p

    Pointer to the root of the subtree.

Source Code

type aabbtree_t
    type(node_t), dimension(:), allocatable :: nodes
    integer, dimension(:), allocatable :: atnd_tab
        !! Atom -> node map.
    integer :: capacity
        !! Maximum number of nodes that the tree can currently handle. This may
        !! increase as more atoms are inserted.
    integer :: freestore
        !! Pointer to head to the free store.
    integer :: size
        !! Number of nodes in the tree.
    integer :: root
        !! Pointer to the tree root.
    real(rp) :: tskin
        !! Thickness of the skin for fattened AABBs, as a fraction of the AABB
        !! base length.
    contains
        procedure :: init
        procedure :: print
        procedure :: clear
        procedure :: delete
        procedure :: insert
        procedure :: remove
        procedure :: remove_all
        procedure :: update_fatm
        procedure :: update_fatmaabb
        generic   :: update => update_fatm, update_fatmaabb
        procedure :: query_watm
        procedure :: query_waabb
        procedure :: query_watmaabb
        generic   :: query => query_watm, query_waabb, query_watmaabb
        procedure :: get_num_atoms
        procedure :: get_aabb
        procedure :: get_height
        procedure :: get_max_balance
        procedure :: get_srfarea_ratio
        procedure :: rebuild
        procedure :: validate
        procedure, private :: insert_leaf
        procedure, private :: remove_leaf
        procedure, private :: balance
        procedure, private :: calc_height
        procedure, private :: fs_acquire
        procedure, private :: fs_return
        procedure, private :: validate_structure
        procedure, private :: validate_metrics
end type aabbtree_t