volumential.meshgen#

Box mesh generation on top of the boxtree tree-of-boxes interface.

This module owns the mesh generators that produce the quadrature nodes, weights, cell centers and cell measures a volume FMM run integrates over. MeshGenBase wraps a volumential.tree_interactive_build.BoxTree and its quadrature; the dimension-specific subclasses only pin the dimension. The module also owns the small helpers that turn a generated mesh into boxtree tree/traversal data.

volumential.meshgen.provider = 'meshgen_boxtree'#

Name of the mesh generation backend in use.

class volumential.meshgen.MeshGenBase(degree: int, nlevels: int, a=-1, b=1, queue: CommandQueue | None = None)[source]#

Bases: object

Base class for Meshgen via BoxTree. The arguments a and b can be scalars or vectors to define dim-dependent bounding boxes.

This base class cannot be used directly since the boxtree is not built in the constructor until dimension_specific_setup() is provided.

This class also implements native CL getters like get_q_points_dev() that play well with boxtree-based workflows.

dimension_specific_setup() → None[source]#

Hook for subclasses to pin the mesh dimension.

get_q_points_dev()[source]#

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

get_q_points() → ndarray[source]#

Return the quadrature nodes on the host, shape (nnodes, dim).

get_q_weights_dev()[source]#

Return the quadrature weights as a device array.

get_q_weights() → ndarray[source]#

Return the quadrature weights on the host.

get_cell_measures_dev()[source]#

Return the per-cell measures as a device array.

get_cell_measures() → ndarray[source]#

Return the per-cell measures on the host.

get_cell_centers_dev()[source]#

Return the cell centers as device arrays, one per axis.

get_cell_centers() → ndarray[source]#

Return the cell centers on the host, shape (ncells, dim).

n_cells() → int[source]#

Note that this value can be larger than the actual number of cells used in the boxtree. It mainly serves as the bound for iterators on cells.

n_active_cells() → int[source]#

Return the number of leaf cells carrying quadrature nodes.

update_mesh(criteria, top_fraction_of_cells: float, bottom_fraction_of_cells: float) → None[source]#

Refine the highest-criteria cells and coarsen the lowest-criteria ones.

Parameters:
  • criteria – One refinement indicator per active cell.

  • top_fraction_of_cells – Fraction of active cells to refine.

  • bottom_fraction_of_cells – Fraction of active cells to coarsen.

print_info(logging_func=<bound method Logger.info of <Logger volumential.meshgen (WARNING)>>) → None[source]#

Report cell and quadrature counts through logging_func.

generate_gmsh(filename) → None[source]#

Write active boxes to a Gmsh v2 ASCII mesh file.

volumential.meshgen.greet() → str[source]#

Return a greeting identifying the active meshgen backend.

volumential.meshgen.make_uniform_cubic_grid(degree: int, nlevels: int = 1, dim: int = 2, queue: CommandQueue | None = None, **kwargs) → tuple[ndarray, ndarray, None][source]#

Uniform cubic grid in [-1,1]^dim.

class volumential.meshgen.MeshGen1D(degree: int, nlevels: int, a=-1, b=1, queue: CommandQueue | None = None)[source]#

Bases: MeshGenBase

Meshgen in 1D

dimension_specific_setup()[source]#

Check that the bounds the constructor got describe a 1D box.

class volumential.meshgen.MeshGen2D(degree: int, nlevels: int, a=-1, b=1, queue: CommandQueue | None = None)[source]#

Bases: MeshGenBase

Meshgen in 2D

dimension_specific_setup()[source]#

Promote scalar bounds to a 2D box, or check that the bounds are 2D.

MeshGenBase reads the dimension off the length of the bounds it was given, so the common a=-1, b=1 call arrives here as dim == 1; widening it (and the root vertex with it) is what makes that call mean \([-1, 1]^2\).

class volumential.meshgen.MeshGen3D(degree: int, nlevels: int, a=-1, b=1, queue: CommandQueue | None = None)[source]#

Bases: MeshGenBase

Meshgen in 3D

dimension_specific_setup()[source]#

Promote scalar bounds to a 3D box, or check that the bounds are 3D.

The 3D counterpart of MeshGen2D.dimension_specific_setup().

volumential.meshgen.build_geometry_info(ctx, queue, dim: int, q_order: int, mesh, bbox=None, a=None, b=None)[source]#

Build tree, traversal and other geo info for FMM computation, given the box mesh over/encompassing the domain.

The bounding box can be specified in one of two ways: 1. via scalars a, b, dim-homogeneous ([a, b]^dim) 2. via bbox (e.g. np.array([[a1, b1], [a2, b2], [a3, b3]]))