carbonfly.blockmesh_writer module
Writers for OpenFOAM blockMesh configuration files.
This module provides helper functions to generate blockMeshDict files for OpenFOAM cases, based on structured geometry definitions and user-defined mesh parameters.
The generated dictionaries are intended to be used as the base mesh before further refinement steps (e.g. snappyHexMesh).
- carbonfly.blockmesh_writer.write_blockmesh_dict(case_root: Path, *, min_xyz: Tuple[float, float, float], max_xyz: Tuple[float, float, float], cells: Tuple[int, int, int] | None = None, cell_size: float | None = None, grading: Tuple[float, float, float] = (1.0, 1.0, 1.0), convert_to_meters: float = 1.0) Path[source]
Write a minimal system/blockMeshDict with a single hex block.
This helper writes a bounding-box blockMeshDict (no edges) with one patch named boundingbox (type wall) containing all six faces.
- Parameters:
case_root (Path) – Case root directory (the parent of system/).
min_xyz (Tuple[float, float, float]) – Domain min bounds (xmin, ymin, zmin) in meters.
max_xyz (Tuple[float, float, float]) – Domain max bounds (xmax, ymax, zmax) in meters.
cells (Optional[Tuple[int, int, int]]) – Explicit (nx, ny, nz). If None, computed from cell_size.
cell_size (Optional[float]) – Target cell size (m). Used only when cells is None.
grading (Tuple[float, float, float]) – simpleGrading factors (gx, gy, gz).
convert_to_meters (float) – OpenFOAM convertToMeters (default 1.0).
- Returns:
Path to the written system/blockMeshDict.
- Return type:
Path
- Raises:
ValueError – If bounds are invalid or cell_size <= 0.