volumential.tree_interactive_build#

Interactive box-tree construction for adaptive volume FMM meshes.

This module owns the compatibility layer between volumential and the current upstream boxtree tree-of-boxes data structures. It provides:

  • BoxTree, a mutable box tree that can be refined and coarsened in place while keeping a 2:1 level restriction, along with device-side views of its levels, centers and leaf boxes;

  • QuadratureOnBoxTree, tensor-product quadrature on the leaf boxes of such a tree; and

  • build_particle_tree_from_box_tree(), which converts a box tree plus its quadrature nodes into a boxtree.Tree suitable for FMM traversal.

The private helpers in between rebuild, prune and balance tree-of-boxes objects by their level/grid-index keys rather than by box id, which is what makes refinement and coarsening reproducible.

class volumential.tree_interactive_build.BoxTree[source]#

Bases: object

Compatibility wrapper for the old boxtree interactive build API.

This vendors the small portion of the old xywei/boxtree API that volumential relied on for adaptive mesh generation, while using current upstream boxtree.tree_of_boxes data structures internally.

generate_uniform_boxtree(queue, root_vertex=array([0., 0.]), root_extent=1, nlevels: int = 1, box_id_dtype=<class 'numpy.int32'>, box_level_dtype=<class 'numpy.int32'>, coord_dtype=<class 'numpy.float64'>) → None[source]#

Build a uniformly refined box tree of nlevels levels.

refine_and_coarsen(refine_flags, coarsen_flags, error_on_ignored_flags: bool = False) → None[source]#

Refine and coarsen the tree in place, then restore level restriction.

Refinement is applied first; coarsening intents are tracked by parent box path so that they survive the renumbering that refinement causes.

property dimensions: int#

Spatial dimension of the tree.

property nboxes: int#

Total number of boxes, leaf and non-leaf.

property nlevels: int#

Number of levels present in the tree.

property n_active_boxes: int#

Number of leaf boxes.

get_box_extent(ibox) → tuple[ndarray, ndarray][source]#

Return the (low, high) corners of box ibox.

class volumential.tree_interactive_build.QuadratureOnBoxTree(boxtree: BoxTree, quadrature_formula=None)[source]#

Bases: object

Tensor-product quadrature on the leaf boxes of a BoxTree.

get_q_points(queue)[source]#

Return the quadrature nodes as device arrays, one per axis.

get_q_weights(queue)[source]#

Return the quadrature weights, scaled by each leaf box measure.

get_cell_centers(queue)[source]#

Return the leaf box centers as device arrays, one per axis.

get_cell_measures(queue)[source]#

Return the leaf box measures (volumes) as a device array.

volumential.tree_interactive_build.build_particle_tree_from_box_tree(actx, box_tree, q_points_host)[source]#

Convert a BoxTree and its quadrature nodes into a particle tree.

The returned boxtree.Tree places every leaf box’s quadrature nodes in one contiguous run, ordered by a depth-first walk over the leaves, so that box source/target ranges are exact and no particle sorting is needed.

Parameters: