visualdynamics.core.hexmesh¶
hexmesh
¶
Brick meshing of any solid, over a grid fitted to its shape.
Mesh Solids meshes an extrusion into bricks on a grid with rings about
its holes (solids.extrusion_mesh). A part that is not an extrusion
is meshed here: a grid of cubes over it, the cubes whose centers are
inside kept, and the stair-stepped skin that leaves fitted to the
true surface. Nothing about the shape is assumed beyond its signed
distance (solids.distance) and the sharp edges read from its recipe
(tetmesh.sharp_edges).
The fitting is done in an order that keeps every brick the right way out. The skin is pillowed first: every surface node gets a twin a little way in, so each brick under the surface touches it by one face only, and a layer of new bricks lies between. The corners and sharp edges are captured by the nearest skin nodes, which are moved onto them and held; the skin between is smoothed so it runs nearly parallel to the surface it is about to meet, and then every skin node is projected onto the surface along the distance's gradient, in two stages, the inside smoothed after each. Last, every node takes the position among a few candidates that raises the worst scaled Jacobian of the bricks around it, surface nodes sliding on the surface, until no node moves.
The result has round holes and sharp edges whatever the shape, with
bricks of lower quality than a ring mesh gives: the worst scaled
Jacobian is typically between 0.15 and 0.3, and the pane reads it.
Where the parts are an extrusion, extrusion_mesh is the better mesh
and is used instead (brick_mesh).
Functions:
| Name | Description |
|---|---|
overlay_mesh |
The parts as eight-node bricks fitted to their shape, ready to |
suggested_size |
An element size at which a mesh of the parts is likely to hold: |
likely_to_fold |
Whether a fit at |
grid_cells |
How many cells the grid |
Classes¶
Functions:¶
overlay_mesh
¶
overlay_mesh(geometry: Any, ids, size: float, progress: Any = None, piece: bool = False, cuts_from=(), discard: Any = None) -> tuple[Any, dict]
The parts as eight-node bricks fitted to their shape, ready to
join to a geometry (mesh.join).
Each part gets one element group, named for it (or for its kind and id when it has no name); a brick goes to the part whose recipe holds its center, the later part where parts overlap. Parts that touch share their nodes there.
Refused: a solid that is part of another, a size that is not
positive, a mesh of more than MESH_LIMIT bricks by its volume, and
a grid of more than GRID_LIMIT cells.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id; each a solid nothing else uses. |
required |
size
|
float
|
The element size, as the geometry holds its coordinates: the grid's spacing, the block faces falling on grid planes. |
required |
progress
|
callable
|
Told |
None
|
piece
|
bool
|
The part is a union's operand meshed on its own ( |
False
|
cuts_from
|
sequence of int
|
Solids whose flat faces the grid is cut at too, the earlier pieces of a union. |
()
|
discard
|
callable
|
Given the bricks' centers, (n, 3), which bricks the caller does not want: a union's later piece inside the pieces before it. They are left out of the mesh handed back, and a fold among them is no refusal: the rod of Brandon's volume folded four bricks at its end inside the block it entered (2026-10-20). |
None
|
Returns:
| Type | Description |
|---|---|
(Geometry, dict)
|
The bricks, in the geometry's length unit; and what was made:
'bricks' and 'nodes', the counts; 'quality', the worst scaled
Jacobian (1 for a cube, 0 for a flat brick); 'poor', how many
bricks are under 0.3; 'uncaptured', how many points along the
sharp edges found no node of their own; 'sweeps', the final
smoothing's; 'off_surface', how far the farthest surface node
was let into the material to unfold a brick at a feather edge,
as a share of the size (0 when none was); 'shortest', the
shortest edge; and 'discarded', the bricks |
Source code in src/visualdynamics/core/hexmesh.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
suggested_size
¶
An element size at which a mesh of the parts is likely to hold:
for bricks fitted to a shape, the smallest radius over ACROSS
(five bricks across it, where most fits measured have held and four
has folded) and the thinnest wall over THROUGH; for tetrahedra,
three across the radius and three through the wall. With no round
feature and no wall, solids.mesh_size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
elements
|
('hexes', 'tetras')
|
The element type. |
'hexes'
|
Returns:
| Type | Description |
|---|---|
float
|
|
Source code in src/visualdynamics/core/hexmesh.py
likely_to_fold
¶
Whether a fit at size is likely to fold, read before the minutes
are spent: how many bricks the smallest round feature's radius is
across, and how many pillow bricks are flat or inside out as soon
as the grid is pillowed, before any fitting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
size
|
float
|
The element size, as the geometry holds its coordinates. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
'across', bricks across the smallest radius (inf with no round
feature); 'through', bricks through the thinnest wall (inf with
no wall); 'flat', the pillow bricks flat or inside out before
fitting, said for what it is (0, uncounted, when the grid is
past |
Source code in src/visualdynamics/core/hexmesh.py
grid_cells
¶
How many cells the grid overlay_mesh lays over these parts at
size holds, voids included: the count before anything is asked
of the shape, so a pane can decide whether to preview.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
size
|
float
|
The element size, as the geometry holds its coordinates. |
required |
Returns:
| Type | Description |
|---|---|
int
|
|