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)

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. However, some sampling operations like CenteredGrid.sample() also accept Geometry objects.

The classes SoftGeometryMask and HardGeometryMask represent fields that take the value 1 inside the geometry and 0 outside. The hard version always returns 0 or 1 while the soft version returns continuous values when volume-sampled.