polyfoammesh.core.meshdict_gen
Generate meshDict for cfMesh v2512.
- This is the file cfMesh/cartesianMesh reads to decide:
what surface to mesh (surfaceFile)
global cell size constraints (maxCellSize, minCellSize)
per-patch cell size overrides (patchCellSize)
boundary refinement (boundaryCellSize + boundaryCellSizeRefinementThickness)
boundary layers (boundaryLayers > patchBoundaryLayers > regex > { nLayer, … })
Syntax verified against the official OpenFOAM v2512 tutorials at /usr/lib/openfoam/openfoam2512/tutorials/…/meshDict.
Functions
|
Build meshDict content for cfMesh v2512. |
|
Build |
|
Map a patch name to the OpenFOAM boundary type cfMesh should assign. |
|
- polyfoammesh.core.meshdict_gen.infer_patch_type(patch_name)[source]
Map a patch name to the OpenFOAM boundary type cfMesh should assign.
cfMesh types EVERY patch as wall unless a renameBoundary block says otherwise. A patch typed wall cannot carry an inlet/outlet boundary condition — the solver (and BaramFlow) treat it as a solid surface — so without this the generated mesh is geometrically fine but physically unusable.
- polyfoammesh.core.meshdict_gen.build_object_refinements(high_curvature_regions=None)[source]
Build
objectRefinementsblock for cfMesh meshDict.Two zone schemas are accepted, so the pipeline-level zones (throat auto-refinements) and the 3D-viewer refinement boxes can coexist in the same list:
zone schema
{centre: (x,y,z), radius: float, cell_size: float}— legacy/auto zones.radiusis the half-diagonal; emitted as a cube of side2*radius.box schema
{xmin,xmax,ymin,ymax,zmin,zmax, cell_size: float}— placed with the in-viewer drag gizmo (refinement_boxes.py). Emitted as the real axis-aligned box it represents (centre = midpoint, lengthX/Y/Z = actual extents), so a non-cube box keeps its shape.
A malformed entry (missing keys, a NaN/zero cell size, non-numeric coords) never aborts the run: it is skipped with a log warning and the valid zones are still written. Returns empty list when nothing to refine.
- polyfoammesh.core.meshdict_gen.build_meshdict_lines(max_cell=0.05, min_cell=0.01, patch_cell_size=None, boundary_cell_size=None, boundary_refinement_thickness=None, surface_file='constant/triSurface/surface.stl', bl_params=None, patch_names=None, patch_types=None, object_refinements=None, local_refinement=None, edge_mesh_refinement=None, workflow_stop_after=None)[source]
Build meshDict content for cfMesh v2512.
- Parameters:
max_cell (
float) – global max cell size (m). Cells anywhere will be <= this.min_cell (
float) – global min cell size (m). Cells anywhere will be >= this.patch_cell_size (
dict[str,float] |None) – dict {patch_name: cell_size} for per-patch overrides. Patches NOT in this dict use the global max_cell/min_cell. Patches IN this dict get a tighter cell size (so e.g. a thin constriction gets small cells while a wide tube body keeps coarse cells).boundary_cell_size (
float|None) – cell size near boundaries (e.g. 0.5 * max_cell). If None, no boundary refinement is requested.boundary_refinement_thickness (
float|None) – distance (m) from the boundary within which boundaryCellSize applies. If None, no boundary refinement.surface_file (
str) – path to the surface STL.bl_params (
dict|None) – dict with keys nLayers, thicknessRatio, expansionRatio, wallPatches (list of patch names). If None, no boundary layers.object_refinements (
list[dict] |None) – list of dicts in either the zone schema {centre, radius, cell_size} or the 3D-box schema {type:”box”, xmin, xmax, ymin, ymax, zmin, zmax, cell_size}. If None or empty, no local refinement. Malformed entries are skipped with a warning, never fatal.local_refinement (
dict[str,dict] |None) – dict {patch_regex: {additional_refinement_levels: N, refinement_thickness: metres}} — refines the VOLUME of cells within refinement_thickness of the named patches by N octree levels (cfMesh’s native currency: LEVELS, not absolute metres — see commit 9904d65 for why absolute sizes crash the octree). Distinct from patch_cell_size (which fixes size ON the faces). Each entry validated; malformed entries are skipped with a warning, never fatal.edge_mesh_refinement (
list[dict] |None) – list of dicts {edge_file: path, levels: N} — refines cells near feature edges read from an OpenFOAM edgeMesh file (eMesh/obj/vtk — NOT the .fms surface format, which cartesianMesh rejects: “Unknown edge format fms”, verified against the installed binary). If None, no edge refinement.workflow_stop_after (
str|None) – step name to stop after (cfMesh workflowControls stopAfter; e.g. “refineBoundaryLayers”). If None, no workflow controls block is written.
- Return type:
- polyfoammesh.core.meshdict_gen.write_meshdict(case_dir, max_cell_size=0.05, min_cell_size=0.01, patch_cell_size=None, boundary_cell_size=None, boundary_refinement_thickness=None, surface_file='constant/triSurface/surface.stl', bl_params=None, patch_names=None, patch_types=None, object_refinements=None, local_refinement=None, edge_mesh_refinement=None, workflow_stop_after=None, max_cells_override=None)[source]