The module phi.geom integrates geometric shapes and supports differentiable volumes.
Geometry serves as a base for all geometry objects, such as boxes or spheres.
All properties of
Geometry support the use of batch, instance and spatial dimensions.
The corresponding values take the type of Φ-tensors.
This allows a single
Geometry object to describe a collection of shapes with varying properties.
.shape: Shapeall batch and spatial dimensions
.rank: intnumber of spatial dimensions the geometry lives in
.center: Tensorcenter points of shape (
lies_inside(location)tests if the given points lie inside the geometry
approximate_signed_distance(location)computes the distance of the given points from the surface
approximate_fraction_inside(Geometry)computes the overlap between two geometries.
Geometries can be checked for equality using
They should generally be treated as immutable.
All built-in basic geometry types support n-dimensional spaces.
Spheres has two defining properties:
.center: Tensorhas a single channel dimension called ‘vector’.
.radius: Tensorhas no channel dimension
Boxes come in multiple variants:
Boxstores the lower and upper corner of the box.
Cuboidstores the center position and half-size.
GridCellis similar to
Cuboidbut its spatial dimensions are guaranteed to span a regular grid
Points have zero volume and are only characterized by their location.
Geometries can be inverted using the
~ operator, i.e. the results of
approximate_fraction_inside return the inverse values.
GeometryStack(geometries, axis) allows the type of
Geometry to vary along a dimension.
Geometry objects are not Fields.
However, some sampling operations like
CenteredGrid.sample() also accept
HardGeometryMask represent fields that take the value
1 inside the geometry and
The hard version always returns 0 or 1 while the soft version returns continuous values when volume-sampled.