CFD PreProcessing Library
Project description
What is CFDPre?
CFDPre is an open-source collection of object-oriented software tools for calculating boundary layer mesh dimensions for Computational Fluid Dynamics simulations. Among other things, it can be used to:
- Calculate First Layer Thickness, Growth Ratio and Final Layer Thickess
Installation
In your command line, within Python environment:
pip install cfdpre
- The Python module can also be installed using pip on Windows, macOS, and Linux.
Usage
yhgrcalc supports two flow types:
flow_type='internal'(default) — fully-developed pipe/duct flow.massflow_kgpersecandhydraulicdia_mmare used to derive velocity and Reynolds number. Skin friction uses the laminar (Re < 2300,16/Re) or the Haaland (1983) explicit turbulent correlation, valid across the full turbulent range for smooth and rough pipes (roughness_mm) — unlike Blasius, which is only accurate belowRe ≈ 1e5. The prism-stack thickness defaults to the pipe radius, but you can set it explicitly withbl_thickness_mmor as a fraction of the radius withbl_thickness_fraction(filling the entire radius with prisms is rarely what you actually mesh).flow_type='external'— flow over a flat plate / aerodynamic surface.hydraulicdia_mmis interpreted as a characteristic length (e.g. chord length), andflow_velocity_mpersecis required (the mass-flow/area velocity is meaningless for external flow). Skin friction and boundary layer thickness use the laminar (Blasius) or turbulent (Schlichting) flat-plate correlations;bl_thickness_mmcan override the correlation-based thickness.
If the computed growth ratio exceeds ~1.3 (or the boundary layer is too thin to resolve
with the requested target_yplus/num_layers), a UserWarning is raised so you can
adjust your inputs.
from cfdpre import yhgrcalc
yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8)
Output:
{'fluid': 'Air',
'temperature [C]': 50,
'pressure [bar]': 10,
'massflow [kg/sec]': 2.5,
'hydraulicdia [mm]': 125,
'target yplus': 1,
'number of layers': 8,
'flow type': 'internal',
'roughness [mm]': 0.0,
'dynvisc [N-sec/m^2]': 1.9762497305390764e-05,
'thermal conductivity [W/m-k]': 0.028357331300649127,
'specific heat [cp] [J/kg-k]': 1019.3146170790077,
'density [kg/m^3]': 10.792698589669245,
'kinematic viscosity [m^2/s]': 1.8310987878701066e-06,
'flow velocity [m/sec]': 18.875569021507275,
'reynolds number': 1288541.1444310248,
'prandtl number': 0.7103701741111368,
'skin friction coefficient [cf]': 0.002776948990231969,
'wall shear stress [tau_wall]': 5.339100066909961,
'boundary layer thickness [delta99] [m]': 0.0625,
'height of cell centroid from wall [yp] [m]': 2.6034112015544278e-06,
'first layer height [yh] [m]': 5.2068224031088555e-06,
'Growth Ratio': 3.6553638704281375,
'Final Layer Thickness [m]': 0.04540326342524223}
Note: with
target_yplus=1and only 8 layers at this high Reynolds number (~1.29e6), the growth ratio comes out to ~3.66, well above the recommended ~1.3 maximum — this example raises aUserWarningaccordingly. In practice you'd either use far more layers (20-40+) or restrict the prism stack to part of the radius. For example, spanning only 30% of the radius:yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8, bl_thickness_fraction=0.3) # GR ~3.04
External flow example (flow_velocity_mpersec is required):
yhgrcalc('Air', 25, 1.01325, 2.5, 1000, 1, 15, flow_type='external', flow_velocity_mpersec=30)
Documentation
In progress - not yet made!
- Project Home Page: https://cfdpre.github.io/ [under construction]
- Users Group: https://groups.google.com/g/cfdpre
- Source code: https://github.com/phsheth/cfdpre
- PyPI Page: https://pypi.org/project/cfdpre/
Call for Contributors
The CFDPre project welcomes your expertise and enthusiasm! Better to discuss on the users group before starting to contribute!
Project Log
January 2025:
- Created Library
June 2026:
- Added
flow_type('internal'/'external') support. Internal flow uses laminar16/Reand the Haaland (1983) turbulent correlation (valid to high Re, smooth/rough viaroughness_mm); external flow uses Blasius/Schlichting flat-plate correlations and now requiresflow_velocity_mpersec. Prism-stack thickness is selectable viabl_thickness_mmorbl_thickness_fraction. Added growth-ratio (>1.3) and boundary-layer sanity warnings.
Project RoadMap:
- Documentation for existing functionality.
- Include example data within library.
- Object-oriented API refactor + input validation.
- Generate
snappyHexMeshDict-readyaddLayersControlssnippets. - Bundled examples, unit tests, CI, and docs site.
- Parametric/batch sweeps.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cfdpre-0.3.0.tar.gz.
File metadata
- Download URL: cfdpre-0.3.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c404ae5cc2389752155adc3c40eb071306eaab4bb2d51e2e4d0a64c261194e5d
|
|
| MD5 |
d235fd1733092e07185a2f183501dc13
|
|
| BLAKE2b-256 |
b1265c30f31a6dd768ad347cde6849028768a1ec34e22beca46e4dc5eb85bfde
|
File details
Details for the file cfdpre-0.3.0-py3-none-any.whl.
File metadata
- Download URL: cfdpre-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c90b0a76e0e0c4fc49d9db68b81467ac48f61ecaddcf4d475db6e273f51a3f5
|
|
| MD5 |
ee2766867e874a540c2dbf96953ea33e
|
|
| BLAKE2b-256 |
ee6c1a6b12e7eb6dd10e99585c3ed6b3d6b8a663ebdf6de0f78b4f35dfc02398
|