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

BLCollisionReport([patch_name, ...])

Collision detection results per patch.

BLEngine()

Boundary layer parameter calculator and quality analyser.

BLParameters([first_layer_height, n_layers, ...])

Calculated boundary layer parameters.

BLQualityMetrics([avg_skewness, ...])

Quality metrics for a boundary layer mesh.

FlowConditions([reynolds_number, ...])

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: object

Flow conditions for y+ estimation.

Parameters:
  • reynolds_number (float)

  • reference_velocity (float)

  • reference_length (float)

  • kinematic_viscosity (float)

  • density (float)

  • turbulence_model (str)

reynolds_number: float = 1000000.0
reference_velocity: float = 1.0
reference_length: float = 1.0
kinematic_viscosity: float = 1e-05
density: float = 1.225
turbulence_model: str = 'kOmegaSST'
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.

Return type:

FlowConditions

Parameters:
  • reference_velocity (float)

  • reference_length (float)

  • kinematic_viscosity (float)

  • density (float)

  • turbulence_model (str)

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: object

Calculated boundary layer parameters.

Parameters:
first_layer_height: float = 0.0
n_layers: int = 10
growth_rate: float = 1.2
total_thickness: float = 0.0
target_yplus: float = 1.0
estimated_yplus: float = 0.0
class polyfoammesh.commercial.bl_engine.BLCollisionReport(patch_name='', overlap_ratio=0.0, max_thickness_ratio=0.0, status='ok')[source]

Bases: object

Collision detection results per patch.

Parameters:
  • patch_name (str)

  • overlap_ratio (float)

  • max_thickness_ratio (float)

  • status (str)

patch_name: str = ''
overlap_ratio: float = 0.0
max_thickness_ratio: float = 0.0
status: str = 'ok'
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: object

Quality metrics for a boundary layer mesh.

Parameters:
  • avg_skewness (float)

  • max_skewness (float)

  • avg_non_orthogonality (float)

  • max_non_orthogonality (float)

  • avg_aspect_ratio (float)

  • max_aspect_ratio (float)

  • min_orthogonality (float)

avg_skewness: float = 0.0
max_skewness: float = 0.0
avg_non_orthogonality: float = 0.0
max_non_orthogonality: float = 0.0
avg_aspect_ratio: float = 0.0
max_aspect_ratio: float = 0.0
min_orthogonality: float = 90.0
passed(thresholds=None)[source]
Return type:

bool

Parameters:

thresholds (dict[str, float] | None)

class polyfoammesh.commercial.bl_engine.BLEngine[source]

Bases: object

Boundary 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 with FlowConditions.from_velocity unless 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:

BLParameters

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).

Return type:

list[str]

Parameters:

patch_names (list[str])

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).

  • patch_names (list[str]) – Names of patches to analyse.

Return type:

list[BLCollisionReport]

Returns:

List of BLCollisionReport, one per patch.

suggest_remedy(report)[source]

Suggest a remedy for a collision report.

Return type:

str

Parameters:

report (BLCollisionReport)

static yplus_from_height(height, u_ref, nu, length)[source]

Estimate y+ from a given first-layer height.

Inverse of the flat-plate correlation.

Return type:

float

Parameters:
static suggest_n_layers(target_thickness, first_height, growth=1.2)[source]

Suggest number of layers to achieve target BL thickness.

Return type:

int

Parameters: