PhiFlow

Differentiable Geometry

The module phi.geom integrates geometric shapes and supports differentiable volumes.

The class 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.

Important properties:

Important methods:

Geometries can be checked for equality using == and !=. They should generally be treated as immutable.

Basic shapes

All built-in basic geometry types support n-dimensional spaces.

Spheres has two defining properties:

Boxes come in multiple variants:

Points have zero volume and are only characterized by their location.

Transformations and Operations

Translation: geometry.shift(delta)

Rotation: geometry.rotate(angle)

Union: union(geometries)

Intersection: intersection(geometries)

Geometries can be inverted using the ~ operator, i.e. the results of lies_inside, approximate_signed_distance and approximate_fraction_inside return the inverse values.

Stacking: GeometryStack(geometries, axis) allows the type of Geometry to vary along a dimension.

Integration with fields

Geometry objects are not Fields. To get a direct Field representation from a Geometry, use field.mask(). Geometries can be resampled to existing fields using field.resample(). In these cases, the field takes the value 1 inside the geometry and 0 outside.