Expand description
Semi-Lagrangian transport of scalar fields (dye, cloud water) by a prescribed,
kinematic velocity on a capped lattice (M13 shared model: jupiter_storms,
hurricane; ADR-0012 caps).
The flow is not solved: a scene writes node velocities (lattice cells per second) into
a Flow, usually as differences of a stream function across each cell (the form of
stream_velocity, which scenes reproduce with cached factors), which makes the
discrete field exactly divergence-free, and advect carries a field along it. Each
node traces its departure point back with a midpoint (RK2) step and takes the bilinear
value there, so the scheme is unconditionally stable for any dt (GEN-R4) at the price
of a little numerical diffusion, which the scenes counter with their sources.
Lattice coordinates: node (i, j) sits at (x, y) = (i, j), y down the screen.
Everything here is allocation-free once the grids are sized (GEN-R11).
Structs§
- Flow
- Node velocities in lattice cells per second.
Enums§
- XEdge
- What lies beyond the left and right edges: a planet’s longitude wraps round, a storm’s box is clamped (its edge value is repeated). Rows are always clamped.
Functions§
- advect
- Carry
srcalongflowfordtseconds intodst(resized tosrc): each node takes the bilinear value ofsrcat itsdeparturespoint.flowmust havesrc’s size, elsedstis left zeroed. - departures
- Call
f(k, x, y)with the departure point(x, y)of every nodek(row-major): where the fluid now at the node wasdtseconds ago, traced back along a midpoint (RK2) characteristic. A scene carrying several fields samples each of them there. - sample
- Bilinear value of
gat lattice point(x, y), clamped inyand wrapped or clamped inxbyedge; 0 for an empty grid or a non-finite point. - value_
noise_ wrap_ x - Value noise that wraps every
periodunits inx(a planet’s longitude), so the seam never shows:sciart_core::rng::value_noise(CORE-R97) with unit cells, except that the lattice column index is taken moduloperiod, which the core form cannot do.