mesh.Mesh.generate_tet_mesh_multi#

classmethod Mesh.generate_tet_mesh_multi(surfaces, tet_size=0.0, triangle_size=0.0, feature_edge_size=0.02, feature_angle=40.0, mesh_quality=2.0, geom_tolerance=0.005)#

Generate a multi-domain tetrahedral volume mesh from surfaces.

Each input tri3 surface Mesh separates two adjacent subdomains.

Parameters#

surfaceslist of (Mesh, int, int)

List defining the surfaces for multi-domain volume meshing. Each entry is a tuple (surface_mesh, domain_inside, domain_outside):

  • surface_mesh : a triangulated surface (tri3), either open or closed.

  • domain_inside : integer label of the subdomain enclosed by the surface (the side opposite to where the normals point). For closed surfaces with outward-pointing normals, this is the interior domain.

  • domain_outside : integer label of the subdomain on the side toward which the surface normals point.

Example:

  • For a closed cube representing a solid domain 1 in empty space (= domain 0): (cube_surface, 1, 0)

  • For a sphere embedded inside the cube (domain 2 inside, cube domain 1 outside): (sphere_surface, 2, 1)

tet_sizefloat, default=0.0

Maximum radius of the tetrahedra. Smaller values produce a finer volume mesh. A value of 0 disables size control.

triangle_sizefloat, default=0.0

Target size of surface triangles. Smaller values yield a finer surface approximation. A value of 0 disables size control.

feature_edge_sizefloat, default=0.02

Target edge length for feature edges. This value must be greater than zero.

feature_anglefloat, default=40.0

Angle threshold (in degrees) used to detect sharp features. Boundary edges where the angle between neighboring faces exceeds this threshold are preserved as features.

mesh_qualityfloat, default=2.0

Controls the shape quality of tetrahedral elements. Lower values enforce stricter quality requirements, while higher values allow more elongated elements. Values must be greater than or equal to 1.1.

geom_tolerancefloat, default=0.005

Maximum allowed geometric deviation between the generated surface mesh and the input geometry.

Returns#

Mesh

A tetrahedral mesh. The MeshDomain field contains subdomain labels for each tetrahedral element.

Notes#

  • Several parameters (tet_size, triangle_size, feature_edge_size, geom_tolerance) are interpreted relative to the overall dimensions of the input geometry. Internally, they are scaled by the diagonal length of the mesh bounding box.

  • This method uses CGAL: The Computational Geometry Algorithms Library.

Important

Imposing too many strict constraints can increase runtime significantly or prevent a mesh from being generated. Avoid conflicting parameter combinations, like setting tet_size too small relative to feature_edge_size or triangle_size.

See Also#

generate_tet_mesh()

Examples#

>>> cube = shapes.cuboid(eltype="tri3").centered()
>>> sphere = shapes.sphere().scale(0.2)
>>> surfaces = [
...     (cube, 1, 0),     # outer boundary
...     (sphere, 2, 1),   # inner inclusion
... ]
>>> tet = Mesh.generate_tet_mesh_multi(
...     surfaces,
...     tet_size=0.05,
...     mesh_quality=1.8,
... )
>>> set(tet.fields["MeshDomain"].data)
{1.0, 2.0}