morphogen.mesh.exact

Conforming meshes of the exact geometry of microstructures, without a background grid.

The level-set route of morphogen.mesh.conforming.conforming_mesh() samples the level set of a microstructure at the nodes of a regular grid: the interface is as accurate as the grid is fine, and features thinner than its spacing are lost. The meshes here are built on the geometry itself.

Faceted microstructures (polyhedral_mesh()): microstructures made of convex polyhedra that partition their box — the plates and voids of scale-rich networks, the extruded ligaments of planar ones, the cubes of fractal sponges, the slabs of laminates — give their pieces (convex_pieces()). Their faces need not match: a plate is bounded on one side by a single face, on the other by the faces of every void and plate that ends on it. The faces are grouped by plane, and the pieces facing each other across a plane share the overlay of their faces (each face clipped by those of the other side, Sutherland-Hodgman on the plane), so that every facet is shared by exactly two pieces (or lies on a face of the box); the vertices lying on the edges of a facet (T-junctions) are inserted into its loop. This face-to-face complex is split into tetrahedra (cones from the centroids of the pieces over their fanned facets, morphogen.mesh.polycrystal.initial_mesh()), and MMG remeshes it to the requested size keeping the facets between phases and the faces of the box (their edges as ridges, within a Hausdorff distance of a millionth of the size: planar facets have nothing to approximate, and its smoothing would bend them): the interfaces are those of the exact geometry, sharp edges and corners included, at any thickness.

Implicit microstructures (adaptive_mesh()): the others give their level set at any point of space (level_set_at: the signed distance to their boundary, or a function with the same zero set), and the mesh is refined where the interface needs it, without a grid. An octree of the box (morphogen.mesh.octree) splits its cells along whose lines of three points a, m, b (edges, middle lines of the faces, axes) the level set crosses zero twice (a feature thinner than the cell), crosses it once at a point that its linear interpolation misplaces by more than the Hausdorff distance (the deviation e = phi_m - (phi_a + phi_b) / 2 of the parabola through the three values, over the slope), or bends toward zero by more than that distance while the interface may be near (|phi_a| + |phi_m| or |phi_m| + |phi_b| below L l / 2, L the slope of the level set: 1 for a distance, l the length of the line): a feature hidden between the samples; or where the level set, at the zero of its linear interpolation along a segment of the cell that may be an edge of its tetrahedra (morphogen.mesh.octree.SEGMENTS), exceeds the Hausdorff distance (a kink between the ends, the medial surface of a sheet, that the parabola misses). A distance bends away from zero on the medial surfaces of the phases (the middle of a sheet), where nothing else is refined. The octree is balanced and split into tetrahedra (the six of the Kuhn triangulation in its plain cells, cones from the centres of the others over their fanned faces), then MMG discretizes the zero level set (mmg3d -ls) and remeshes the result within the Hausdorff distance, without detecting ridges by angles (the facets of the cut bend at the scale of the octree: their ridges would keep flat elements; the edges of the box are given); the nodes of the interface are finally moved onto the exact zero level set (Newton’s method along the gradient), as near as the elements allow without flipping or flattening. Periodic meshes: the octree is balanced across the periodic faces, so that opposite faces get the same triangles; their edges that the interface crosses are split at its exact zeros (or their ends moved onto them), alike on translated faces, and MMG keeps these faces as they are: they match, and their nodes lie on the interface.

morphogen.mesh.exact.TOLERANCE = 1e-09

points closer are one, faces on planes closer are coplanar

Type:

Relative tolerance of the geometry (times the largest side of the box)

morphogen.mesh.exact.face_to_face(pieces, cells, lower, upper, *, tol: float | None = None) → CellComplex[source]

The face-to-face complex of convex polyhedra partitioning the box [lower, upper] ((vertices, face offsets, labels, normals, planes) tuples, the faces counter- clockwise about their outward normals), cells[p] the cell of piece p: the overlay of the faces facing each other on every plane, the vertices on the edges of the facets inserted into their loops (see the module).

morphogen.mesh.exact.grid_boxes(labels, edges) → tuple[list, ndarray][source]

Convex pieces of a structure made of the cells of a rectilinear grid (labels: a phase per cell; edges: the coordinates of the planes of the grid along each axis): boxes of one phase each (_greedy_boxes()), and their phases.

morphogen.mesh.exact.pieces_mesh(pieces, phase, lower, upper, *, size: float, min_size: float | None = None, hausdorff: float | None = None, gradation: float = 2.0, phases: str = 'all', cells=None, thin: float | None = None, order: int = 1, periodic: bool = False, executable: str | None = None, workdir=None, timeout: float | None = None) → TetMesh[source]

Conforming tetrahedral mesh of convex pieces partitioning the box (the (vertices, face offsets, labels, normals, planes) of each, its phase): the face-to-face complex of the pieces (face_to_face()), cones from their centroids, remeshed by MMG keeping their facets and the faces of the box (every element knows its phase, and its cell when cells are given: mesh.cell). Pieces thinner than the elements (plates) get flat elements, one through their thickness, of aspect ratio size over the thickness; thin: the elements of a piece at most thin times its width (twice the radius of its largest ball) and at least min_size (default size / 10), meshed through their thickness (as many elements as the square of the ratio of the size to the thickness, per unit area). phases: "all", "solid" (phase 1) or "matrix" (phase 0); periodic: matching opposite faces (meshed alike by mmg2d, kept by MMG). hausdorff: how far MMG may move the nodes off the facets, which are planar (default 1e-6 size: not at all, the facets exact; with the usual size / 20, its smoothing bends their ridges into curves, their nodes a few thousandths of the size off the planes).

