API Reference

H2Trees.AggregateMode β€” Type
AggregateMode <: FarMulMode

This mode uses AggregatePlan and DisaggregateTranslatePlan to perform the farmultiplication.

source
H2Trees.AggregatePlan β€” Type
    AggregatePlan

Aggregation plan for a tree.

This plan specifies which nodes are visited during upward traversal and which node moments must be stored for later use by translation/disaggregation phases.

This is not a translating plan and the corresponding translating plan is a DisaggregateTranslatePlan.

Fields:

- `nodes`: Aggregation nodes grouped per level sorted from leave nodes to root.
- `levels`: Aggregation levels (leaves to root).
- `storenode`: Boolean flag per node index indicating whether that node's moment is
    stored.
- `rootoffset`: Offset used to convert node ids to compact 1-based storage indices
- `tree`: Tree for which the plan is built.
source
H2Trees.AggregatePlan β€” Method
AggregatePlan(tree, aggregatenode)

Build an AggregatePlan from aggregatenode(node).

A node is marked for storage when aggregatenode(node) is true. Nodes that do not store moments are still included in traversal if any ancestor satisfies aggregatenode, ensuring paths toward storing nodes are aggregated correctly.

Block trees are not supported by this constructor; specify the aggregation tree explicitly in a non-block-tree context.

source
H2Trees.AggregateTranslatePlan β€” Type
    AggregateTranslatePlan

Aggregation translation plan for a tree.

This is a translating plan used during upward traversal to compute and store moments that contribute to translation. The matching disaggregation plan is a DisaggregateTranslatePlan.

Fields:

  • receivingnodes: Per level, a dictionary mapping receiving nodes (not necessarily in tree) to source aggregation node ids (in tree) whose moments translate to the receiver.
  • nodes: Per level, nodes that must be visited during aggregation (from leaves to root).
  • levels: Aggregation levels ordered from leaves to root.
  • istranslatingnode: Boolean flag per node index indicating whether the node contributes as a translating/source node.
  • rootoffset: Offset used to convert node ids to 1-based storage indices.
  • tree: Tree for which the plan is built.
source
H2Trees.AggregateTranslatePlan β€” Method
    AggregateTranslatePlan(tree, TranslatingNodesIterator)
    AggregateTranslatePlan(testtree, trialtree, TranslatingNodesIterator)

Build an AggregateTranslatePlan from an iterator/functor that provides translating target nodes for a source aggregation node.

Single-tree form:

  • TranslatingNodesIterator(node) yields receiving nodes in tree that receive translated information from node.

Two-tree form:

  • TranslatingNodesIterator(testnode) is wrapped so the resulting plan is built on testtree, while receiving nodes are selected using trialtree.

For block trees, the tree used for aggregation must be specified explicitly via the two-tree constructor.

source
H2Trees.AllTranslations β€” Type
struct AllTranslations <: AbstractTranslationTrait

Represents the translation trait where all translations that occur are unique and are stored individually.

source
H2Trees.BEASTProtrusionFunctor β€” Type
BEASTProtrusionFunctor(space)

Protrusion evaluator backed by a BEAST space.

Concrete call methods for this type are provided by the H2BEASTTrees extension.

source
H2Trees.BlockTree β€” Type
    BlockTree{T}

Container holding a pair of trees used as test and trial clusters.

Fields:

  • testcluster::T
  • trialcluster::T
source
H2Trees.BoundingBallTree β€” Type
BoundingBallTree{N,D,T} <: H2ClusterTree

A cluster tree where nodes are bounded by spheres (balls).

This tree structure uses spherical bounding volumes to organize spatial data hierarchically. Each node is bounded by a ball with a center and radius.

Type Parameters

  • N: The ambient dimension (coordinate space dimension).
  • D: The type of nodes.
  • T: The type of the radius.

Fields

  • nodes::Vector{Node{D}}: Vector of nodes comprising the tree.
  • root::Int: Index of the root node.
  • center::SVector{N,T}: Center of the bounding ball of the tree.
  • radius::T: Radius of the bounding ball of the tree.
  • nodesatlevel::Vector{Vector{Int}}: Vector of vectors, where each inner vector contains the indices of nodes at a specific level.
source
H2Trees.ChildIterator β€” Type
ChildIterator{T,N<:Integer}

An iterator over the children of a node in a tree.

Fields

  • tree::T: The tree.
  • node::N: The node whose children are being iterated over.
