The mesh_report_parsers.py module#
Summary#
Extract the three headline quality numbers from a |
|
Extract structured fields from a |
Description#
Pure-functional parsers for Fluent’s mesh.check and mesh.quality reports.
These commands print a human-readable block to the Fluent transcript/console.
PyFluent forwards that print stream to Python’s stdout, which
ansys.fluent.mcp.solve.backends.pyfluent.PyFluentBackend.run_code()
captures into RunCodeResult.stdout via
contextlib.redirect_stdout. The following parsers take that captured
text and extract structured numbers/lists.
Why parse instead of using a programmatic API:
mesh.checkandmesh.qualityare settings-API commands. They returnNoneand emit their result to the console. There is no structured return value across the supported Fluent versions. (Newer PyFluent versions have experimental structured reports undersolver.report.*, but the names have churned across the 24.x / 25.x) releases.The transcript wording for the headline lines cared about (
Minimum Orthogonal Quality/Maximum Ortho Skew/Maximum Aspect Ratio/Volume statistics/Face area statistics/Domain Extents) has been stable since Fluent 19.0. Extra histograms/hints below the headline lines are version-dependent and ignored.
Fluent 2024 and later formats notes (verified against a real session):
mesh.qualitytypically prints onlyMinimum Orthogonal QualityandMaximum Aspect Ratio.Maximum Ortho Skewis often absent because Fluent treats orthogonal quality as the canonical cell-quality metric (orthogonal quality ≈ 1 − ortho-skew, so the two are redundant). The parser returnsNonefor the missing field. Callers MUST treatNoneasunknownand rely onmin_orthogonal_qualityas the primary signal.The headline lines now include trailing annotations like
cell. These are ignored by design. Only the number to the right of theon zone (ID: on partition: )
at location (x, y, z)=is captured.mesh.checkmay indent theVolume statistics:andFace area statistics:headers with one leading space and use single-space separators betweentotal volumeand(m3). The regex whitespace classes (\\s+,\\s*) tolerate both styles.
Both parsers are intentionally lenient. Anything that cannot be matchd
collapses to None rather than raising. Callers are expected to
treat None as unknown, never as a passing score.
Tested against transcripts from both pressure-based and density-based
solvers in tests.test_mesh_report_parsers.
Module detail#
- mesh_report_parsers.parse_mesh_quality(stdout: str | None) dict[str, float | None]#
Extract the three headline quality numbers from a
mesh.qualityreport.The returned mapping contains
"min_orthogonal_quality","max_ortho_skew", and"max_aspect_ratio". A value isNonewhen the line is not found instdout(no mesh loaded, command failed, transcript capture truncated). Never raises.
- mesh_report_parsers.parse_mesh_check(stdout: str | None) dict[str, Any]#
Extract structured fields from a
mesh.checkreport.Output shape is documented on
ansys.fluent.mcp.common.backend.Backend.mesh_check(). Missing fields are emitted asNone(or empty list forwarnings/errors). Never raises.The
rawfield always carries the verbatim stdout chunk so callers that need a feature this parser doesn’t extract yet can still get at it without re-running the command.