k=0 construction (cubed sphere)
The k=0 layer is the wall grid from which the volume is marched. For the cubed sphere (and the wrap of the OH hybrid) it is built in two stages:
- Caps: a flat diamond in the tangent plane at each pole, cast onto the body (gnomonic projection).
- Equator: great-circle meridians from the south cap seam to the north cap seam, cast onto the body, with the first and last interval of each meridian pinned to the cap edge (C1 spacing at the seam).
Both stages cast rays through the projector. The result is six arrays: four equatorial sub-blocks of (ni, nc) nodes and two caps of (nc, nc) nodes, with nc = nj // 4 + 1.
Caps: gnomonic flat-square projection
At each pole a flat diamond is placed in the tangent plane
Each tangent-plane point is normalised to a direction and cast through the anchor. On a sphere centred on the anchor, the four corners land at colatitude
Why a diamond. The four sub-block junctions sit at azimuths 0°, 90°, 180°, 270°. An axis-aligned square would put its corners at ±45° and ±135°, between the junctions; turned by 45° its corners land exactly on them, which is the contract _overwrite_cap_boundaries expects.
Cap-edge spacing. The 1D coordinates on j_spacing: uniform, or tanh2 to cluster nodes toward the cap corners. Because the cap edges become the equator's pole rows, the equator inherits the same distribution along its seams. (tanh is not offered: the law must be symmetric in the four quadrants.)
The OH hybrid passes phi_offset = pi/4 so the four sub-block centres, not their corners, face the world axes.
Equator: great-circle meridians
The seam ring of each cap (its four edges in sub-block order, shared corners dropped) gives nj seam nodes per pole. For every column
- Slerp from
seam_south[j]toseam_north[j]along the great circle through the two anchor directions, at the colatitudes of a 1D distribution (below). - Cast the interior directions onto the body.
- Copy the two seam rows from the caps bit for bit (no re-cast), so the cap–equator seams are conforming to round-off.
Per-j C1 seam pinning
At each seam vertex three block edges meet: two cap-edge edges and one equator meridian. For the spacing to be continuous across the seam all three must start with the same first cell.
The cap-edge first cell at column
The meridian is parametrised in colatitude, not in anchor angle, so the step is converted per column,
with pinned_distribution then places the first and last interval exactly and shapes the interior ni − 2 cells with i_spacing (uniform, tanh toward the south seam, tanh2 toward both seams).
Compatibility window and fallback
Pinning is used on a column only when each pinned step is within a factor 2 of the step the unpinned i_spacing law would give there (UserWarning ("Cap radial step ... is incompatible ..."). A forced pin outside the window would put a large cell-size jump just inside the seam, which the marcher then carries outward.
For uniform spacing on a sphere, the cap step is the corner-to-corner arc divided by the cap cells and the natural equator step is the meridian divided by its cells, so the rule is
With --ni 40 --nj 60 and
Final layout
CubedSphereTopology.build allocates one contiguous ring of shape (ni, 4·(nc − 1) + 1, nk, 3) for the four sub-blocks; each sub-block is a numpy view of a 90° slice, so adjacent sub-blocks share their j_hi / j_lo columns in memory (SHARED). The caps are separate (nc, nc, nk, 3) arrays bound to the sub-block pole rows (DIRICHLET); _overwrite_cap_boundaries rewrites the cap edges from the pole rows at every marched layer.




See also
- Surface projection: the ray-casting kernel
- Marching and Seam-aware normals: how the pinned spacing is carried outward
- Cubed-sphere topology: block layout and connectivity
build_cap_k0,build_equator,pinned_distribution