source
H2Trees.ComputeProtrusionFunctor β€” Type
ComputeProtrusionFunctor

Default protrusion evaluator.

This functor represents relative protrusion normalized by 2 * halfsize of a box. The base implementation returns zero and is intended as a lightweight fallback and extension point.

source
H2Trees.DepthFirstIterator β€” Type
DepthFirstIterator{T,N<:Integer}

Traverses the tree in a depth first manner. If no node is specified the tree is traversed from the root node.

Fields

  • tree::T: The tree.
  • node::Int: The node from which the tree is traversed.

Methods

DepthFirstIterator(tree, node)

Creates a new DepthFirstIterator instance, traversing the tree from the specified node.

DepthFirstIterator(tree)

Creates a new DepthFirstIterator instance, traversing the tree from the root node.

source
H2Trees.DirectionInvariance β€” Type
struct DirectionInvariance <: AbstractTranslationTrait

Represents the translation trait where the direction of translation is invariant, i.e., translations in different directions are identical. Therefore, only one version of the translation is stored.

source
H2Trees.DirectionInvariancePerLevel β€” Type
struct DirectionInvariancePerLevel <: AbstractTranslationTrait

Represents the translation trait where translations on the same level with the same length and direction are identical. Therefore, only one version of the translation is stored.

source
H2Trees.DisaggregatePlan β€” Type
    DisaggregatePlan

