polyfoammesh.commercial.parallel_mesh
Parallel meshing engine using MPI + cartesianMesh’s own -parallel mode.
Runs cartesianMesh across N MPI ranks and reconstructs the result — real wall-clock speedup on multi-core machines.
This is NOT decomposePar-based domain decomposition: decomposePar splits an EXISTING mesh/fields for parallel SOLVING, and requires a mesh to already exist — at this point in the pipeline there is no mesh yet, since generating one is the whole point. cartesianMesh’s own -parallel flag does the geometry-based decomposition internally; it only needs each processorN/ directory to exist with its own copy of the case’s system/ and constant/ input files (confirmed live: without them, cartesianMesh -parallel fails with “cannot open case directory processorN”).
- Pipeline:
Write meshDict (cell sizes, BL, patch names) to the Windows case dir
Clean residual /tmp/cfmesh_parallel_* from previous killed runs
Clean residual processorN/ dirs from previous runs
build_parallel_command() copies system/+constant/ into a native WSL tmpfs (/tmp/cfmesh_parallel_XXXXX) and runs mpirun there — this avoids SIGSEGV from mmap on /mnt/c (Windows filesystem).
reconstructParMesh inside tmpfs, then copies back constant/polyMesh and per_rank_cells.txt
Collect per-rank cell counts from per_rank_cells.txt
Classes
|
Parameters for domain decomposition. |
|
Parallel meshing engine using MPI + cartesianMesh's own -parallel mode. |
|
Exceptions
Raised inside ParallelMeshEngine when cancel() is called mid-run. |
- exception polyfoammesh.commercial.parallel_mesh.CancelledError[source]
Bases:
RuntimeErrorRaised inside ParallelMeshEngine when cancel() is called mid-run.
- class polyfoammesh.commercial.parallel_mesh.DecomposeParams(method='scotch', n_cores=4, preserve_patches=<factory>, overlap=0)[source]
Bases:
objectParameters for domain decomposition.
- class polyfoammesh.commercial.parallel_mesh.ParallelMeshResult(success=False, case_dir='', n_cores=0, cell_count=0, cell_count_per_rank=<factory>, warnings=<factory>, errors=<factory>, wall_time_seconds=0.0)[source]
Bases:
object- Parameters:
- class polyfoammesh.commercial.parallel_mesh.ParallelMeshEngine(of_config=None)[source]
Bases:
objectParallel meshing engine using MPI + cartesianMesh’s own -parallel mode.
Usage:
pe = ParallelMeshEngine(of_config) pe.setup_case(case_dir, n_cores=8) result = pe.run()
- Parameters:
of_config (OFConfig | None)
- MAX_CORES = 128
- MIN_CORES = 2
- cancel()[source]
Request cancellation of a running meshing operation. Sets an internal event that is polled between steps and during the blocking subprocess call (via Popen + polling loop). Also cleans up stray WSL processes and orphaned tmp dirs.
- Return type:
- run()[source]
Execute the parallel meshing workflow.
- Return type:
- Steps:
Kill stray MPI processes from previous runs
Clamp core count to available WSL2 memory
Clean orphaned /tmp/cfmesh_parallel_* from killed runs
Clean residual processorN/ dirs from previous runs
Write meshDict (cell sizes, BL, patch names)
Run cartesianMesh -parallel via tmpfs bash script
Collect per-rank cell counts from per_rank_cells.txt
Standalone reconstruct fallback (if bundled one didn’t run)