Grid-generation utilities for one-dimensional coordinates.
Public API¶
| Symbol | Type | Summary |
|---|---|---|
generate_grid | function | Return face coordinates and optionally cell-center coordinates. |
non_uniform_grid | function | Generate a one-dimensional stretched face grid. |
generate_grid(size, x_f = None, generate_x_c = False, x_c = None)¶
Return face coordinates and optionally cell-center coordinates.
Parameters¶
size(int) Number of cells along the axis.x_f(array_like, optional) Face coordinates. Accepted inputs are:Noneor an empty array: build a uniform grid on[0, 1];an array of length
size + 1: interpreted directly as face coordinates;an array-like of length
2: interpreted as(xmin, xmax)and used to build a uniform grid.
generate_x_c(bool, optional) IfTrue, also return cell-center coordinates.x_c(array_like, optional) Explicit cell-center coordinates. When provided, length must equalsize.
Returns¶
numpy.ndarray or tuple[numpy.ndarray, numpy.ndarray]Face coordinates, and optionally cell-center coordinates.
Raises¶
ValueErrorIf provided coordinates are inconsistent withsize.
non_uniform_grid(left_bound, right_bound, num_points, dx_inf, factor)¶
Generate a one-dimensional stretched face grid.
Parameters¶
left_bound, right_bound(float) Domain bounds.num_points(int) Number of returned face coordinates, including both boundaries.dx_inf(float) Asymptotic cell width used in the stretching expression.factor(float) Geometric stretching factor. Values larger than1stretch cells; values between0and1compress cells.
Returns¶
numpy.ndarrayMonotonic array of face coordinates with lengthnum_points.