Skip to content

Geometry

Surface geometry computations from grid data.

Functions

curvature

1
2
3
from lst_tools import curvature

kappa = curvature(grid)

Compute the surface curvature distribution.

lst_tools.geometry.curvature

Wall curvature computation along a grid i-line.

curvature

curvature(grid: Grid, *, j: int = 0, smooth: bool = True, debug_path: Path | str | None = None, method: str = 'spline', method_params: dict[str, Any] | None = None) -> np.ndarray

Compute wall curvature along an i-line.

Treats the wall as y(x) and computes: kappa = -y'' / (1 + (y')^2)^(3/2)

Parameters:

Name Type Description Default
grid Grid

Structured grid with shape (ny, nx).

required
j int

Row index (0..ny-1) along which to compute curvature.

0
smooth bool

If True, apply smoothing to the raw curvature.

True
debug_path Path | str | None

Directory for debug output (Tecplot ASCII).

None
method str

Smoothing method ("spline", "savgol", "gaussian", "robust").

'spline'
method_params dict[str, Any] | None

Extra keyword arguments passed to the smoother.

None

Returns:

Type Description
ndarray

1-D array of curvature values along the i-line.

smooth_gaussian

smooth_gaussian(kappa: ndarray, sigma_frac: float = 0.02) -> np.ndarray

Gaussian smoothing with moving-average fallback.

Parameters:

Name Type Description Default
kappa ndarray

Raw curvature array.

required
sigma_frac float

Gaussian sigma as a fraction of array length.

0.02

Returns:

Type Description
ndarray

Smoothed curvature array.

smooth_kappa

smooth_kappa(x: ndarray, kappa: ndarray, *, method: str = 'spline', method_params: dict[str, Any] | None = None, window_frac: float | None = None, polyorder: int | None = None, sigma_frac: float | None = None, s_factor: float | None = None, median_frac: float | None = None, gauss_frac: float | None = None) -> np.ndarray

Dispatch to a chosen smoothing method.

Parameters:

Name Type Description Default
x ndarray

Coordinate array.

required
kappa ndarray

Raw curvature array.

required
method str

One of "spline", "savgol", "gaussian", "robust".

'spline'
method_params dict[str, Any] | None

Extra parameters forwarded to the chosen smoother.

None
window_frac float | None

Optional Savitzky-Golay window fraction.

None
polyorder int | None

Optional Savitzky-Golay polynomial order.

None
sigma_frac float | None

Optional Gaussian sigma fraction.

None
s_factor float | None

Optional spline smoothing factor.

None
median_frac float | None

Optional robust median-filter window fraction.

None
gauss_frac float | None

Optional robust Gaussian smoothing fraction.

None

Returns:

Type Description
ndarray

Smoothed curvature array.

smooth_robust

smooth_robust(kappa: ndarray, median_frac: float = 0.01, gauss_frac: float = 0.02) -> np.ndarray

Median filter to remove spikes, then Gaussian smooth.

Parameters:

Name Type Description Default
kappa ndarray

Raw curvature array.

required
median_frac float

Median filter window as a fraction of array length.

0.01
gauss_frac float

Gaussian sigma fraction passed to smooth_gaussian.

0.02

Returns:

Type Description
ndarray

Smoothed curvature array.

smooth_savgol

smooth_savgol(kappa: ndarray, window_frac: float = 0.03, polyorder: int = 3) -> np.ndarray

Savitzky-Golay smoothing with moving-average fallback.

Parameters:

Name Type Description Default
kappa ndarray

Raw curvature array.

required
window_frac float

Window size as a fraction of array length (forced odd).

0.03
polyorder int

Polynomial order (typically 2-3).

3

Returns:

Type Description
ndarray

Smoothed curvature array.

smooth_spline

smooth_spline(x: ndarray, kappa: ndarray, s_factor: float = 0.01) -> np.ndarray

Smoothing spline on non-uniform x with moving-average fallback.

The smoothing parameter s is derived from a median-based noise estimate scaled by s_factor.

Parameters:

Name Type Description Default
x ndarray

Coordinate array (non-uniform spacing OK).

required
kappa ndarray

Raw curvature array.

required
s_factor float

Scale factor for the smoothing parameter.

0.01

Returns:

Type Description
ndarray

Smoothed curvature array.

curvilinear_coordinate

1
2
3
from lst_tools import curvilinear_coordinate

s = curvilinear_coordinate(grid)

Compute the curvilinear coordinate along the surface.

lst_tools.geometry.curvilinear_coordinate

Curvilinear (streamwise) coordinate computation along a grid line.

curvilinear_coordinate

curvilinear_coordinate(x: Any, y: Any, j: int = 0, debug_path: Path | str | None = None) -> np.ndarray

Return a curvilinear coordinate array s for a given grid line.

This minimal version mirrors the original Fortran logic::

1
s(i) = x(i, 1)

i.e., use the x-coordinates along a fixed j-line as the streamwise coordinate.

Parameters:

Name Type Description Default
x Any

2-D grid x-coordinates with shape (ny, nx), or 1-D array.

required
y Any

2-D grid y-coordinates with shape (ny, nx), or 1-D array.

required
j int

Row index (0..ny-1) along which to extract s.

0
debug_path Path | str | None

Directory for Tecplot ASCII debug output.

None

Returns:

Type Description
ndarray

1-D array of the curvilinear coordinate along the selected j-line.

Note

If 1-D arrays are provided, the function simply returns a copy of x. This is intentionally simple. If you later want arc-length or more sophisticated definitions of s, extend this routine while keeping the same call signature.

surface_angle

1
2
3
from lst_tools import surface_angle

theta = surface_angle(grid)

Compute the surface angle distribution.

lst_tools.geometry.surface_angle

Surface-angle computation along a wall j-line.

surface_angle

surface_angle(grid: Grid, *, method: str = 'first_order', debug_path: Path | str | None = None) -> np.ndarray

Compute surface tangent angle phi along the wall j-line.

Parameters:

Name Type Description Default
grid Grid

Structured grid (shape ny x nx).

required
method str

Differentiation scheme — "first_order" (forward/backward differences) or "second_order" (np.gradient).

'first_order'
debug_path Path | str | None

Directory for Tecplot ASCII debug output.

None

Returns:

Type Description
ndarray

Surface tangent angle phi (radians) at each streamwise station.

Raises:

Type Description
ValueError

If method is not a recognised scheme.

radius

1
2
3
from lst_tools import radius

r = radius(grid)

Compute the local body radius.

lst_tools.geometry.radius

Local body radius computation for different geometry kinds.

radius

radius(grid: Grid, cfg: dict, *, debug_path: Path | str | None = None) -> np.ndarray

Compute the local body radius array for the given geometry kind.

Parameters:

Name Type Description Default
grid Grid

Computational grid with shape (ny, nx).

required
cfg dict

Configuration object with geometry.type and related params.

required
debug_path Path | str | None

Directory for Tecplot ASCII debug output.

None

Returns:

Type Description
ndarray

1-D radius array along the wall (j = 0).

Geometry Kinds

GeometryKind

1
2
3
from lst_tools import GeometryKind, list_geometry_kinds

kinds = list_geometry_kinds()

Enumeration of supported geometry types.

lst_tools.geometry.GeometryKind

Bases: IntEnum

Integer identifiers for supported geometry types.

lst_tools.geometry.list_geometry_kinds

list_geometry_kinds() -> Mapping[int, str]

Return a mapping {integer_id: 'NAME — explanation'} for display/CLI.