Rectilinear2DGrid¶
- class petres.grids.Rectilinear2DGrid[source]¶
Bases:
objectRepresent a 2D structured rectilinear grid.
The class stores vertex coordinates in each axis and computes cell-center coordinates and coordinate meshes on demand.
- Parameters:
x_vertex (ArrayLike) – 1D vertex coordinates along x of length
ni+1.y_vertex (ArrayLike) – 1D vertex coordinates along y of length
nj+1.active (ArrayLike) – Boolean mask of shape
(nj, ni)indicating active cells.
- Raises:
ValueError – If
activedoes not match the expected shape(nj, ni).
Notes
Coordinate meshes are cached lazily and reused after first computation.
Initialize the rectilinear grid and validate input shapes.
- Raises:
ValueError – If
activedoes not match the expected shape(nj, ni).
- __init__(x_vertex, y_vertex, active)[source]¶
Initialize the rectilinear grid and validate input shapes.
- Raises:
ValueError – If
activedoes not match the expected shape(nj, ni).
- __post_init__()[source]¶
Validate normalized arrays and enforce the activity-mask shape.
- Raises:
ValueError – If
activedoes not match the expected cell shape(nj, ni).
Notes
This method assumes arrays were already converted to NumPy arrays by
__init__().
- property niv: int¶
Get the number of vertices in the i-direction.
- Returns:
Number of x-direction vertices, equivalent to
ni + 1.- Return type:
- property njv: int¶
Get the number of vertices in the j-direction.
- Returns:
Number of y-direction vertices, equivalent to
nj + 1.- Return type:
- property ni: int¶
Get the number of cells in the i-direction.
- Returns:
Number of i-direction cells.
- Return type:
- property nj: int¶
Get the number of cells in the j-direction.
- Returns:
Number of j-direction cells.
- Return type:
- property x_center: ndarray[tuple[Any, ...], dtype[float64]]¶
Get 1D x cell-center coordinates.
- Returns:
Array of length
nicontaining x center coordinates.- Return type:
- property y_center: ndarray[tuple[Any, ...], dtype[float64]]¶
Get 1D y cell-center coordinates.
- Returns:
Array of length
njcontaining y center coordinates.- Return type:
- property xx_vertex: ndarray[tuple[Any, ...], dtype[float64]]¶
Get x coordinates on the 2D vertex mesh.
- Returns:
2D array with shape
(nj + 1, ni + 1).- Return type:
- property yy_vertex: ndarray[tuple[Any, ...], dtype[float64]]¶
Get y coordinates on the 2D vertex mesh.
- Returns:
2D array with shape
(nj + 1, ni + 1).- Return type: