turbo_moc.deprecated.meshing.stator_mesh_2d module#
Meshing source: Gmsh CAD, inflation, periodic mesh, export, and diagnostics.
Sections: settings; CAD; sizing; conformity; CGNS export; visualization; quality metrics; report writing; generation workflow. All lengths are mm.
Transfer the existing fitted B-spline exactly to OpenCASCADE, close the trailing edge with circular arcs, and mesh the surrounding fluid with inflation layers.
- exception turbo_moc.deprecated.meshing.stator_mesh_2d.InvertedCellsError[source]#
Bases:
RuntimeErrorCells folded against, or non-convex in, their surface’s orientation.
- turbo_moc.deprecated.meshing.stator_mesh_2d.add_blade_boundary(blade, mesh_size)[source]#
Reuse the fitted spline and close its ends with two quarter-circle arcs.
- turbo_moc.deprecated.meshing.stator_mesh_2d.add_inflation_layers(blade_curves, numerics)[source]#
Create quadrilateral layers normal to every blade-boundary curve.
- turbo_moc.deprecated.meshing.stator_mesh_2d.add_periodic_passage(curves, blade_curves, pitch, mesh_size)[source]#
Transfer the selected smooth domain and constrain translated 1D meshes.
- turbo_moc.deprecated.meshing.stator_mesh_2d.analyze_mesh(xy, cells, element_tags, boundary_edges, *, periodic_map=None, inflation=None, gmsh_quality=None, worst_cells=10, inflation_tolerance=0.35)[source]#
Pure-Python geometric analysis; connectivity uses zero-based node indices.
- turbo_moc.deprecated.meshing.stator_mesh_2d.annotate_mesh_boundaries(ax, data, options, shifts)[source]#
Label outer passage boundaries and a central blade for any blade count.
- turbo_moc.deprecated.meshing.stator_mesh_2d.app_numerics(sizes)[source]#
Gmsh numerics for the app’s mesh from blade_size, domain_size, first_height, growth_ratio, num_layers, transition_ratio. The inflation thickness passed to Gmsh is derived: exactly num_layers geometric layers.
- turbo_moc.deprecated.meshing.stator_mesh_2d.calculate_inflation_profile(inflation)[source]#
Resolve the complete geometric layers that fit the thickness limit.
These are nominal values: Gmsh may shorten or merge columns near curvature and neighbouring boundaries. The three user inputs are never adjusted.
- turbo_moc.deprecated.meshing.stator_mesh_2d.check_periodic_conformity(boundaries)[source]#
Verify complete node bijections, translations, and matching 1D edges.
- turbo_moc.deprecated.meshing.stator_mesh_2d.collect_fluid_mesh(fluid_surface, boundaries)[source]#
Renumber used nodes and orient cells/edges with fluid on their left.
CAD control points and other unused Gmsh nodes are excluded. Each exterior cell edge must belong to exactly one named boundary. This follows the section extraction used by ParaBlade’s annular_mesh.py.
- turbo_moc.deprecated.meshing.stator_mesh_2d.collect_mesh_plot_data(fluid_surface, boundaries=None)[source]#
Read actual cells and named 1D physical groups; omit unused CAD nodes.
- turbo_moc.deprecated.meshing.stator_mesh_2d.collect_periodic_nodes(boundaries, local, xy)[source]#
Merge per-curve maps into one checked right-to-left node bijection.
- turbo_moc.deprecated.meshing.stator_mesh_2d.compute_mesh_report(fluid_surface, boundaries, *, inflation=None, worst_cells=10, inflation_tolerance=0.35)[source]#
Analyze an active Gmsh 2D surface before gmsh.finalize().
- turbo_moc.deprecated.meshing.stator_mesh_2d.configure_core_transition(blade_curves, numerics, profile, pitch=None, use_mesh=False)[source]#
Install local, periodic sizing; refresh from actual wall edges after 1D.
Before the 1D mesh exists, CAD samples and curvature estimate tangential spacing. Afterwards, actual blade-edge lengths replace that estimate. The blade’s 1D sizing remains separate from the core’s area-based sizing.
- turbo_moc.deprecated.meshing.stator_mesh_2d.configure_mesh_display()[source]#
Use orange for both 2D element types, independent of saved GUI colors.
- turbo_moc.deprecated.meshing.stator_mesh_2d.configure_recombination(fluid_surface, numerics)[source]#
Recombine the fluid surface, as in ParaBlade’s 2D mesh builder.
Algorithm 8 prepares triangles for recombination; setRecombine actually enables their conversion to quadrilaterals outside the inflation layers.
- turbo_moc.deprecated.meshing.stator_mesh_2d.core_mesh_size(distance, tangent_size, profile, domain_size, recombine=True, transition_ratio=1.2)[source]#
Match the nominal last-layer area, then grade towards the far field.
Last-layer area is estimated as tangential spacing times normal height. Convert it to a square/equilateral-triangle size; this keeps the two wall directions independent. transition_ratio sets the jump from the last inflation layer to the first core cell (area growth, and the cap on the normal step). A small linear size gradient then gives approximately CORE_AREA_GROWTH between successive regular core cells.
- turbo_moc.deprecated.meshing.stator_mesh_2d.create_mesh(blade, curves, settings, output_dir, show_gui=True)[source]#
Generate, check, export and report a mesh using the caller’s logging setup.
- turbo_moc.deprecated.meshing.stator_mesh_2d.default_mesh_sizes(pitch)[source]#
App defaults. Cell sizes [mm] are proportional to the pitch, with the same ratios as examples/gmsh/stator_mesh.yaml (tuned for its ~80 mm pitch), since a sized blade can be tens of times smaller than that raw design. The first-layer height is not here: it comes from a target y+ (turbo_moc.meshing.wall_spacing.estimate_first_layer_height).
- turbo_moc.deprecated.meshing.stator_mesh_2d.distribution(values)[source]#
JSON-safe count, extrema, mean, standard deviation, and quantiles.
- turbo_moc.deprecated.meshing.stator_mesh_2d.export_flow_domain_step(blade, step_path, passage=None)[source]#
Write the fluid domain (passage face with the blade hole) to STEP.
Built with the exact same Gmsh/OpenCASCADE CAD the mesher uses (add_blade_boundary + add_periodic_passage: fitted blade B-spline, circular TE arcs, the passage’s analytic splines), so the exported surface IS the meshed domain. No cadquery needed.
- turbo_moc.deprecated.meshing.stator_mesh_2d.export_fluent_cgns(filename, fluid_surface, boundaries, settings)[source]#
Write a true 2D CGNS/ADF mesh with named BCs and periodic connectivity.
A CGNS mesh describes boundary types, not pressures, temperatures, or a Fluent case setup. Coordinate scaling affects only this export. Mixed cells use the CGNS 3.4 layout supported by the ParaBlade ADF converter.
- turbo_moc.deprecated.meshing.stator_mesh_2d.flow_domain_outline(curves)[source]#
Closed outer boundary (n, 2) of a stator_flow_domain, for plotting: left periodic side inlet -> outlet, outlet cap, right side back, inlet cap.
- turbo_moc.deprecated.meshing.stator_mesh_2d.inverted_cell_count(fluid_surface)[source]#
Cells folded against the majority orientation of their surface, or non-convex. Gmsh’s minSJ misses flipped cells on a plane surface (a flipped triangle reports minSJ = 1), so corner turns are checked here.
- turbo_moc.deprecated.meshing.stator_mesh_2d.mesh_figure_options(settings)[source]#
Validate the small set of user controls for one exported mesh view.
- turbo_moc.deprecated.meshing.stator_mesh_2d.mesh_sized_stator(scaled_blade, sizes, passage=None, topology='unstructured')[source]#
2D blade-to-blade mesh of a sized stator’s HUB section.
scaled_blade is the app’s stator-sizing-store[“scaled_blade”] (parametrize_stator_blade output rescaled by k: mm, x pitchwise, y axial, flow toward -y). sizes holds blade_size, domain_size [mm], first_height [mm] (e.g. from a target y+), num_layers, growth_ratio and transition_ratio. Other spans and the cylinder view are node maps of this one mesh (see section_coordinates), so the topology is the same everywhere.
topology=”structured” tries the multi-block O-H mesh (turbo_moc.meshing.stator_structured_2d); if that fails for this design, the unstructured mesh is generated instead and the result reports why (“fallback_reason”).
Returns plain-list arrays (JSON-friendly): xy (n, 2) [mm], cells (1-based node lists, fluid on the left), named_edges {name: [[a, b, cell, position], …]}, periodic {“current”, “donor”} (periodic_right -> periodic_left nodes), pitch, domain_shift_mm, topology and statistics.
- turbo_moc.deprecated.meshing.stator_mesh_2d.mesh_statistics(fluid_surface, boundaries)[source]#
Check cell quality and periodic node correspondence before saving.
- turbo_moc.deprecated.meshing.stator_mesh_2d.plot_mesh_figure(data, *, pitch, options)[source]#
Draw the selected number of pitch-translated blades in one boxed figure.
- turbo_moc.deprecated.meshing.stator_mesh_2d.reconstruct_inflation(xy, cells, owners, wall_edges, settings, tolerance=0.35)[source]#
Trace opposite-edge quad columns consistent with the configured layers.
Membership is an estimate: recombined core quads do not carry a public BoundaryLayer provenance tag. Reject heights inconsistent with the geometric series, stop at the configured thickness allowance, and expose column depth/coverage rather than asserting a uniform layer count.
- turbo_moc.deprecated.meshing.stator_mesh_2d.save_mesh_image(filename, fluid_surface, *, boundaries=None, pitch=None, settings=None)[source]#
Export one Times-styled mesh view to PNG and SVG without opening a GUI.
- turbo_moc.deprecated.meshing.stator_mesh_2d.section_coordinates(xy, r_hub, radius, mode='unrolled')[source]#
Map hub-section mesh nodes to the section at radius.
The app’s axial annular wrap (turbo_moc.geometry.annular, flare “pitch_scale”) puts every blade point at theta = -x / r_hub and z = y at EVERY radius: the pitchwise stretch r/r_hub cancels the 1/r of the wrap. So the section at radius r is exactly the hub section with x scaled by r/r_hub (“unrolled”, planar (r*theta, z) coordinates for 2D CFD), and the same nodes on the cylinder are (r cos theta, r sin theta, z) (“cylinder”, a 3D surface matching the exported solid).
- turbo_moc.deprecated.meshing.stator_mesh_2d.set_mesh_sizes(blade_curves, numerics, profile=None, pitch=None)[source]#
Set blade resolution and automatically grade the surrounding core.
- turbo_moc.deprecated.meshing.stator_mesh_2d.stator_flow_domain(blade, passage=None)[source]#
The app’s single fluid-domain definition for a stator blade: the smooth periodic passage of stator_passage.generate_flow_domain with APP_PASSAGE_DEFAULTS (overridable via passage), auto-centred between the periodic sides. Used by the 2D mesh, the STEP export and the preview, so all three always describe the same domain. Extents are in chords, so the domain scales with the blade (raw Phase 2 or sized).
- turbo_moc.deprecated.meshing.stator_mesh_2d.surface_elements(fluid_surface)[source]#
getElements(2, …) for one surface tag or a list of them (a multi-block mesh), merged per element type in the same layout.
- turbo_moc.deprecated.meshing.stator_mesh_2d.untangle_surface(surface, max_passes=50, rings=2)[source]#
Repair a few folded/non-convex cells by guarded Laplacian moves of the interior nodes near them; boundary nodes stay put.
A node moves toward the mean of its neighbours (full, half, quarter or tenth step) only if that raises the worst corner sine of the cells around it, so no move can fold a cell that was valid – plain smoothing would wreck the thin inflation cells. Returns the number of cells still invalid; moved nodes are written back to the Gmsh model.
- turbo_moc.deprecated.meshing.stator_mesh_2d.validate_mesh_settings(settings)[source]#
Check the numerical, figure, export and report controls before Gmsh.
- turbo_moc.deprecated.meshing.stator_mesh_2d.write_fluent_cgns_2d(filename, xy, cells, named_edges, periodic, settings)[source]#
export_fluent_cgns’s writer, from plain arrays (no live Gmsh model).
xy: (n, 2) node coordinates in mm; cells: 1-based node lists, fluid on the left; named_edges: {name: (m, 4) [a, b, cell, position]} as returned by collect_fluid_mesh; periodic: (current, donor) 1-based node arrays for periodic_right -> periodic_left. The periodic translation is measured from xy, so a pitchwise-stretched copy of a mesh exports correctly.