polyfoammesh.commercial.bl_engine
Boundary Layer Quality Engine — inspired by ANSA, Pointwise T-Rex.
Provides automatic wall detection, y+ estimation, BL parameter calculation, collision detection, and quality metrics for prism-layer meshes in OpenFOAM.
- Key capabilities:
Automatic wall patch detection (naming heuristics)
y+ estimation from flow conditions (Re, U_ref, turbulence model)
First-layer height calculation from target y+
BL collision detection (overlap ratio per wall)
Quality metrics: skewness, non-orthogonality, aspect ratio
Classes
|
Collision detection results per patch. |
|
Boundary layer parameter calculator and quality analyser. |
|
Calculated boundary layer parameters. |
|
Quality metrics for a boundary layer mesh. |
|
Flow conditions for y+ estimation. |
- class polyfoammesh.commercial.bl_engine.FlowConditions(reynolds_number=1000000.0, reference_velocity=1.0, reference_length=1.0, kinematic_viscosity=1e-05, density=1.225, turbulence_model='kOmegaSST')[source]
Bases:
objectFlow conditions for y+ estimation.
- Parameters:
- classmethod from_velocity(reference_velocity, reference_length, kinematic_viscosity=1.5e-05, density=1.225, turbulence_model='kOmegaSST')[source]
Build flow conditions with Re DERIVED from U·L/ν.
reynolds_number is a plain field with a 1e6 default, so constructing FlowConditions(reference_velocity=…, reference_length=…) silently keeps that default instead of the Reynolds number those values imply — every downstream quantity (Cf, u_tau, first layer height) is then based on the wrong Re. Use this constructor whenever Re is not known directly.
- class polyfoammesh.commercial.bl_engine.BLParameters(first_layer_height=0.0, n_layers=10, growth_rate=1.2, total_thickness=0.0, target_yplus=1.0, estimated_yplus=0.0)[source]
Bases:
objectCalculated boundary layer parameters.
- Parameters:
- class polyfoammesh.commercial.bl_engine.BLCollisionReport(patch_name='', overlap_ratio=0.0, max_thickness_ratio=0.0, status='ok')[source]
Bases:
objectCollision detection results per patch.
- class polyfoammesh.commercial.bl_engine.BLQualityMetrics(avg_skewness=0.0, max_skewness=0.0, avg_non_orthogonality=0.0, max_non_orthogonality=0.0, avg_aspect_ratio=0.0, max_aspect_ratio=0.0, min_orthogonality=90.0)[source]
Bases:
objectQuality metrics for a boundary layer mesh.
- Parameters:
- class polyfoammesh.commercial.bl_engine.BLEngine[source]
Bases:
objectBoundary layer parameter calculator and quality analyser.
Usage:
bl = BLEngine() params = bl.calculate_from_flow(FlowConditions(reynolds_number=1e7)) print(f"First layer: {params.first_layer_height:.6f} m")
- calculate_from_flow(flow, growth_rate=1.2, flow_type='flat_plate')[source]
Calculate BL parameters from flow conditions and target y+.
y+ = y * u_tau / nu, u_tau = U_ref * sqrt(Cf/2), with the skin friction correlation chosen by the FLOW TYPE - the same choice the standard online y+ calculators make:
"flat_plate"(external flows): Cf = 0.027 / Re^(1/7) (turbulent flat plate, 1/7th power law). flow.reference_length must be the plate length."pipe"(internal flows): Blasius Cf = 0.079 / Re^0.25 for Re < 1e5, and the 1/5-power pipe law Cf = 0.046 / Re^0.2 above. flow.reference_length must be the hydraulic diameter (the inlet’s equivalent diameter for a pipe/nozzle).
Using the pipe correlation with the inlet diameter instead of the flat-plate one with the bounding box is what makes internal-flow cases (tubes, nozzles, valves) land close to the solver’s real y+.
- Parameters:
flow (
FlowConditions) – free-stream/mean conditions; build it withFlowConditions.from_velocityunless you know Re directly.growth_rate (
float) – layer-to-layer expansion, clamped to [1.05, 1.5]. The layer COUNT is derived from it and the 99% BL thickness.flow_type (
str) –"flat_plate"(default) or"pipe".
- Return type:
- detect_wall_patches(patch_names)[source]
Auto-detect wall patches by name heuristics.
Delegates to
patch_roles.split_wall_patches. Returns an empty list when no patch name matches a wall keyword — never falls back to treating every patch as a wall (extruding prisms into an inlet or outlet is physically wrong).
- detect_collisions(bl_params, cell_size, patch_names)[source]
Detect boundary layer collisions.
For each patch, computes the ratio of BL total thickness to local cell size. When ratio > 0.5, layers may overlap across thin gaps.
- Parameters:
bl_params (
BLParameters) – Calculated BL parameters.cell_size (
float) – Local cell size at the wall (m).
- Return type:
- Returns:
List of
BLCollisionReport, one per patch.
- suggest_remedy(report)[source]
Suggest a remedy for a collision report.
- Return type:
- Parameters:
report (BLCollisionReport)