Skip to content

shore.volume.jacobian

Per-cell Jacobian computation for structured O-grids.

O-grid vs open topology

jacobian_field assumes a periodic j-direction (O-grid). For open (non-periodic) blocks — such as the equatorial sub-blocks and cap blocks of the cubed-sphere topology — use _jacobian_field_open instead. The per-layer minimum-Jacobian guard used by the marcher and by Mesh.check is built on these two field functions (see Relationship to shore check).

Functions

jacobian_field

python
def jacobian_field(grid: np.ndarray) -> np.ndarray

Compute the scalar-triple-product Jacobian for every cell in the volume.

Ji,j,k=(e2×e1)e3

where e1=Pi,j+1,kPi,j,k (j-tangent, periodic), e2=Pi+1,j,kPi,j,k (i-tangent), and e3=Pi,j,k+1Pi,j,k (wall-normal).

Parameters

NameTypeDescription
gridnp.ndarray (ni, nj, nk, 3)Full structured O-grid volume

Returns

numpy.ndarray of shape (ni-1, nj, nk-1) — one Jacobian value per cell. The j-dimension equals nj (not nj-1) because the periodic wrap closes the last cell.

Example

python
from shore.volume.jacobian import jacobian_field
from shore.io.geo import read_geo

grid = read_geo("sphere.geo")
J = jacobian_field(grid)
print(J.shape)        # (ni-1, nj, nk-1)
print(J.min())        # > 0 for a valid O-grid

Per-layer minimum Jacobian

There is no standalone jacobian_per_layer helper. The per-layer minimum that shore check tabulates is computed inside Mesh.check and shore.mesh.inspect: for each layer interval [k, k+1] they slice the two layers, stack them into a 2-layer volume, call jacobian_field (periodic-j) or _jacobian_field_open (open block), and take jac.min(). The marcher applies the same per-layer guard through shore.topology.sphere_cap._check_jacobian (see api-sphere-cap).


_jacobian_field_open (internal)

python
def _jacobian_field_open(grid: np.ndarray) -> np.ndarray

Jacobian field for a non-periodic (open) structured volume. Identical to jacobian_field but the j-direction is not wrapped: there are nj-1 cells in j rather than nj.

Parameters

NameTypeDescription
gridnp.ndarray (ni, nj, nk, 3)Open structured volume

Returns

numpy.ndarray of shape (ni-1, nj-1, nk-1).

Used by the cubed-sphere topology for equatorial sub-blocks and cap blocks, which have open boundaries in both i and j.

Notes

Sign convention

Positive Jacobian means the cell is correctly oriented: the outward normal of the cross product e2×e1 aligns with the wall-normal direction e3.

For a sphere O-grid with rays cast outward from the centroid, the lat-lon directions give:

  • e1 (longitude, j) — eastward
  • e2 (latitude, i) — southward
  • e2×e1 — outward radial (positive Jacobian when e3 also points outward)

Relationship to shore check

shore check calls Mesh.check, which computes the per-layer minimum Jacobian per block by slicing each consecutive layer pair into a 2-layer volume and reducing jacobian_field / _jacobian_field_open with .min(). The marcher applies the same per-layer guard at every accepted layer via shore.topology.sphere_cap._check_jacobian.

See also

Released under the MIT License.