Skip to main content

Module vortex_advect

Module vortex_advect 

Source
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 src along flow for dt seconds into dst (resized to src): each node takes the bilinear value of src at its departures point. flow must have src’s size, else dst is left zeroed.
departures
Call f(k, x, y) with the departure point (x, y) of every node k (row-major): where the fluid now at the node was dt seconds ago, traced back along a midpoint (RK2) characteristic. A scene carrying several fields samples each of them there.
sample
Bilinear value of g at lattice point (x, y), clamped in y and wrapped or clamped in x by edge; 0 for an empty grid or a non-finite point.
value_noise_wrap_x
Value noise that wraps every period units in x (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 modulo period, which the core form cannot do.