Python API overview#
The top-level cutcells package re-exports the primary C++ bindings and Python
mesh utilities. CutResult, MeshPart, EntityTable, EntityRules and
EntityQuadrature live in cutcells.part, Condition in
cutcells.conditions (re-exported as cutcells.Condition).
Mesh construction#
Name |
Purpose |
|---|---|
|
Background mesh view from coordinates, connectivity, offsets, cell types, and |
|
Convert a PyVista |
|
Structured |
|
Structured |
|
PyVista triangular rectangle mesh helper. |
|
PyVista quadrilateral rectangle mesh helper. |
|
PyVista tetrahedral box mesh helper. |
|
PyVista hexahedral box mesh helper. |
Level sets#
Name |
Purpose |
|---|---|
|
Scalar level-set function object; |
|
A level set from a callable or an |
|
The level sets it is made of, as given, or |
|
Interpolation mesh data for level-set degrees of freedom. |
|
Build level-set interpolation data. |
|
Build a named level set from mesh data and values. |
|
Interpolate a batched callback where |
|
Interpolate a batched callback where |
|
Analytic level set from Python callables (slow, for experiments). |
|
Analytic level set from a capsule holding its C struct (fast, for compiled libraries); |
|
Compiled sphere, |
|
Analytic level set from the arrays of a ShapeForest tape. |
|
Analytic level set from a ShapeForest shape, expression or tape. |
Conditions#
Name |
Purpose |
|---|---|
|
A |
|
Conditions combined: and, or. Each comparison needs parentheses. |
|
A selection built from level sets. |
|
The string of a selection for a cut of |
Cutting#
Name |
Purpose |
|---|---|
|
Classify every cell of a |
|
The same with several level sets. |
|
Deprecated alias of |
|
Low-level single-cell cutting API (straight cuts). |
|
Low-level single-cell cutting of a second-order cell. |
|
Low-level whole-mesh cutting from flat VTK arrays. |
|
Locate parent cells matching a sign or interface selection. |
cut(mesh, level_sets, ...) keyword arguments:
Argument |
Default |
Meaning |
|---|---|---|
|
|
Names of the level sets, in order; by default their own, and |
|
|
Name of a single level set (not with |
|
|
Bisections of a cell before an unproven sign counts as cut. |
|
|
Default backend of the selected parts; |
|
|
|
|
|
Lookup tables only: split pieces into simplices. |
|
|
Lookup tables only: |
|
|
Lookup tables only: template order from the level sets’ degree ( |
|
|
Lookup tables only: template order for |
|
|
Lookup tables only: template order for analytic level sets with |
The lookup-table keywords raise when given with another backend.
Cut result objects#
CutResult:
Member |
Meaning |
|---|---|
|
Number of background cells. |
|
Number of cells that some level set cuts. |
|
Number of level sets, a level set made of level sets counted as its own. |
|
Names used in selection strings; the level sets a level set made of level sets is made of are named after it ( |
|
The level sets made of level sets, by name, with their insides ( |
|
Cells that some level set cuts, ascending. |
|
Per level set and cell: 0 inside, 1 cut, 2 outside; shape |
|
The entities of dimension |
|
Facets lying in a zero set, |
|
Backend and options of the parts selected from now on (settable). |
|
Select a |
MeshPart:
Member |
Meaning |
|---|---|
|
Selected entity dimension. |
|
Number of selected cut cells. |
|
Number of cells wholly in a volume part. |
|
Selected cut cells. |
|
Cells wholly in a volume part. |
|
The entities of dimension |
|
Indices into |
|
The faces of a surface on the level sets named, such as |
|
The part’s backend and options. |
|
Quadrature rules with positive weights, one per cell; |
|
The rules on the facets, edges and vertices the part holds, once per entity: an |
|
|
|
Write the visualisation mesh to a |
mode is "full" (cut cells plus whole cells) or "cut_only". backend=None
uses the part’s backend.
EntityTable (result.entities(dim)), CSR arrays over entities and their
sharing cells:
Member |
Meaning |
|---|---|
|
Dimension and number of the entities. |
|
Per entity, its |
|
The entities’ mesh nodes in chart order (sorted; a quadrilateral’s lowest node, its lower and higher neighbours, the opposite node). |
|
The cells sharing each entity, ascending. |
|
The entity’s number in each sharing cell (Basix numbering, |
|
Per entity: bit |
|
Per entity: the vanishing level sets that change sign across it (or all, on the mesh boundary). |
|
Per sharing cell: bit |
|
Per entity: 1 on the mesh boundary. |
EntityQuadrature (part.entity_quadrature(order)): facets, ridges
(codimension 2) and vertices (3D; None in 2D), each an EntityRules;
on[dim] gives those of dimension dim. On a mesh of intervals the facets
are the vertices.
EntityRules, one rule per entity, CSR arrays:
Member |
Meaning |
|---|---|
|
Dimensions of the cells and of the entities; number of rules. |
|
Per rule, the entity’s |
|
Per rule: bit |
|
Points in the entity’s reference cell, shape |
|
Per rule, the cells sharing the entity and its number in each (Basix). |
|
Per sharing cell: its sides of the level sets vanishing on the entity. |
|
Per sharing cell, the rule’s points in its reference coordinates, shape |
Backend options#
QuadraysOptions() (set attributes after construction):
Attribute |
Meaning |
|---|---|
|
Required |
|
Relative accuracy of curved pieces: boxes are bisected while |
|
|
|
The accuracy check also compares a moment of what a mass matrix sees, a Legendre polynomial squared along each axis of the cell, relative to the piece as the measure is. A box that fails first takes twice the points on its anchored segments, then up to four points more per direction, and is bisected only if that fails too. This is what it asks of six or more points per segment; of fewer, this value to the power |
|
A box with two free coordinates that no axis certifies is split at the folds of its zero curves (where one turns along the height direction) and where two of them cross, instead of bisected; its height lines take all roots. True (default). With |
|
Curve parts in 3D cells follow the curve: arcs between the faces of the cell, split where branches cross and where a further level set vanishes, with Gauss-Legendre points in arc length. |
|
Bisection limits per level and per cell. |
|
Gauss-Legendre points per segment; 0 chooses them from the order. |
|
Record why each bisection happened ( |
|
Engine controls; see the docstrings. |
LutOptions(template_order=0, triangulate=False, triangulation="classical"):
Attribute |
Meaning |
|---|---|
|
Order k of the Pk-iso-P1 template that subdivides a cut cell, 1 to 4; 0: the highest degree of the level sets that cut the cell, 2 for analytic ones. |
|
Split the cut pieces into simplices. |
Quadrature#
Name |
Purpose |
|---|---|
|
Flat quadrature storage for points, weights, offsets, and parent cells. |
|
Rules with at most as many points as the polynomial space has; returns |
|
Generate rules for low-level cut cells. |
|
Generate rules directly from VTK-style mesh arrays and level-set values (straight cuts). |
|
Map reference quadrature points to physical space. |
|
quadrays on a single cell. |
Output and conversion#
Name |
Purpose |
|---|---|
|
Convert a |
|
Convert a CutCells |
|
Lagrange cells of the quadrays decomposition: |
|
Low-level VTK/VTU writer for flat arrays. |
|
Write level-set diagnostics from a |
|
Convert a selection expression to a compact file-safe token. |
Precision-specific aliases#
The binding exports float32 and float64 variants for many native objects,
for example MeshView_float64, CutCell_float64, QuadratureRules_float64
and cutcells.part.MeshPart_float64. The unsuffixed aliases such as
MeshView, LevelSetFunction and cutcells.part.MeshPart are the recommended
default entry points for ordinary Python workflows. The former names
HOCutResult and HOMeshPart still work but are deprecated.