1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Sweep kernels behind [`StaggeredLeapfrog3D`].
//!
//! Each kernel picks its traversal from where the differentiated axis sits in
//! row-major storage: the innermost axis is a contiguous line, the outer two
//! are strided blocks whose taps zip across whole blocks rather than cells.
//! A non-contiguous array falls back to three-index addressing, which computes
//! the same sums in the same order.
//!
//! The two operator families live one per leaf module — [`gradient`] sweeps
//! forward, [`divergence`] is its transpose — and share the tap window and
//! reflection helpers held here.
pub use ;
pub use ;
use StaggeredLeapfrog3D;
use ;
/// One window of `2·halo` source cells split at `halo` feeds one output cell of
/// either operator: `Σ_n c_n (hi[n−1] − lo[halo−n])`. The gradient's window for
/// face `i+½` starts at `i+1−halo`; the divergence's window for cell `j` starts
/// at `j−halo` — the transpose shifts the output by one cell and changes
/// nothing else. Taps accumulate in ascending `n`, the order the indexed
/// reference uses, so the two agree bit for bit.
pub
/// Mirror an index about the nearest wall until it lands inside `0..extent`.
///
/// Cell centres sit at `(i+½)Δ`, so the walls fall *between* cells and the
/// mirror is `−1−m` at the low end and `2·extent−1−m` at the high end — no cell
/// is its own reflection. The loop repeats for stencils deeper than the grid,
/// which only arises for extents below the halo width; it terminates for any
/// `extent ≥ 1`.
pub