TwoNTree

The TwoNTree is a 2ⁿ-tree for organizing points in ℝⁿ. In the case of three-dimensional points, this results in an octree. The TwoNTree can be constructed from a set of points and a minimum halfsize. Additionally, the minvalues parameter can be set to control the subdivision of the tree. A box is only further subdivided if it contains at least minvalues points.

In the Galerkin case, the tree can be constructed as follows

m = meshsphere(1.0, 0.1)
tree = TwoNTree(vertices(m), 0.1; minvalues=60)
TwoNTree{3, BoxData{3, Float64}, Float64}
 level: 1 with 1 node(s) with on average 1610.0 points and 8.0 children and halfsize: 1.6
- level: 2 with 8 node(s) with on average 201.25 points and 4.0 children and halfsize: 0.8
-- level: 3 with 32 node(s) with on average 50.31 points and 1.03 children and halfsize: 0.4
--- level: 4 with 33 node(s) with on average 19.06 points and 0.0 children and halfsize: 0.2

Alternatively, the tree can be constructed with a minimum halfsize of 0:

m = meshsphere(1.0, 0.1)
tree = TwoNTree(vertices(m), 0.0; minvalues=60)
TwoNTree{3, BoxData{3, Float64}, Float64}
 level: 1 with 1 node(s) with on average 1610.0 points and 8.0 children and halfsize: 1.0
- level: 2 with 8 node(s) with on average 201.25 points and 7.12 children and halfsize: 0.5
-- level: 3 with 57 node(s) with on average 28.25 points and 0.0 children and halfsize: 0.25

In the Petrov-Galerkin case, the tree can be constructed by providing two sets of points

using CompScienceMeshes
using H2Trees

mx = meshsphere(1.0, 0.1)
my = meshsphere(2.0, 0.1)

tree = TwoNTree(vertices(mx), vertices(my), 0.1)
BlockTree{TwoNTree{3, BoxData{3, Float64}, Float64}}(TwoNTree{3, BoxData{3, Float64}, Float64}
 level: 2 with 1 node(s) with on average 1610.0 points and 8.0 children and halfsize: 1.6
- level: 3 with 8 node(s) with on average 201.25 points and 4.0 children and halfsize: 0.8
-- level: 4 with 32 node(s) with on average 50.31 points and 3.41 children and halfsize: 0.4
--- level: 5 with 109 node(s) with on average 14.77 points and 3.3 children and halfsize: 0.2
---- level: 6 with 360 node(s) with on average 4.47 points and 0.0 children and halfsize: 0.1
, TwoNTree{3, BoxData{3, Float64}, Float64}
 level: 1 with 1 node(s) with on average 6291.0 points and 8.0 children and halfsize: 3.2
- level: 2 with 8 node(s) with on average 786.38 points and 4.0 children and halfsize: 1.6
-- level: 3 with 32 node(s) with on average 196.59 points and 3.75 children and halfsize: 0.8
--- level: 4 with 120 node(s) with on average 52.42 points and 3.35 children and halfsize: 0.4
---- level: 5 with 402 node(s) with on average 15.65 points and 3.79 children and halfsize: 0.2
----- level: 6 with 1525 node(s) with on average 4.13 points and 0.0 children and halfsize: 0.1
)

This creates a BlockTree with two TwoNTrees.

Note

The trees are configured such that both trees have the same halfsize at the same level. This means that not every tree starts at level 1.