morphogen.mesh.polyhedra

Exact cells of Voronoi and Laguerre (power) tessellations restricted to a box.

The cell of germ g_i (weight w_i) is the convex polyhedron of the points whose power distance |x - g_i|^2 - w_i is the smallest: the intersection of the half-spaces 2 (g_j - g_i) . x <= |g_j|^2 - |g_i|^2 - w_j + w_i bounded by the bisector planes of its neighbours. Each cell is computed as a half-space intersection (Qhull) with the planes of nearby germs, then checked: no other germ may be closer to one of its vertices, otherwise the missing germs are added and the cell computed again.

Restricted to the box, a tessellation is a complex of convex pieces: one per cell, or several for the cells of a periodic tessellation that cross the faces of the box (one piece per periodic image). Pieces share their facets: bisector polygons between two pieces, or polygons on the faces of the box. Vertices computed by neighbouring pieces are merged, so that the facets are shared exactly; for periodic tessellations, the vertices of opposite faces of the box are made translates of each other.

A periodic tessellation can also be taken as a set of whole cells (periodic_cells()): each cell once, around its germ in the box, uncut. Their union fills the volume of the box and tiles space by the translations of the box; its boundary is made of facets between a cell and a translate of another one, which come in pairs of translates, so that a mesh of the union naturally has matching nodes on them (periodization at the design rather than at the meshing).

morphogen.mesh.polyhedra.BOX_FACES = ((0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1))

x0, x1, y0, y1, z0, z1 (references 1 to 6).

Type:

Box faces

class morphogen.mesh.polyhedra.CellComplex(vertices: ~numpy.ndarray, facets: list[~numpy.ndarray], facet_pieces: ~numpy.ndarray, facet_box: ~numpy.ndarray, piece_cell: ~numpy.ndarray, piece_facets: list[~numpy.ndarray], lower: ~numpy.ndarray, upper: ~numpy.ndarray, periodic: bool = False, metadata: dict = <factory>, whole: bool = False, facet_shift: ~numpy.ndarray | None = None)[source]

Bases: object

Convex pieces of the cells of a tessellation restricted to a box.

facets[f] is a loop of vertex indices, counter-clockwise around the normal that points from piece facet_pieces[f, 0] to piece facet_pieces[f, 1] (-1: outside the box, for the facets on its faces). facet_box[f] is 0 inside the box, 1-6 on the faces x0, x1, y0, y1, z0, z1. piece_cell[p] is the cell (germ index) of piece p, piece_facets[p] its facets.

whole: the pieces are the whole cells of a periodic tessellation (periodic_cells()); the facets with no second piece then bound their union, and facet_shift[f] is the translation (in box lengths) of the cell beyond them.

property n_vertices: int
property n_facets: int
property n_pieces: int
facet_vectors() → tuple[ndarray, ndarray][source]

Area vectors (normal times area, oriented as the loops) and centroids.

piece_volumes() → ndarray[source]

Volumes of the pieces (divergence theorem over their facets).

cell_volumes(n_cells: int | None = None) → ndarray[source]

Volume of each cell inside the box (summed over its pieces).

grain_boundary_area() → float[source]

Area of the facets between different cells.

interface_facets() → ndarray[source]

Facets between pieces of different cells (grain boundaries).

edges() → ndarray[source]

Unique edges (sorted vertex pairs) of the facets.

summary() → dict[source]
morphogen.mesh.polyhedra.power_complex(germs, weights=None, lower=(0.0, 0.0, 0.0), upper=(1.0, 1.0, 1.0), periodic: bool = False, *, neighbours: int = 30) → CellComplex[source]

Exact cells of the power diagram of germs (Voronoi without weights) restricted to the box [lower, upper], periodic or not.

morphogen.mesh.polyhedra.periodic_cells(germs, weights=None, lower=(0.0, 0.0, 0.0), upper=(1.0, 1.0, 1.0), *, neighbours: int = 30) → CellComplex[source]

Whole cells of the periodic power diagram of germs (Voronoi without weights) of period upper - lower: one piece per non-empty cell, around its germ brought into the box (see the module). Facets between two cells of the set are shared; the others bound the union and come in pairs of translates.

morphogen.mesh.polyhedra.torus_classes(points: ndarray, lower, size, tol: float) → tuple[ndarray, ndarray][source]

Points that are translates of each other by the periods size: the class of each point and its translation (in periods) from the first point of its class.