Skip to content

pyflightstream.probes.geometry (stable)

Generated from the docstrings at build time: every one of the 5 names in the __all__ of pyflightstream.probes.geometry has an entry below. The names a guide or an example uses come first; the others follow under Advanced.

Geometry gate of the probe planner: culling and near-surface refinement.

Pipeline role: keeps the probe budget honest. Probe points that fall inside the body sample nothing physical, so the gate discards them against the surface mesh (an .obj/.stl exported from the simulation, see :func:pyflightstream.run.export_surface_mesh), and the optional boundary-layer band re-samples the cells within a distance d of the surface with finer elements. Every decision is counted in the :class:~pyflightstream.probes.planar.GeometryGateReport: no probe is dropped or added silently.

The containment and distance queries come from trimesh (public library per the engineering policy), which reaches them through a SPATIAL INDEX: scipy's kd-tree and rtree's bounds tree. Both are runtime dependencies (license evidence reports/RPT-003), as is the reader itself, whose accessor lives in :mod:pyflightstream._mesh. This module never runs the solver: it consumes a mesh file that already exists.

Advanced

pyflightstream.probes.geometry.InsideReport dataclass

InsideReport(
    checked: bool, reason: str | None, inside: ndarray
)

Which probe points lie inside the body (FR-1074).

Attributes:

Name Type Description
checked bool

Whether the containment test ran.

reason str or None

Why it did not run (the spatial index absent, a mesh that is not watertight), or None.

inside ndarray

One flag per point, True inside the body; all False when unchecked.

count property

count: int

How many points lie inside the body.

first

first(
    points: ndarray, n: int = 3
) -> list[tuple[float, float, float]]

Return the first n inside points of points, for a message.

pyflightstream.probes.geometry.OpenMeshError

Bases: PyflightstreamError, ValueError

The surface mesh is not watertight.

Inside/outside is undefined for an open surface (a half model cut by a symmetry plane, an unclosed trailing edge): the ray-parity test would return arbitrary answers, so the gate refuses instead of guessing.

pyflightstream.probes.geometry.apply_geometry_gate

apply_geometry_gate(
    grid: PlanarProbeGrid,
    mesh=None,
    *,
    mesh_path: str | Path | None = None,
    cull: bool = True,
    standoff: float = 0.0,
) -> PlannedProbes

Run the geometry gate of a planar grid and return the final probes.

Parameters:

Name Type Description Default
grid PlanarProbeGrid

The prescribing grid; its optional refinement band is honored here, because only the mesh knows where the surface is.

required
mesh Trimesh

Loaded surface mesh; alternatively give mesh_path, never both. The report records no file for a mesh object.

None
mesh_path str or Path

Mesh file to load through :func:load_surface_mesh; the watertight check runs only when cull is set.

None
cull bool

Discard points inside the body; it needs a closed mesh. Disabling keeps every point, asks no containment (so an open mesh serves a standoff margin or a refinement band), and is the way to run the gate without a mesh.

True
standoff float

Also discard points closer to the surface than this margin (simulation length units). A probe on or hugging the wall samples the body's surface state, not the flow: the 26.120 round trip exported zero velocity for a node sitting exactly on the leading edge, and near-wall probes carry boundary-layer columns regardless of the viscous toggles (reports/RPT-004). Zero disables the margin.

0.0

Returns:

Type Description
PlannedProbes

Final reference-frame points in the deterministic parser order, plus the probe accounting report.

Raises:

Type Description
ProbeGeometryError

If the grid asks for refinement, or a positive standoff is requested, without a mesh: both are measured from the surface, so they cannot exist without one. Also if the standoff is negative or non-finite, if cull is set without a mesh, or if both mesh and mesh_path are given. It is a ValueError.

OpenMeshError

If cull is set and the mesh is not watertight, whether it came as mesh or through mesh_path.

pyflightstream.probes.geometry.load_surface_mesh

load_surface_mesh(
    path: str | Path, *, require_watertight: bool = True
)

Load a surface mesh file for the geometry gate.

Parameters:

Name Type Description Default
path str or Path

Mesh file (.obj or .stl), in simulation length units and the reference frame, as EXPORT_SURFACE_MESH writes it (FSM-26.120 pp.307-308).

required
require_watertight bool

Refuse open meshes (the default): containment is undefined on them. Disable only for distance-only uses.

True

Returns:

Type Description
Trimesh

The loaded mesh.

Raises:

Type Description
OpenMeshError

If the mesh is not watertight and containment would be undefined.

Notes

Reading a mesh is the reader alone (:mod:pyflightstream._mesh). Containment and distance queries run through the spatial index (scipy and rtree) that trimesh searches.

pyflightstream.probes.geometry.points_inside

points_inside(
    points: ndarray, *, mesh_path: str | Path
) -> InsideReport

Test probe points against the body, never refusing (FR-1074).

The containment of the geometry gate, run on any probe points. Where it cannot run, because the mesh is not watertight, the report says so and flags nothing: a caller warns that the points were not checked and goes on.

Parameters:

Name Type Description Default
points ndarray

Probe positions (n, 3) in the mesh's frame and length unit.

required
mesh_path str or Path

The geometry mesh of the row.

required

Returns:

Type Description
InsideReport

The flags, or why there are none.

Raises:

Type Description
ProbeGeometryError

If points is not an (n, 3) array (an empty array is accepted).