Implements an axis-aligned bounding box (AABB) tree. This code is adapted from the C++ implementation by Lester Hedges. The original C++ implementation can be found here.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | private, | parameter | :: | NULL_NODE | = | 0 | |
type(ivector_t), | private | :: | stack |
Is this a leaf node?
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(node_t), | intent(in) | :: | this | A node_t instance. |
true if this is a leaf node, false otherwise.
Returns a string representation of a node.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(node_t), | intent(in) | :: | this | A node_t instance. |
||
character(len=*), | intent(in), | optional | :: | frmt | Format string for real numbers, e.g. '(f15.6)'. Default: (g0.6). |
Return value
Returns the number of atoms in an AABB tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(in) | :: | this | An aabbtree_t instance. |
Return value
Returns a copy of the AABB associated with atom with index ia
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(in) | :: | this | An aabbtree_t instance. |
||
integer, | intent(in) | :: | ia | Atom index. |
AABB of atom ia
.
Returns the height of an AABB tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(in) | :: | this | An aabbtree_t instance. |
Return value.
Returns the maximum difference between the height of two children of a node.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(in) | :: | this | An aabbtree_t instance. |
Return value.
Returns the ratio of the sum of the node surface area to the surface area of the root node.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(in) | :: | this | An aabbtree_t instance. |
Return value.
Balances an AABB tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(inout) | :: | this | An aabbtree_t instance. |
||
integer, | intent(in) | :: | p | Node index |
Calculates the height of a subtree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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
Acquires a new node from the free store and returns a pointer to it.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(inout) | :: | this | An aabbtree_t instance. |
Return value
Initializes a node.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(node_t), | intent(out) | :: | this | A node_t instance. |
Initializes an AABB tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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. |
Prints a subtree of an AABB tree rooted at p
in order.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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. |
Clears an AABB tree. Associated memory is not deallocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(inout) | :: | this | An aabbtree_t instance. |
Deletes an AABB tree. All associated memory is deallocated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(inout) | :: | this | An aabbtree_t instance. |
Inserts an atom into an AABB tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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) |
Removes an atom from an AABB tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(inout) | :: | this | An aabbtree_t instance. |
||
integer, | intent(in) | :: | ia | Atom index |
Removes all atoms from an AABB tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(inout) | :: | this | An aabbtree_t instance. |
Updates an AABB tree for the case when an atom leaves its fattened AABB.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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. |
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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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. |
Query an AABB tree for a set of potential neighbors of an atom.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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. |
Query an AABB tree for a set of potential neighbors of an atom & its bounding AABB.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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 |
||
type(ivector_t), | intent(inout) | :: | nbrs | List of potential neighbors. |
Query an AABB tree for the set of atoms whose AABBS overlap with
aabb
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
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. |
Rebuilds an optimal AABB tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(inout) | :: | this | An aabbtree_t instance. |
Validates an AABB tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(in) | :: | this | An aabbtree_t instance. |
Inserts a leaf node into a tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(inout) | :: | this | An aabbtree_t instance. |
||
integer, | intent(in) | :: | leaf | Pointer to a leaf node |
Removes a leaf node from a tree.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(inout) | :: | this | An aabbtree_t instance. |
||
integer, | intent(in) | :: | leaf | Pointer to a leaf node |
Returns a node to the free store.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(inout) | :: | this | An aabbtree_t instance. |
||
integer, | intent(in) | :: | p | Node pointer. |
Asserts that an AABB subtree has a valid structure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(in) | :: | this | An aabbtree_t instance. |
||
integer, | intent(in) | :: | p | Pointer to the root of the subtree. |
Asserts that an AABB subtree has a valid metric.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(aabbtree_t), | intent(in) | :: | this | An aabbtree_t instance. |
||
integer, | intent(in) | :: | p | Pointer to the root of the subtree. |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | next | = | NULL_NODE | ||
integer, | public | :: | parent | = | NULL_NODE | ||
integer, | public | :: | left | = | NULL_NODE | ||
integer, | public | :: | right | = | NULL_NODE | ||
integer, | public | :: | height | = | -1 | ||
integer, | public | :: | atom | = | 0 | ||
type(aabb_t), | public | :: | aabb |
procedure, public :: init => node_init | |
procedure, public :: isleaf => node_isleaf | |
procedure, public :: asstr => node_asstr |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
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. |
procedure, public :: init | |
procedure, public :: print | |
procedure, public :: clear | |
procedure, public :: delete | |
procedure, public :: insert | |
procedure, public :: remove | |
procedure, public :: remove_all | |
procedure, public :: update_fatm | |
procedure, public :: update_fatmaabb | |
generic, public :: update => update_fatm, update_fatmaabb | |
procedure, public :: query_watm | |
procedure, public :: query_waabb | |
procedure, public :: query_watmaabb | |
generic, public :: query => query_watm, query_waabb, query_watmaabb | |
procedure, public :: get_num_atoms | |
procedure, public :: get_aabb | |
procedure, public :: get_height | |
procedure, public :: get_max_balance | |
procedure, public :: get_srfarea_ratio | |
procedure, public :: rebuild | |
procedure, public :: 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 |