morphogen.mesh.exact.polyhedral_mesh(micro, *, size: float, by_piece: bool = False, **options) → TetMesh[source]

Conforming tetrahedral mesh of a faceted microstructure from its exact convex pieces (micro.convex_pieces(): the pieces, their phases and cells; by_piece: every element knows the cell of its piece, mesh.cell), periodic (matching faces) when the microstructure is; see pieces_mesh() for the options.

morphogen.mesh.exact.adaptive_mesh(micro, *, size: float, hausdorff: float | None = None, min_size: float | None = None, gradation: float = 1.8, phases='all', order: int = 1, periodic=None, lipschitz: float | None = None, project: bool = True, remove_islands: float | None = None, ridges: bool = False, sharp_edges: bool | None = None, retries: int = 2, executable: str | None = None, workdir=None, timeout: float | None = None) → TetMesh[source]

Conforming tetrahedral mesh of the exact implicit functions of the phases of a microstructure (micro.phase_level_sets_at; an object with a level_set_at only: its two phases), refined where they need it, without a grid (see the module).

Parameters:
  • size – Largest element size.

  • hausdorff – Largest distance between the meshed and the exact interfaces (default size / 20): the edges near the interface are split until the level set departs from its linear interpolation by at most this distance.

  • min_size – Smallest element size (default: hausdorff): features thinner than about it are meshed less accurately.

  • gradation – Largest ratio of the sizes of neighbouring elements.

  • phases – "all", "solid" (phase 1) or "matrix" (phase 0) of a structure of the phases 0 and 1; or the phases to keep (a list), of any structure.

  • order – 1 (4-node tetrahedra) or 2 (10-node tetrahedra, curved onto the interfaces by morphogen.mesh.curved.curved_mesh() when project, straight otherwise).

  • periodic – Matching opposite faces (default: when the microstructure is periodic), or three booleans: along those axes.

  • lipschitz – Bound of the slope of the level set (default: the microstructure’s lipschitz, 1 for a signed distance): the edges farther from the interface than it allows are not refined.

  • project – Move the nodes of the interface onto the exact zero level set.

  • remove_islands – Relative volume below which MMG removes isolated components (-rmc; none by default: the geometry is exact; non-periodic meshes of two phases only).

  • ridges – Let MMG detect ridges on the cut (dihedral angles above 45°): the sharp edges of the geometry (the intersections of spheres, the rims of dead leaves) stay sharp, at the price of flat elements where the facets of the cut bend at the scale of the octree (0.5 % of the elements of a sheet gyroid below a quality of 10⁻³). Off by default: those edges are rounded within the Hausdorff distance, the edges of the box kept.

  • sharp_edges – Follow the sharp edges of the phases of the structures that give their smooth pieces (implicit_pieces(): the unions of spheres and segments, their coatings and bores) with edges of the mesh: the octree is refined on the surfaces of the pieces, the box cut by each in turn, and the lines where two cuts meet kept as ridges (mesh.sharp), their nodes moved onto both surfaces. By default when two pieces of a phase meet; false rounds these edges within the Hausdorff distance. Two primitives that enter each other by less than the Hausdorff distance are in the same piece (their edge is rounded).

  • retries – Periodic meshes whose opposite faces do not match (MMG remeshes a face where the interface touches itself on it) are made again on another octree (one more root cell along each axis), up to this number of times.

morphogen.mesh.exact.exact_route(micro, grains: bool | None = None) → str[source]

How exact_mesh() meshes a microstructure: "cells" (the exact cells of Voronoi and Laguerre tessellations, grain by grain), "pieces" (exact convex pieces: faceted microstructures), "level_set" (the adaptive mesh of the exact point-wise functions of its phases, phase_level_sets_at(): the other structures, of two phases or more, the tessellations with a grain-boundary phase, and those meshed by their phases, grains false), or "" (none: the structures whose functions are those of grids only, and those whose cells carry crystal orientations but tessellations, whose meshes come from their voxel images).

morphogen.mesh.exact.exact_mesh(micro, *, size: float, min_size: float | None = None, hausdorff: float | None = None, gradation: float | None = None, phases='all', order: int = 1, periodic=None, grains: bool | None = None, sharp_edges: bool | None = None, executable: str | None = None, workdir=None, timeout: float | None = None, **options) → TetMesh[source]

Conforming tetrahedral mesh of the exact geometry of a microstructure, without a background grid (see the module): the exact cells of tessellations (morphogen.mesh.polycrystal.polycrystal_mesh()), the exact convex pieces of faceted microstructures (polyhedral_mesh()), or the adaptive mesh of the exact functions of the phases of the others (adaptive_mesh()); options go to the mesher of the route (exact_route(), which grains false turns from the cells of a tessellation to the functions of its phases). phases: "all", "solid", "matrix" or the phases to keep (a list). hausdorff: the distance of the curved interfaces of level sets to their facets; the planar facets of cells and pieces are kept, whatever it is. sharp_edges: the sharp edges of the smooth pieces of level sets (adaptive_mesh()); the edges of cells and convex pieces are those of their facets, kept.