visualdynamics.core.tetmesh¶
tetmesh
¶
Tetrahedral meshing of a geometry's solids, from their recipe.
Mesh Solids meshes an extrusion into bricks (solids.extrusion_mesh).
A part that is not one, a hole drilled at an angle, cylinders along
three axes, is meshed here into tetrahedra, from the recipe's signed
distance (solids.distance) alone: nothing about the shape is assumed
beyond where its surface is and which way is out.
The method is the one of Persson and Strang (2004). Points are laid on a body-centered lattice inside the solid, with points fixed along its sharp edges and at its corners; every edge of their Delaunay triangulation pushes its ends apart when shorter than the length aimed at; a point pushed out of the solid is put back onto its surface along the distance's gradient; and the triangulation is made again when the points have moved enough to need it. The relaxation ends when the points have settled, and the tetrahedra whose centroids fall outside the solid are dropped.
Sharp edges are found from the recipe: each block gives six planes, each cylinder a wall and two caps, and an edge is a curve where two of them cross on the solid's surface, a corner a point where three do. Points are placed along the curves a mesh size apart and held there, so the mesh keeps every edge the recipe has and rounds nothing off.
The elements are ten-node tetrahedra (type 118): the corners, then the midside nodes of edges 1-2, 2-3, 1-3, 1-4, 2-4, 3-4, those on a curved wall moved onto it. Four-node ones (type 111) are made on request.
Functions:
| Name | Description |
|---|---|
tet_count |
About how many tetrahedra |
tet_mesh |
The parts as tetrahedra, ready to join to a geometry |
sharp_edges |
The points |
Classes¶
Functions:¶
tet_count
¶
About how many tetrahedra tet_mesh would make for these parts
at size: their volume, read by sampling, over the cube of the
size, times what a relaxed lattice packs into that. Within a
quarter or so; the pane reads it to 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
|
|
Source code in src/visualdynamics/core/tetmesh.py
tet_mesh
¶
tet_mesh(geometry: Any, ids, size: float, quadratic: bool = True, progress: Any = None, keep_slivers: bool = False) -> tuple[Any, dict]
The parts as tetrahedra, 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); an element goes to the part whose recipe holds its centroid, 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, and a mesh of more than MESH_LIMIT tetrahedra by
tet_count's estimate.
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 aimed at, as the geometry holds its coordinates: the edge length the relaxation settles to. |
required |
quadratic
|
bool
|
Ten-node tetrahedra; False for four-node ones. |
True
|
progress
|
callable
|
Told |
None
|
keep_slivers
|
bool
|
Keep the slivers that lie in the surface rather than remove
them. Removed, each leaves a shallow dimple, and the surface
pinches along an edge there; kept, the mesh's outer faces are
the surface whole, which is what a shell mesh of it wants
( |
False
|
Returns:
| Type | Description |
|---|---|
(Geometry, dict)
|
The tetrahedra, in the geometry's length unit; and what was made: 'tets' and 'nodes', the counts; 'steps', how many the relaxation took; 'quality', the least radius ratio (1 for a regular tetrahedron, 0 for a flat one); 'poor', how many are under 0.3; 'slivers', how many were removed from the surface; and 'shortest', the shortest edge. |
Source code in src/visualdynamics/core/tetmesh.py
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 206 207 208 209 210 211 212 213 214 215 216 | |
sharp_edges
¶
The points tet_mesh holds fixed: the parts' corners, and points
about size apart along every sharp edge of their surface.
The surfaces are read from the recipe, each block's six planes and each cylinder's wall and caps, unbounded; a sharp edge is where two of them cross on the solid's surface, a corner where three do. Points seeded on one surface are moved onto the other and back until they sit on both, kept where the solid's distance is zero there, and thinned to the size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Geometry
|
Whose solids. |
required |
ids
|
sequence of int
|
The parts, by id. |
required |
size
|
float
|
The mesh size: the spacing along an edge. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
(n, 3), the corners first. |
Source code in src/visualdynamics/core/tetmesh.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |