warp.fem.Nanogrid#
- class warp.fem.Nanogrid(
- grid,
- temporary_store=None,
- scalar_type=warp.float32,
- cell_env=None,
- env_offsets=None,
- rebuildable=False,
Sparse grid geometry.
Construct a sparse grid geometry from an in-memory NanoVDB volume.
- Parameters:
grid (Volume) – The NanoVDB volume. Any type is accepted, but for indexing efficiency an index grid is recommended. If
gridis an"on"index grid, cells will be created for active voxels only, otherwise cells will be created for all leaf voxels.temporary_store (TemporaryStore | None) – shared pool from which to allocate temporary arrays
scalar_type (type) – Scalar type for grid coordinates (
warp.float32orwarp.float64)rebuildable (bool) – Whether to retain capacity-sized topology buffers that can be refreshed with
rebuild_topology_from_cells().cell_env (array | None)
env_offsets (array | None)
Methods
boundary_side_count()build_bvh([device])Rebuild the geometry's Bounding Volume Hierarchy (BVH) for
devicefrom scratch.bvh_id(device)Return the BVH identifier for the given device, or
0if unavailable.cell_arg_value(device)cell_bvh_groups(device)Return optional per-cell BVH group indices on
device.cell_count()cell_env_arg_value(device)Return per-cell environment indices for geometry argument structs.
environment_count()fill_cell_arg(arg, device)fill_side_arg(arg, device)fill_side_index_arg(arg, device)from_environment_voxels([points, ...])Construct a sparse grid geometry from environment-tagged active voxel points.
make_filtered_cell_lookup([filter_func])rebuild(points[, point_envs, status, point_mask])Rebuild the cell grid and refresh Nanogrid topology buffers.
Refresh Nanogrid topology buffers from the current cell grid.
reference_cell()reference_side()side_arg_value(device)side_count()side_deformation_gradient(args, s)Device function returning the gradient of world position with respect to reference side
side_index_arg_value(device)side_normal(args, s)Device function returning the element normal at a sample point
supports_cell_lookup(device)update_bvh([device])Refit the geometry's BVH if it exists on
device, or build it from scratch otherwise.vertex_count()Attributes
FACE_AXIS_MASKFACE_INNER_OFFSET_BITFACE_OUTER_OFFSET_BITGRID_AXIS_FLAGSideIndexArgStructure containing arguments to be passed to device functions for indexing sides.
baseReturn the base geometry from which this geometry derives its topology.
boundary_side_indexcell_dimensionManifold dimension of the geometry cells
cell_envcell_environment_indexcell_gridcell_lookupDevice function for looking up the closest cell to a position.
cell_measure_ratiocompute_cell_bvh_groupscoords_typeWarp vector type for element coordinates matching this geometry's scalar precision.
dimensionDimension of the embedding space.
env_offsetsface_gridnameName of the geometry, including environment and scalar type suffixes.
sample_typeWarp struct type for samples matching this geometry's scalar precision.
scalar_typeside_environment_indextransformTransform matrix mapping index to world space.
vertex_gridCellArgStructure containing arguments to be passed to device functions evaluating cell-related quantities.
SideArgStructure containing arguments to be passed to device functions evaluating side-related quantities.
- classmethod from_environment_voxels(
- points=None,
- point_envs=None,
- env_count=None,
- env_offsets=None,
- *,
- point_mask=None,
- guard_cells=3,
- voxel_size=1.0,
- translation=(0.0, 0.0, 0.0),
- transform=None,
- temporary_store=None,
- scalar_type=warp.float32,
- device=None,
- rebuildable=False,
- max_active_voxels=None,
- max_leaf_nodes=None,
- max_lower_nodes=None,
- max_upper_nodes=None,
- status=None,
- cell_ijks=None,
Construct a sparse grid geometry from environment-tagged active voxel points.
The active voxel points are interpreted in local FEM space. They are packed into a single NanoVDB index grid by adding an environment offset, while FEM positions subtract the offset so environments may remain colocated in world space.
- Parameters:
points (array | Sequence[array] | None) – Flat
warp.vec3iorwarp.vec3farray of active voxel points. Deprecated: a sequence of per-environmentwarp.vec3iarrays is also accepted for compatibility.point_envs (array | Sequence[Sequence[int]] | None) – Flat
int32array with one environment index per point. Entries for unmasked points must satisfy0 <= env < env_count.env_count (int | None) – Number of environments represented by
point_envs.env_offsets (array | Sequence[Sequence[int]] | None) – Optional packed-grid offsets, one
warp.vec3iper environment. If omitted, offsets are generated along the x axis with at least one guard region between consecutive environments. Generated offsets are recomputed from the active point ranges during multi-environment rebuilds. Custom offsets are an advanced override for callers that need deterministic packed NanoVDB coordinates, for example to match an externally built volume. They must still keep active cells from different environments from sharing packed-grid faces.point_mask (array | None) – Optional
int32array with one entry per point. Points with a zero mask value are ignored.guard_cells (int) – Number of empty packed cells between generated environment tiles. The default isolates padded B-spline node grids up to degree 3.
voxel_size (int | float | Sequence[float] | None) – Voxel size for the packed NanoVDB volume. Ignored if
transformis provided.translation – Translation between packed index and world spaces.
transform – Linear transform between packed index and world spaces.
temporary_store (TemporaryStore | None) – Shared pool from which to allocate temporary arrays.
scalar_type (type) – Scalar type for grid coordinates (
warp.float32orwarp.float64).device – CUDA device on which to build the packed volume.
rebuildable (bool) – Whether to allocate persistent capacity for rebuilds.
max_active_voxels (int | None) – Maximum number of active voxels for rebuilds. Defaults to the packed cell count.
max_leaf_nodes (int | None) – Maximum number of NanoVDB leaf nodes for rebuilds. Defaults to
max_active_voxels.max_lower_nodes (int | None) – Maximum number of lower internal nodes for rebuilds. Defaults to
max_leaf_nodes.max_upper_nodes (int | None) – Maximum number of upper internal nodes for rebuilds. Defaults to
max_lower_nodes.status (array | None) – Optional one-element
uint32array receiving rebuild status flags.cell_ijks (Sequence[array] | None) – Deprecated keyword alias for the old per-environment
pointssequence form.
- rebuild(
- points,
- point_envs=None,
- *,
- status=None,
- point_mask=None,
Rebuild the cell grid and refresh Nanogrid topology buffers.
Space topologies built from this Nanogrid are not refreshed automatically. Reusing a topology after rebuilding the grid is unsupported unless that topology provides and has had its own rebuild method called.
- Parameters:
points (array) – Active voxel points. When
point_envsis provided, points are interpreted in local environment space and packed throughenv_offsetsbefore rebuilding the cell grid.point_envs (array | None) – Optional
int32array with one environment index per point. Required for multi-environment Nanogrids. Entries for unmasked points must satisfy0 <= env < environment_count.status (array | None) – Optional one-element
uint32array receiving rebuild status flags.point_mask (array | None) – Optional
int32array with one entry per point. Points with a zero mask value are ignored.
- Returns:
The status array passed to
status, orNoneif no status array was provided.- Return type:
array | None
- rebuild_topology_from_cells()[source]#
Refresh Nanogrid topology buffers from the current cell grid.
Space topologies built from this Nanogrid are not refreshed automatically. Reusing a topology after rebuilding the grid is unsupported unless that topology provides and has had its own rebuild method called.
- cell_position = <Function Nanogrid__cell_position(args: Any, s: Any)>#
- cell_deformation_gradient = <Function Nanogrid__cell_deformation_gradient(args: Any, s: Any)>#
- cell_inverse_deformation_gradient = <Function Nanogrid__cell_inverse_deformation_gradient(args: Any, s: Any)>#
- cell_coordinates = <Function Nanogrid__cell_coordinates(args: Any, cell_index: int, pos: Any)>#
- cell_closest_point = <Function Nanogrid__cell_closest_point(args: Any, cell_index: int, pos: Any)>#
- side_position = <Function Nanogrid__side_position(args: Any, s: Any)>#
- side_inner_inverse_deformation_gradient = <Function Nanogrid__side_inner_inverse_deformation_gradient(args: Any, s: Any)>#
- side_outer_inverse_deformation_gradient = <Function Nanogrid__side_outer_inverse_deformation_gradient(args: Any, s: Any)>#
- side_measure_ratio = <Function Nanogrid__side_measure_ratio(args: Any, s: Any)>#
- side_inner_cell_index = <Function Nanogrid__side_inner_cell_index(args: Any, side_index: int)>#
- side_outer_cell_index = <Function Nanogrid__side_outer_cell_index(args: Any, side_index: int)>#
- side_inner_cell_coords = <Function Nanogrid__side_inner_cell_coords(args: Any, side_index: int, side_coords: Any)>#
- side_outer_cell_coords = <Function Nanogrid__side_outer_cell_coords(args: Any, side_index: int, side_coords: Any)>#
- side_from_cell_coords = <Function Nanogrid__side_from_cell_coords(args: Any, side_index: int, element_index: int, element_coords: Any)>#
- side_coordinates = <Function Nanogrid__side_coordinates(args: Any, side_index: int, pos: Any)>#