# CFDPre ```{raw} html
CFDPre logo

Open-source boundary-layer mesh sizing for CFD — first layer height, growth ratio, and final layer thickness, computed with the correct correlations for internal (pipe/duct) and external (flat-plate/aero) flows.

``` **CFDPre** is an open-source Python library for **boundary-layer mesh sizing** in Computational Fluid Dynamics (CFD). Given your fluid, flow conditions, and target $y^+$, it computes the three numbers you need to set up an inflation / prism layer stack in a mesher such as **OpenFOAM** (`snappyHexMesh`), Fluent, or cfMesh: - **First layer height** — the wall-adjacent cell thickness that achieves your target $y^+$ - **Growth ratio** — the geometric expansion ratio between successive layers - **Final layer thickness** — the thickness of the outermost layer in the stack Fluid properties are evaluated with [CoolProp](http://www.coolprop.org/), so you can work with real fluids (air, water, fuels, refrigerants, …) at a given temperature and pressure instead of hand-typing density and viscosity. ## Why it exists Sizing the near-wall mesh is one of the most repeated calculations in wall-bounded CFD, and getting it wrong quietly corrupts your turbulence model and wall functions. CFDPre turns the full chain — fluid properties → Reynolds number → skin friction → wall shear → friction velocity → first layer height → growth ratio — into a single call, with the correct correlations for **internal (pipe/duct)** and **external (flat-plate/aero)** flows. ## Quick example ```python from cfdpre import yhgrcalc result = yhgrcalc( fluid="Air", temperature_c=50, pressure_bar=10, massflow_kgpersec=2.5, hydraulicdia_mm=125, target_yplus=1, num_layers=8, ) print(result["first layer height [yh] [m]"]) # -> 5.21e-06 print(result["Growth Ratio"]) # -> 3.66 (with a UserWarning: too aggressive) ``` ## Installation ```bash pip install cfdpre ``` ## Where to next ```{raw} html
Installation Requirements and install options Quickstart Internal and external flow, in code Theory & Methodology Every formula CFDPre uses, derived and referenced API Reference Full yhgrcalc signature and outputs
``` ## Coming soon CFDPre currently gives you the numbers — what's next is wiring them straight into your mesher's config: - **OpenFOAM** — generate a ready-to-paste `addLayersControls` / `snappyHexMeshDict` snippet - **Fluent / cfMesh** — equivalent inflation-layer setup snippets - **Batch / parametric sweeps** — vary velocity or geometry over an array and get a table of results ## Links - **Source code:** - **PyPI:** - **Users group:** ```{toctree} :hidden: :maxdepth: 2 installation quickstart theory api/reference ```