Non-translating disaggregation plan. The corresponding aggregation plan is a AggregateTranslatePlan`

Fields:

- `nodes`: disaggregation nodes grouped per level, ordered from lower to higher
    level (root to leaves).
- `levels`: contiguous level range corresponding to `nodes`, with increasing
    order from root to leaves.
- `storenode`: boolean marker per tree node indicating whether that node
    receives and stores a moment directly or if one of its ancestors does so.
- `rootoffset`: offset used to map node ids to 1-based storage indices.
- `tree`: tree on which disaggregation is defined.
source
H2Trees.DisaggregatePlan β€” Method
    DisaggregatePlan(tree, disaggregatenode)

Build a `DisaggregatePlan` on `tree` using `disaggregatenode`.

disaggregatenode marks nodes that store moments directly; nodes below a marked ancestor are included in the disaggregation traversal even when they do not store directly.

This constructor is defined for non-BlockTree trees. For block trees, select the corresponding test or trial tree first.

source
H2Trees.DisaggregateTranslatePlan β€” Type
    DisaggregateTranslatePlan

Disaggregation translation plan for a single tree.

This is a translating plan used during downward traversal. The matching aggregation plan is an AggregatePlan.

Fields:

- `translatingnodes`: Per level, a dictionary mapping receiving nodes (in `tree`) to
    source nodes, which do not have to be in `tree`.
- `nodes`: Per level, nodes that must be visited during disaggregation.
- `levels`: Contiguous disaggregation levels ordered from coarse to fine (root to leaves).
- `isdisaggregationnode`: Boolean flag per node indicating whether the node is
    reached by the disaggregation traversal (either directly receiving translated data or
    via its ancestors).
- `rootoffset`: Offset used to convert node ids to 1-based storage indices
- `tree`: Tree for which the plan is built.
source
H2Trees.DisaggregateTranslatePlan β€” Method
    DisaggregateTranslatePlan(tree, TranslatingNodesIterator)
    DisaggregateTranslatePlan(testtree, trialtree, TranslatingNodesIterator)

Build a DisaggregateTranslatePlan from an iterator/functor that provides translating source nodes for a receiving node.

Single-tree form:

  • TranslatingNodesIterator(node) yields source nodes in tree that translate to node.

Two-tree form:

  • TranslatingNodesIterator(testnode) is wrapped so the resulting plan is built on testtree, while source nodes are selected using trialtree.

For block trees, the tree used for disaggregation must be specified explicitly via the two-tree constructor.

source
H2Trees.ParentUpwardsIterator β€” Type
ParentUpwardsIterator{T,N<:Int}

ParentUpwardsIterator is an iterator that iterates over all parent nodes of a given node in a tree until the root is reached. The last node is the node 0.

Fields

  • tree::T: The tree.
  • node::Int: The node over which parents is iterated.
source
H2Trees.SimpleHybridTree β€” Type
SimpleHybridTree{T} <: H2ClusterTree

A cluster tree that divides into upper and lower tree regions at a hybrid level.

The upper tree spans from the minimum level to hybridlevel, while the lower tree spans from hybridlevel+1 to the maximum level. This structure enables efficient hybrid algorithms that treat different tree regions differently.

Fields

  • tree::T: The underlying cluster tree.
  • hybridlevel::Int: The level that separates the upper and lower tree regions.
source
H2Trees.SimpleHybridTree β€” Method
SimpleHybridTree(tree::TwoNTree; hs=H2Trees.halfsizes(tree), hybridhalfsize::H=maximum(hs))

Construct a SimpleHybridTree for a TwoNTree by specifying the hybrid halfsize.

The hybrid level is determined by finding the first level whose halfsize is less than or equal to the specified hybridhalfsize. An error is raised if the hybrid halfsize is smaller than the minimum halfsize in the tree or if any leaf is below the computed hybrid level.

Arguments

  • tree::T: The underlying TwoNTree cluster tree.
  • hs: The halfsizes of tree levels (default: H2Trees.halfsizes(tree)).
  • hybridhalfsize::H: The halfsize threshold for determining the hybrid level (default: maximum halfsize).

Returns

A new SimpleHybridTree instance with the computed hybrid level.

Throws

Error if hybridhalfsize is smaller than the minimum halfsize or if any leaf is below the hybrid level.

source
H2Trees.TwoNTree β€” Type
TwoNTree{N,D,T} <: H2ClusterTree

A cluster tree where nodes are bounded by axis-aligned boxes.

This tree structure uses boxes to partition spatial data hierarchically. Each node is bounded by a box defined by a center and halfsize.

Type Parameters

  • N: The coordinate space dimension.
  • D: The type of the nodes.
  • T: The numeric type for coordinates and halfsizes.

Fields

  • nodes::Vector{Node{D}}: Vector of nodes comprising the tree.
  • root::Int: Index of the root node.
  • center::SVector{N,T}: Center of the bounding box of the tree.
  • halfsize::T: Halfsize of the bounding box of the tree.
  • nodesatlevel::Vector{Vector{Int}}: A vector of vectors, where each inner vector contains the indices of nodes at a specific level.
source
H2Trees.TwoNTree β€” Method
    TwoNTree(testpositions, trialpositions, minhalfsize; kwargs...)

Construct a BlockTree from separate test and trial positions.

Each side is built as a TwoNTree with compatible root sizes and minimum levels, so both trees can be used together in block-tree traversals.

Keyword arguments

- `testminvalues=0`, `trialminvalues=testminvalues`: A node is only split if it has at least minimum values.
- `testmaxprotrusion=NaN`, `trialmaxprotrusion=testmaxprotrusion`:
    Maximum protrusion thresholds for splitting.
- `testcomputeprotrusion=ComputeProtrusionFunctor()`,
    `trialcomputeprotrusion=ComputeProtrusionFunctor()`: Protrusion functors.

Returns

A BlockTree with a test tree and a trial tree.

source
H2Trees.TwoNTree β€” Method
TwoNTree(positions, minhalfsize; minlevel::Int=1, root::Int=1, minvalues=0, maxprotrusion=NaN, computeprotrusion=ComputeProtrusionFunctor())

Construct a TwoNTree from a collection of positions.

This constructor creates a hierarchical bounding box tree by recursively partitioning the given points. The tree is built by computing the bounding box of all positions and recursively subdividing boxes until the minimum halfsize is reached or stopping criteria are met.

Arguments

  • positions: Collection of points to partition.
  • minhalfsize: Minimum halfsize for leaf boxes.
  • minlevel::Int: Minimum tree level (default: 1).
  • root::Int: Index of root node (default: 1).
  • minvalues: Minimum number of points required before subdividing (default: 0).
  • maxprotrusion: Maximum allowed protrusion for nodes (default: NaN for no limit).
  • computeprotrusion: Function to compute protrusion metrics (default: ComputeProtrusionFunctor()).

Returns

A TwoNTree with positions hierarchically organized in axis-aligned boxes.

source
H2Trees.KMeansTree β€” Method
KMeansTree(points::AbstractVector{SVector{N,T}}, numberofclusters::Int; minvalues::Int=numberofclusters, minlevel::Int=1, root::Int=1, balldata=BoundingBallData, updateradii=boundingsphere, kwargs...)

Construct a BoundingBallTree using k-means clustering to partition the given points.

This function recursively clusters the points using k-means algorithm to build a hierarchical tree structure. Each node in the tree contains a cluster of points bounded by a sphere.

Arguments

  • points::AbstractVector{SVector{N,T}}: Array of points to partition.
  • numberofclusters::Int: Number of clusters for k-means at each split.
  • minvalues::Int: Minimum number of points required before splitting a node (default: numberofclusters).
  • minlevel::Int: Minimum tree level (default: 1).
  • root::Int: Index of root node (default: 1).
  • balldata: Data structure for storing bounding ball information (default: BoundingBallData).
  • updateradii: Function for updating node radii (default: boundingsphere).
  • kwargs...: Additional arguments passed to the k-means wrapper function.

Returns

A BoundingBallTree with points organized hierarchically by k-means clustering.

source
H2Trees.LevelIterator β€” Method
LevelIterator(tree, level::Int)

Return an iterator over the nodes at the specified level in the tree.

Arguments

  • tree: The tree object.
  • level: The level at which to iterate.

Returns

An iterator over the nodes at the specified level.

source
H2Trees.NearNodeIterator β€” Method
NearNodeIterator(testtree, trialtree, trialnode::Int; isnear=isnear)

Returns an iterator over the nodes in the testtree that are at the same level as the specified node in the trialtree and are near to node. Two nodes are near if the function isnear(testtree, trialtree, testnode, trialnode) evaluates to true.

Arguments

  • testtree: The tree to search for near nodes.
  • trialtree: The tree that contains the node to find near nodes for.
  • trialnode::Int: The node in the trialtree from which to start the search.
  • isnear: A function that returns true if two nodes are near each other. Defaults to isnear.

Returns

An iterator over the nodes in the testtree that are at the same level as the specified node in the trialtree and are near to node.

source
H2Trees.NearNodeIterator β€” Method
NearNodeIterator(tree, node::Int; isnear=isnear)

Returns an iterator over the nodes in the tree that are at the same level as the specified node and are near to node. Two nodes are near if the function isnear(tree, nodea, nodeb) evaluates to true.

Arguments

  • tree: The tree to search for near nodes.
  • node::Int: The node from which to start the search.
  • isnear: A function that returns true if two nodes are near each other. Defaults to isnear.

Returns

An iterator over the nodes in the tree that are at the same level as the specified node and are near to node.

source
H2Trees.NodeFilterIterator β€” Method
NodeFilterIterator(testtree, trialtree, trialnode::Int, filter)

Returns an iterator over nodes at the same level as trialnode in trialtree, for which the function filter(testtree, trialtree, testnode, trialnode) return true.

In the case of a tree with the trait isBlockTree, it is assumed that trialnode is belonging to the trialtree.

Arguments

  • testtree: The tree to iterate over
  • trialtree: The tree to which the trialnode belongs to
  • trialnode::Int: The node to start from
  • filter: A function that takes a test tree, a trial tree, a test node, and a trial node and returns a boolean

Returns

An iterator over nodes at the same level as trialnode that pass the filter

source
H2Trees.NodeFilterIterator β€” Method
NodeFilterIterator(tree, node::Int, filter)

Returns an iterator that returns nodes at the same level as node, for which the function filter(tree, nodea, nodeb) or the function filter(testtree, trialtree, testnode, trialnode) return true. In the case of a tree with the trait isBlockTree it is assumed that node is belonging to the trialtree.

Arguments

  • tree: The tree to iterate over
  • node::Int: The node to start from
  • filter: A function that takes a tree and two nodes and returns a boolean

Returns

An iterator over nodes at the same level as node that pass the filter

source
H2Trees.SameLevelIterator β€” Method
SameLevelIterator(tree, node::Int)

Returns an iterator over the nodes at the same level as node in the tree.

Arguments

  • tree: The tree structure.
  • node: The node for which to find the same level nodes.

Returns

An iterator over the nodes at the same level as node.

source
H2Trees.WellSeparatedIterator β€” Method
WellSeparatedIterator(testtree, trialtree, trialnode::Int; iswellseparated=iswellseparated)

Constructs an iterator to identify which translations should occur and which should not. This determination is based on the concept of well-separated nodes. Two nodes are considered well-separated if their parents are near each other and the nodes themselves are far apart. This assumes that child clusters are completely inside their parent clusters.

Arguments

  • testtree: the test tree
  • trialtree: the trial tree
  • trialnode: the node in the trial tree for which the translations happen
  • iswellseparated: a function that returns true if two nodes are well-separated and false otherwise

Returns

An iterator that yields the nodes in the testtree that are well-separated from the specified trialnode in the trialtree.

source
H2Trees.WellSeparatedIterator β€” Method
WellSeparatedIterator(tree, node::Int; iswellseparated=iswellseparated)

Constructs an iterator to identify which translations should occur and which should not. This determination is based on the concept of well-separated nodes. Two nodes are considered well-separated if their parents are near each other and the nodes themselves are far apart. This assumes that child clusters are completely inside their parent clusters.

Arguments

  • tree: the tree in which the translations occur
  • node: the node for which the translations happen
  • iswellseparated: a function that returns true if two nodes are well-separated and false otherwise

Returns

An iterator that yields the nodes that are well-separated from the specified node in the tree.

source
H2Trees.WellSeparatedIterator β€” Method
WellSeparatedIterator(; isnear=nothing, iswellseparated=nothing)

Constructs a functor that returns a WellSeparatedIterator if provided a tree. Two nodes are considered well-separated if their parents are near each other and the nodes themselves are far apart. This assumes that child clusters are completely inside their parent clusters.

Arguments

  • isnear: a function that takes a tree as input and returns another function. This returned function is then used to evaluate the isnear criterion.
  • iswellseparated: a function that takes a tree as input and returns another function. This returned function is then used to evaluate the iswellseparated criterion.

Returns

A WellSeparatedIteratorFunctor that returns a WellSeparatedIterator if provided with a tree.

Throws

  • error: if both isnear and iswellseparated are provided, or if neither is provided.
source
H2Trees.adjointplans β€” Method
adjointplans(aggregationplan, disaggregationplan)

Return the adjoint pair (adjointaggregation, adjointdisaggregation) associated with the provided forward aggregationplan and disaggregationplan.

source
H2Trees.boundingbox β€” Method
boundingbox(points::Vector{SVector{D, T}})

Returns halfsize and center of bounding box of points. The halfsize is the half of the length of the edge of the bounding box.

source
H2Trees.boundingsphere β€” Method
boundingsphere(tree, node::Int)

Compute a bounding sphere that encloses a tree node and all its children recursively.

This function performs a coarse approximation of the smallest enclosing ball algorithm by recursively computing bounding spheres for each child node and merging them.

Arguments

  • tree: The bounding ball tree.
  • node::Int: Index of the node to compute the bounding sphere for.

Returns

A tuple (center, radius) representing the bounding sphere.

source
H2Trees.comparisonTwoNTree β€” Method
comparisonTwoNTree(points, root::Int, roothalfsize, minlevel)

Construct a TwoNTree for comparisons where the boxes are subdivided until each leaf contains exactly one point.

Arguments

  • points: Collection of points to partition.
  • root::Int: Index of root node.
  • roothalfsize: Halfsize of the root bounding box.
  • minlevel: Minimum tree level.

Returns

A TwoNTree where each leaf node contains exactly one point, suitable for comparisons.

source
H2Trees.cornerpoints β€” Method
cornerpoints(tree::TwoNTree{N,D,T}, node::Int, i)

Return the corner point of a given node in an N-dimensional TwoNTree.

Arguments

  • tree::TwoNTree{N,D,T}: The tree.
  • node::Int: The index of the node.
  • i: The corner point index (1 til 2^N).

Returns

  • The corner point coordinates as a SVector.
source
H2Trees.findleafnode β€” Method
findleafnode(tree, value::Int)

Find the leaf node in the given tree that contains the specified value.

Arguments

  • tree: The tree to search in.
  • value: The value to search for.

Returns

  • The leaf node that contains the value, or 0 if not found.
source
H2Trees.galerkinplans β€” Method
galerkinplans(tree, aggregatenode, translatingnodesiterator, aggregationmode)

Construct the four Galerkin plans for tree: trialaggregationplan, testdisaggregationplan, testaggregationplan, and trialdisaggregationplan.

The returned named tuple also contains relevantlevels, defined from the minimum level at which aggregation and disaggregation are both meaningful up to the deepest level of tree.

Assumptions:

  • Aggregation and disaggregation are built on the same tree (tree is not a BlockTree).
source
H2Trees.isfar β€” Method
isfar(testtree, trialtree, testnode::Int, trialnode::Int)

Return the logical negation of the trait-dispatched two-tree isnear predicate.

source
H2Trees.isfar β€” Method
isfar(tree, testnode::Int, trialnode::Int)

Return the logical negation of isnear(tree, testnode, trialnode).

source
H2Trees.isin β€” Method
isin(tree, node, point)

Return whether point lies in node for tree.

source
H2Trees.isnear β€” Method
isnear(testtree, trialtree, testnode::Int, trialnode::Int; minlevel=level(testtree, root(testtree)), kwargs...)

Return whether two nodes, one from each tree, are near.

If either node level is below minlevel, this returns true immediately; otherwise it forwards to trait-dispatched isnear.

source
H2Trees.isnear β€” Method
isnear(tree, testnode::Int, trialnode::Int; minlevel=level(tree, root(tree)), kwargs...)

Return whether two nodes in a single tree are near.

If level(tree, testnode) < minlevel, this returns true immediately; otherwise it forwards to trait-dispatched isnear.

source
H2Trees.leaves β€” Function
leaves(tree, node::Int)

Returns an iterator over the leaf nodes in the tree, starting from the specified node. If no node is specified the tree is traversed from the root node.

Arguments

  • tree: The tree to search for leaf nodes.
  • node::Int: The node from which to start the search.

Returns

An iterator over the leaf nodes in the tree.

source
H2Trees.leveltolevelid β€” Method
leveltolevelid(tree, level::Int)

Converts a level in the tree to its corresponding level ID. This is relevant since the first level might not be level 1.

Arguments

  • tree: The tree object.
  • level: The level to convert.

Returns

The level ID corresponding to the given level.

source
H2Trees.locatepoint β€” Method
locatepoint(tree, point, level)

Find the node in tree at the given level whose box contains point.

Starting from the root, the function descends the tree by determining which child sector contains point at each level, until the target level is reached.

Arguments

  • tree: A TwoNTree.
  • point: The point to locate.
  • level: The tree level at which to find the containing node.

Returns

  • The node index of the box at level that contains point.

Throws

  • An error if no suitable node at level is found for point.
source
H2Trees.maxprotrusion β€” Method
maxprotrusion(tree; computeprotrusion=ComputeProtrusionFunctor)

Compute the maximum protrusion per tree level.

For each leaf, this evaluates computeprotrusion(tree, leaf, value) for all values in the leaf and stores the leaf maximum on its level. The level-wise protrusion is then propagated upwards so each coarser level is at least half of the next finer level.

A warning is emitted when a level protrusion is greater than or equal to 0.5.

Returns

A vector with one protrusion value per level in levels(tree).

source
H2Trees.minimumlevel β€” Method
minimumlevel(tree)

Get the minimum level of a tree, which is the level of the root node. This is not necessarily the level 1.

Arguments

  • tree: The tree.

Returns

The minimum level of the tree.

source
H2Trees.mintranslationlevel β€” Method
mintranslationlevel(tree; TranslatingNodesIterator=TranslatingNodesIterator)

Return the first tree level that contains at least one translating node.

A node is considered translating if istranslatingnode(tree, node; TranslatingNodesIterator=...) is true.

Returns

The minimum level with a translating node. If no translating node exists, the last level of tree is returned.

source
H2Trees.nearinteractions β€” Method
nearinteractions(tree; kwargs...)

Compute near-interaction index lists for tree.

Keyword arguments

- `extractselfvalues::Bool=false`: Controls whether self-interactions are returned separately.
- `isnear=isnear`: Decides if two nodes are near.

Returns

For a single tree:

- If `extractselfvalues == false`:
    `(v::Vector{Vector{Int}}, nearvalues::Vector{Vector{Int}})` where each
    `v[i]` is paired with `nearvalues[i]`, including self-interactions.
- If `extractselfvalues == true`:
    `(selfv::Vector{Vector{Int}}, v::Vector{Vector{Int}}, nearvalues::Vector{Vector{Int}})`
    where `selfv` contains self-interaction
    values, and `(v, nearvalues)` contains non-self near interactions.

For a block tree (testtree, trialtree):

- Always returns `(testv::Vector{Vector{Int}}, trialv::Vector{Vector{Int}})`.
    In this mode, `extractselfvalues` is required to be `false`.
source
H2Trees.nearnodevalues β€” Method
nearnodevalues(testtree, trialtree, trialnode::Int; isnear=isnear, storevalues=Val{:flattened}())

Collect values from near nodes in testtree for a reference node in trialtree.

The traversal first visits near nodes relative to trialnode, then walks upward through trial-tree parents and adds near leaf nodes.

Keyword arguments

  • isnear: Decides if two nodes are near.
  • storevalues: Storage strategy for collected values. Val{:flattened}() returns a flattened Vector{Int}.

Returns

Collected values from testtree according to storevalues (flattened by default).

source
H2Trees.nearnodevalues β€” Method
    nearnodevalues(tree, node::Int; isnear=isnear, storevalues=Val{:flattened}())

Collect values stored in near nodes for node in a single tree.

The traversal first visits near nodes at the level of node, then walks upward through parents and includes near leaf nodes.

Keyword arguments

- `isnear`: Decides if two nodes are near.
- `storevalues`: Storage strategy for collected values. `Val{:flattened}()` returns a flattened `Vector{Int}`.

Returns

Collected values according to storevalues (flattened by default).

source
H2Trees.noboundingsphereupdate β€” Method
noboundingsphereupdate(tree, node::Int)

Return the node's bounding sphere without updating it.

This function returns the stored center and radius of a node without performing any computation or update. This can be used when radii updates are intentionally skipped and existing values should be preserved as-is.

Warning

The radii of the tree have not been updated. This will lead to incorrect results when using the iterators in H2Trees. Proceed at your own risk.

Arguments

  • tree: The bounding ball tree.
  • node::Int: Index of the node.

Returns

A tuple (center, radius) with the node's current stored values.

source
H2Trees.parentcenterminuschildcenter β€” Method
parentcenterminuschildcenter(tree::TwoNTree{N,D,T}, child::Int) where {D,T}

Calculate the difference r_p-r_c between the center of the parent r_p and the center of the child node r_c.

Arguments

  • tree::TwoNTree{N,D,T}
  • child::Int: The index of the child node.

Returns

  • SVector{N,T}: The difference between the center of the parent node and the center of the child node.
source
H2Trees.petrovplans β€” Method
    petrovplans(tree, aggregatenode, translatingnodesiterator, aggregationmode)

Construct the four Petrov-Galerkin plans for a block tree tree: testaggregationplan, trialaggregationplan, testdisaggregationplan, and trialdisaggregationplan.

The returned named tuple also contains:

  • relevantlevels: levels where all generated plans are simultaneously relevant.
  • mintranslationlevel: first level where translations appear in both test and trial disaggregation plans.
source
H2Trees.splitplan β€” Method
splitplan(tree, plan)

Split a translating plan into two subplans at hybridlevel(tree).

The function returns (upperplan, lowerplan), both with the same concrete plan type as plan, where level sets are partitioned into levels at or above the hybrid level and levels below it.

source
H2Trees.testwellseparatedness β€” Method
testwellseparatedness(tree)

Check that the well-separated translation rule is consistent for tree.

A pair of nodes is treated as well-separated when the two nodes are far, while their parents are near. In that case, a translation is expected.

This test verifies that each tested pair is covered in exactly one way: near interaction, direct translation, or parent-level translation. In particular, a translation must not be duplicated through another route (for example, also via parents).

Returns

true if each tested node pair has exactly one connection class; otherwise throws an error.

source
H2Trees.translations β€” Method
function translations(tree, translatingplan::AbstractPlan, translationtrait)

Compute the translations of the tree based on the given translating plan and translation trait.

Arguments

  • tree: The tree
  • translatingplan::AbstractPlan: The plan describing the translations in the tree
  • translationtrait: The trait describing the translations

Returns

A tuple containing two vectors:

  • The first vector contains NamedTuples with fields receivingnode, translatingnode, and translationID. The translationID is the id of the translation in the translation directions.
  • The second vector contains the translation directions.
source
H2Trees.unsafemaxradiusboundingsphere β€” Method
unsafemaxradiusboundingsphere(tree, node::Int)

Compute a bounding sphere using the maximum child radius (unsafe approximation).

This function computes a bounding sphere by taking the node's center and using the maximum radius among all child nodes. This is an unsafe approximation that may not correctly enclose all child nodes and should only be used when the proper bounding sphere computation has failed or for testing purposes.

Warning

The radii of the tree have not been properly updated. This will lead to incorrect results when using the iterators in H2Trees. Proceed at your own risk.

Arguments

  • tree: The bounding ball tree.
  • node::Int: Index of the node.

Returns

A tuple (center, radius) where radius is the maximum child radius.

source
H2Trees.values β€” Method
values(tree, node::Int)

Returns the values stored in the given node of the tree. If the node is a leaf node, it returns the values directly. Otherwise, it recursively collects the values from all the leaf nodes in the subtree rooted at the given node.

Arguments

  • tree: The H2 tree.
  • node::Int: The index of the node.

Returns

An array of values stored in the given node or its subtree.

source
H2Trees.BEASTProtrusionFunctor β€” Method
(f::BEASTProtrusionFunctor)(tree, node::Int, value::Int)

Compute the protrusion of basis function value relative to node in tree.

This method uses H2Trees.center(tree, node) and H2Trees.halfsize(tree, node) and forwards to the center/halfsize overload.

source
H2Trees.BEASTProtrusionFunctor β€” Method
(f::BEASTProtrusionFunctor)(center::A, halfsize::T, value::Int) where {T,A<:AbstractVector{T}}

Compute the maximum normalized protrusion of basis function value with respect to an axis-aligned box centered at center with halfsize halfsize.

The protrusion is evaluated over all support vertices and the maximum value is returned.

source
H2Trees.TwoNTree β€” Method
TwoNTree(space::BEAST.Space, minhalfsize; kwargs...)

Construct a TwoNTree from a given BEAST.Space.

Arguments

  • space::BEAST.Space: The input space.
  • minhalfsize: The minimum half-size of the tree.
  • computeprotrusion: Protrusion functor used during tree construction. Defaults to BEASTProtrusionFunctor(space).
  • kwargs...: Additional keyword arguments.

Returns

A TwoNTree.

source
H2Trees.TwoNTree β€” Method
TwoNTree(testspace::BEAST.Space, trialspace::BEAST.Space, minhalfsize; kwargs...)

Construct a block tree with two TwoNTrees from two given spaces: a test space and a trial space.

Arguments

  • testspace::BEAST.Space: The test space.
  • trialspace::BEAST.Space: The trial space.
  • minhalfsize: The minimum half-size of the tree.
  • testcomputeprotrusion: Protrusion functor for the test tree. Defaults to BEASTProtrusionFunctor(testspace).
  • trialcomputeprotrusion: Protrusion functor for the trial tree. Defaults to BEASTProtrusionFunctor(trialspace).
  • kwargs...: Additional keyword arguments.

Returns

A TwoNTree.

source
H2Trees.traceball β€” Method
traceball(center::H2ClusterTree, radius; n=30, kwargs...) where

Returns a trace, which can be used to plot a bounding ball of a BoundingBallTree in PlotlyJS. All 'kwargs' are passed to PlotlyJS.scatter or PlotlyJS.surface, respectively.

Arguments:

  • tree::H2ClusterTree: Tree
  • node: Cluster to plot.
  • kwargs: keyword arguments passed to PlotlyJS
source
H2Trees.traceball β€” Method
traceball(center::SVector{D,T}, radius; n=30, kwargs...) where {D,T}

Returns a trace, which can be used to plot a bounding ball in PlotlyJS. All 'kwargs' are passed to PlotlyJS.scatter or PlotlyJS.surface, respectively.

Arguments:

  • center: Center of the bounding ball.
  • radius: Radius of bounding ball.
  • kwargs: keyword arguments passed to PlotlyJS
source
H2Trees.tracecube β€” Method
tracecube(tree::H2ClusterTree, node::Int; kwargs...)

Returns a trace, which can be used to plot a cluster of a TwoNTree in PlotlyJS. All 'kwargs' are passed to PlotlyJS.scatter or PlotlyJS.scatter3d, respectively.

Arguments:

  • tree::H2ClusterTree: tree
  • node::Int: Cluster to plot
  • kwargs: keyword arguments passed to PlotlyJS
source
H2Trees.tracecube β€” Method
tracecube(center::SVector{D, T}, halfsize; kwargs...)

Returns a trace, which can be used to plot a bounding box in PlotlyJS. All 'kwargs' are passed to PlotlyJS.scatter or PlotlyJS.scatter3d, respectively.

Arguments:

  • center: Center of the bounding box.
  • halfsize: Halfsize of the bounding box, which is half of the length of the edge of the bounding box.
  • kwargs: keyword arguments passed to PlotlyJS
source