MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / bb_tree

Function bb_tree

python/dolfinx/geometry.py:117–151  ·  view source on GitHub ↗

Create a bounding box tree for use in collision detection. Args: mesh: The mesh. dim: Dimension of the mesh entities to build bounding box for. padding: Padding for each bounding box. entities: List of entity indices (local to process). If not supplie

(
    mesh: Mesh[Real],
    dim: int,
    *,
    padding: float = 0.0,
    entities: npt.NDArray[np.int32] | None = None,
)

Source from the content-addressed store, hash-verified

115
116
117def bb_tree(
118 mesh: Mesh[Real],
119 dim: int,
120 *,
121 padding: float = 0.0,
122 entities: npt.NDArray[np.int32] | None = None,
123) -> BoundingBoxTree[Real]:
124 """Create a bounding box tree for use in collision detection.
125
126 Args:
127 mesh: The mesh.
128 dim: Dimension of the mesh entities to build bounding box for.
129 padding: Padding for each bounding box.
130 entities: List of entity indices (local to process). If not
131 supplied, all owned and ghosted entities are used.
132
133 Returns:
134 Bounding box tree.
135
136 """
137 map = mesh.topology.index_map(dim)
138 if map is None:
139 raise RuntimeError(f"Mesh entities of dimension {dim} have not been created.")
140
141 dtype = mesh.geometry.x.dtype
142 if np.issubdtype(dtype, np.float32):
143 return BoundingBoxTree(
144 _cpp.geometry.BoundingBoxTree_float32(mesh._cpp_object, dim, padding, entities)
145 )
146 elif np.issubdtype(dtype, np.float64):
147 return BoundingBoxTree(
148 _cpp.geometry.BoundingBoxTree_float64(mesh._cpp_object, dim, padding, entities)
149 )
150 else:
151 raise NotImplementedError(f"Type {dtype} not supported.")
152
153
154def compute_collisions_trees(

Calls 2

BoundingBoxTreeClass · 0.70
index_mapMethod · 0.45