polyfoammesh.core.boundary_reader

Functions

count_cells(case_dir)

count_faces(case_dir)

count_points(case_dir)

parse_boundary(boundary_path)

rename_boundary_patch(case_dir, old_name, ...)

Rename a patch in constant/polyMesh/boundary and back the file up.

rename_patch_in_fields(case_dir, old_name, ...)

Rename the patch entry in every 0/ field's boundaryField block.

Classes

PatchInfo(name, patch_type, n_faces, start_face)

class polyfoammesh.core.boundary_reader.PatchInfo(name, patch_type, n_faces, start_face)[source]

Bases: object

Parameters:
  • name (str)

  • patch_type (str)

  • n_faces (int)

  • start_face (int)

name: str
patch_type: str
n_faces: int
start_face: int
polyfoammesh.core.boundary_reader.rename_boundary_patch(case_dir, old_name, new_name)[source]

Rename a patch in constant/polyMesh/boundary and back the file up.

The generated-mesh rename path (the mandate’s “rinominare dopo il meshing”): validates the new name (non-empty, no structural/quote/whitespace chars, not already in use), copies boundary to boundary.bak (only if no backup exists yet, so the ORIGINAL is never overwritten), then rewrites the single standalone patch-name line. Everything else in the file — nFaces, startFace, type, physicalType, inGroups — is preserved byte-for-byte.

Raises FileNotFoundError when the case has no boundary file and ValueError on an invalid/missing/duplicate name.

Return type:

Path

Parameters:
polyfoammesh.core.boundary_reader.rename_patch_in_fields(case_dir, old_name, new_name)[source]

Rename the patch entry in every 0/ field’s boundaryField block.

Renaming only constant/polyMesh/boundary is not enough: a field that still lists the old patch name makes OpenFOAM (and BaramFlow) abort on load with “cannot find patchField entry for <patch>”, and the BaramFlow export validation refuses the case (user report: missing-files popup after renaming patches). Each touched file is backed up to <name>.bak once, like the boundary rewrite does. Best effort: unreadable files are skipped. Returns the files changed.

Return type:

list[Path]

Parameters:
polyfoammesh.core.boundary_reader.parse_boundary(boundary_path)[source]
Return type:

list[PatchInfo]

Parameters:

boundary_path (Path | str)

polyfoammesh.core.boundary_reader.count_cells(case_dir)[source]
Return type:

int

Parameters:

case_dir (Path | str)

polyfoammesh.core.boundary_reader.count_points(case_dir)[source]
Return type:

int

Parameters:

case_dir (Path | str)

polyfoammesh.core.boundary_reader.count_faces(case_dir)[source]
Return type:

int

Parameters:

case_dir (Path | str)