carbonfly.postproc module
Post-processing helpers for OpenFOAM cases.
This module provides utilities to configure, run, and collect results from OpenFOAM post-processing workflows using internal probes. internalProbes commonly used for sampling scalar and vector fields along points or lines.
- carbonfly.postproc.collect_internal_probes_results(case_root: str | Path, which: str | int = 'latest') Dict[str, Any][source]
Read one sampled result from postProcessing/internalProbes/<time>/points.xy.
- Parameters:
case_root (str | Path) – OpenFOAM case root directory.
which (str | int) – Select which time-folder to read. - “latest” or “last”: read the last (usually largest) time directory - int >= 0: read the N-th directory in sorted order (0 = first) - int < 0: read from the end (-1 = last, -2 = second last, …)
- Returns:
- {
“time_dir”: “<time directory name, e.g. ‘2000’>”, “data”: {
”columns”: […], “points”: […], “distance”: […], “scalars”: {…}, “vectors”: {…}, “raw_rows”: […],
}
}
- Return type:
Dict[str, Any]
- carbonfly.postproc.run_internal_probes_postprocess(case_root: str | Path, *, foam_bashrc: str = '/opt/openfoam10/etc/bashrc', distro: str | None = None, time_selector: str | None = None, log_rel: str = 'system/internalProbes.run.log') int[source]
Call postProcess -func internalProbes in WSL for an existing case.
- Parameters:
case_root (str | Path) – Windows path to the case directory.
foam_bashrc (str) – OpenFOAM bashrc path inside WSL.
distro (str | None) – WSL distro name if needed.
time_selector (str | None) –
None: no time option (process all)
”latestTime” / “latest” / “last”: add -latestTime
”100”: add -time 100
”0:100”: add -time 0:100
log_rel (str) – Log path (relative to case root).
- Returns:
Process return code.
- Return type:
int
- carbonfly.postproc.write_internal_probes_dict(case_root: str | Path, *, points: Iterable[Iterable[float]], fields: Iterable[str], ordered: bool = True, filename: str = 'internalProbes') Path[source]
Create/overwrite system/internalProbes for post-processing.
- Parameters:
case_root (str | Path) – Case folder on Windows, e.g. r”C:DataCarbonflycase_name”.
points (Iterable[Iterable[float]]) – Probe points as (x, y, z) tuples/lists.
fields (Iterable[str]) – Field names to sample, e.g. (“CO2”, “T”, “U”).
ordered (bool) – If True, set ordered yes; so output order matches input order.
filename (str) – Output filename under system/. Default is “internalProbes”.
- Returns:
Path to the created dict (Windows path).
- Return type:
Path