Types
Index
PhysicalTrees.AbstractOctree2DPhysicalTrees.AbstractOctree3DPhysicalTrees.AbstractOctreeNodePhysicalTrees.AbstractOctreeNode2DPhysicalTrees.AbstractOctreeNode3DPhysicalTrees.AbstractTreePhysicalTrees.AbstractTree2DPhysicalTrees.AbstractTree3DPhysicalTrees.DomainNodePhysicalTrees.ExtNodePhysicalTrees.OctreePhysicalTrees.OctreeConfigPhysicalTrees.OctreeConfigPhysicalTrees.OctreeNodePhysicalTrees.TopNode
Tree types
PhysicalTrees.AbstractTree — TypeAbstractTree{T}Supertype of every spatial tree in PhysicalTrees.jl. The type parameter T carries the particle scalar type (e.g. Float64, Unitful.Quantity).
A tree behaves like a one-element iterable (so for t in tree yields exactly one value) and length(tree) == 1. All search / communication routines are dispatched on the abstract type.
PhysicalTrees.AbstractTree2D — TypeAbstractTree2D{T} <: AbstractTree{T}Abstract supertype of every 2D spatial tree (PVector2D data). Currently no concrete subtype is shipped — 2D construction raises an informative error from init_octree.
PhysicalTrees.AbstractTree3D — TypeAbstractTree3D{T} <: AbstractTree{T}Abstract supertype of every 3D spatial tree (PVector data). The only concrete subtype shipped today is Octree.
PhysicalTrees.AbstractOctree2D — TypeAbstractOctree2D{T} <: AbstractTree2D{T}Reserved for future 2D octree implementations. There is no concrete subtype in this version of PhysicalTrees.jl.
PhysicalTrees.AbstractOctree3D — TypeAbstractOctree3D{T} <: AbstractTree3D{T}Abstract supertype of 3D octrees. The shipped concrete subtype is Octree.
PhysicalTrees.AbstractOctreeNode — TypeAbstractOctreeNode{T}Supertype of every node stored inside an Octree's treenodes array. Subtypes must store at minimum an ID, Father, DaughterID, geometric Center, SideLength, Mass, MassCenter, and a NextNode traversal pointer — see OctreeNode for the canonical concrete node.
PhysicalTrees.AbstractOctreeNode2D — TypeAbstractOctreeNode2D{T} <: AbstractOctreeNode{T}Reserved for future 2D node implementations. No concrete subtype ships today.
PhysicalTrees.AbstractOctreeNode3D — TypeAbstractOctreeNode3D{T} <: AbstractOctreeNode{T}Supertype of all 3D octree nodes. The shipped concrete subtype is OctreeNode.
Concrete nodes
PhysicalTrees.OctreeNode — TypeOctreeNode{I<:Integer, POS, LEN, MASS} <: AbstractOctreeNode{I}Concrete 3D octree node. OctreeNode is an immutable struct, so mutation is performed through Setfield.jl / BangBang.jl's setproperties!! (used internally throughout PhysicalTrees).
Fields (see the Octree page for the data layout):
| Field | Meaning |
|---|---|
ID::I | Node id (1 = root). |
Father::I | Parent id (0 for the root). |
DaughterID::MVector{8,I} | The 8 children; 0 means "no child here". |
Center::POS | Geometric center (PVector). |
SideLength::LEN | Cube side length. |
Mass::MASS | Subtree mass (set by update). |
MassCenter::POS | Mass-weighted center. |
MaxSoft::LEN | Largest smoothing length in the subtree. |
IsAssigned::Bool | true on a leaf that owns a particle. |
ParticleID::I | Index of the assigned particle (0 if none or many). |
NextNode::I | Sibling / leaf traversal pointer. |
Sibling::I | Next node in a depth-first walk. |
BitFlag::I | Worker-locality flags (set by flag_local_treenodes). |
PhysicalTrees.TopNode — TypeTopNode{I<:Integer}Top-level node in the Peano-Hilbert decomposition of the local data (an intermediate tree built during split_domain). It records the index of its Daughter in the local top-tree array, its starting Peano key (StartKey), its Count of particles, and the Blocks it occupies. TopNodes do not depend on the spatial dimension — the same struct is reused for 2D (bits=31) and 3D (bits=21).
Fields:
Daughter::I— index of the first child in the local top-tree array (-1for the root)Pstart::Int128— Peano key of the first particle (Int128 to fit2^(3*PeanoBits3D))Blocks::Int128— number ofDomainFac * SideLengthblocks in the top-nodeLeaf::I— flag indicating this top-node is a leaf of the top-tree (1) or has children (0)Size::Int128— number of particles inside the top-nodeStartKey::Int128— Peano key where this top-node beginsCount::Int128— number of particles in the local task that fall inside this top-node
PhysicalTrees.DomainNode — TypeDomainNode{POS, VEL, MASS, LEN, B}Per-domain pseudo-particle summary exchanged between workers during update. Each domain (one Peano leaf assigned to a worker) exports its MassCenter, velocity (Vel), Mass, largest smoothing length (MaxSoft) and bit-flag to every other worker so that remote subtrees can be queried as a single pseudo-particle.
Fields:
MassCenter::POS—PVectormass-weighted center.Vel::VEL— center-of-mass velocity.Mass::MASS— total mass in the domain.MaxSoft::LEN— largest softening length in the domain.BitFlag::B— locality flags (reserved).
PhysicalTrees.ExtNode — TypeExtNode{LEN, VEL}Extra per-node aggregate that the search family reads in O(1) without touching the immutable OctreeNode itself. Indexed by the node id in the Octree's ExtNodes array and updated by update_local_data.
Fields:
hmax::LEN— largest smoothing length among descendants (used byngb_treefind_pairsto enlarge the search radius).vs::VEL— center-of-mass velocity of the subtree.
Octree
PhysicalTrees.Octree — TypeOctree{A, U, Len, Len_1, I, F, POS, VEL, MASS, B, Ext} <: AbstractOctree3D{A}The concrete 3D octree shipped by PhysicalTrees.jl. The type parameters carry the particle container (A), the unit system (U), the global length / per-axis length types (Len / Len_1), the integer / float element types (I / F), and the types used for PVector / mass / bit-flags (POS, VEL, MASS, B, Ext).
Most users should never instantiate Octree directly — call octree(data; ...) instead. The fields and their layout are documented on the Octree page.
PhysicalTrees.OctreeConfig — Typestruct OctreeConfigStores config parameters for building octree
| Parameter | type | usage | Default value |
|---|---|---|---|
NumData | <:Integer | Total number of data points | - |
MaxTopnode | <:Integer | Maximum number of topnodes | 10000 |
MaxTreenode | <:Integer | Maximum number of treenodes | 100000 |
TopnodeFactor | Int64 | Controls how many blocks that Peano-Hilbert curve is cut into while dividing computing domain | 20 |
ExtentMargin | <:AbstractFloat | Enlarge the extent a bit to make sure that all particles are inside the domain | 1.001 |
PeanoBits2D | Int64 | Peano bit length used in each axis. the last Peano key would be $2^(2*PeanoBits2D) - 1$ | 31 |
PeanoBits3D | Int64 | Peano bit length used in each axis. the last Peano key would be $2^(3*PeanoBits3D) - 1$ | 21 |
epsilon | Float64 | Controls the precision of tree leaf seperation | 1.0e-4 |
ToptreeAllocSection | <:Integer | If out of Toptree nodes, append corresponding number of empty nodes | $NumDataBase$ * $ToptreeAllocFactor$ |
TreeAllocSection | <:Integer | If out of Octree nodes, append corresponding number of empty nodes | $NumDataBase$ * $TreeAllocFactor$ |
Notes:
NumDataBaseis the decimal base of total number of data points.- Use
ToptreeAllocFactorandTreeAllocFactorto controlToptreeAllocSectionandTreeAllocSectionrespectively.
Config
PhysicalTrees.OctreeConfig — MethodOctreeConfig(NumData::Integer; ToptreeAllocFactor, MaxTopnode, TopnodeFactor,
TreeAllocFactor, MaxTreenode, ExtentMargin, PeanoBits3D, PeanoBits2D,
epsilon, Periodic, BoxSize)Constructor for OctreeConfig with sensible defaults derived from the total particle count NumData.
The allocation sections (ToptreeAllocSection / TreeAllocSection) are computed as NumDataBase * AllocFactor, where NumDataBase is the decimal base of NumData (e.g. NumData = 6000 → NumDataBase = 1000). A safety floor of 10 is applied when NumData < 100.
MaxTreenode defaults to NumData * 10 when NumData > 1000, otherwise 10000. All other knobs (BoxSize, Periodic, PeanoBits3D, …) accept the same defaults as the struct itself.
Example
cfg = OctreeConfig(6; Periodic = true, BoxSize = 2.0)