polyfoammesh.commercial.fault_tolerant

Fault-tolerant (non-watertight) meshing workflow.

Inspired by ANSYS Fluent Meshing Fault-Tolerant Workflow. Handles CAD with gaps, overlaps, missing faces, and small features that prevent traditional watertight meshing.

Pipeline:
  1. Import geometry (even non-watertight STL with gaps/overlaps)

  2. Gap detection & analysis

  3. Gap closing (snap-merge / MeshFix repair)

  4. meshDict preparation (sizing + boundary layers)

  5. Volume fill (cartesianMesh, BL -> no-BL fallback)

  6. Quality check (checkMesh) — success requires a valid volume mesh

Classes

FaultTolerantParams([gap_h, wrap_coarsen, ...])

Parameters controlling the fault-tolerant workflow.

FaultTolerantResult([success, case_dir, ...])

FaultTolerantWorkflow([of_config])

Fault-tolerant meshing for non-watertight geometry.

GapInfo(location, gap_size[, patch_name])

Information about a detected gap in the geometry.

class polyfoammesh.commercial.fault_tolerant.GapInfo(location, gap_size, patch_name='')[source]

Bases: object

Information about a detected gap in the geometry.

Parameters:
location: tuple[float, float, float]
gap_size: float
patch_name: str = ''
class polyfoammesh.commercial.fault_tolerant.FaultTolerantParams(gap_h=0.001, wrap_coarsen=0.5, occlude_internal=True, min_feature_size=0.0005, merge_tolerance=0.0001)[source]

Bases: object

Parameters controlling the fault-tolerant workflow.

Parameters:
gap_h: float = 0.001
wrap_coarsen: float = 0.5
occlude_internal: bool = True
min_feature_size: float = 0.0005
merge_tolerance: float = 0.0001
to_dict()[source]
Return type:

dict[str, Any]

class polyfoammesh.commercial.fault_tolerant.FaultTolerantResult(success=False, case_dir='', gaps_found=0, min_gap=0.0, cells=0, warnings=<factory>, errors=<factory>, wall_time_seconds=0.0, stage='', gaps_closed=0, quality=None)[source]

Bases: object

Parameters:
success: bool = False
case_dir: str = ''
gaps_found: int = 0
min_gap: float = 0.0
cells: int = 0
warnings: list[str]
errors: list[str]
wall_time_seconds: float = 0.0
stage: str = ''
gaps_closed: int = 0
quality: Any = None
class polyfoammesh.commercial.fault_tolerant.FaultTolerantWorkflow(of_config=None)[source]

Bases: object

Fault-tolerant meshing for non-watertight geometry.

Usage:

ft = FaultTolerantWorkflow(of_config)
ft.set_geometry("path/to/dirty_geometry.stl")
ft.set_params(FaultTolerantParams(gap_h=0.002))
result = ft.run()
Parameters:

of_config (OFConfig | None)

set_geometry(path)[source]
Return type:

None

Parameters:

path (str | Path)

set_params(params)[source]
Return type:

None

Parameters:

params (FaultTolerantParams)

set_cell_sizes(max_cell, min_cell)[source]
Return type:

None

Parameters:
set_boundary_layers(n_layers, thickness_ratio, expansion_ratio)[source]
Return type:

None

Parameters:
run()[source]

Execute the fault-tolerant meshing workflow.

success=True is only set once a volume mesh actually exists on disk AND checkMesh confirms it (no fatal error, cells > 0). If checkMesh is unavailable the mesh-on-disk check alone is accepted, with a warning that quality is unverified.

Return type:

FaultTolerantResult