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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! Finite-difference sub-trait.
//!
//! [`FiniteDifference3DOps`] provides fixed central and Yee first-derivative
//! stencils. [`StaggeredPairOps`] provides the arbitrary-even-order staggered
//! gradient/divergence pair used by a conservative leapfrog.
//!
//! # Why this is not part of [`BackendOps`]
//!
//! [`BackendOps`] is the set every backend must satisfy. A backend that has no
//! stencil kernels yet would have to supply stubs to join it, and a stub that
//! returns zeros or an error is a mock wearing a trait impl. Consumers bind
//! `B: FiniteDifference3DOps<T>` or `B: StaggeredPairOps<T>` directly, so a
//! backend advertises each capability when it implements that family.
//!
//! # Preparation
//!
//! The coefficients of an order-`2N` staggered stencil come from solving a
//! Taylor system; deriving them per sweep would put a linear solve inside an
//! FDTD timestep. [`StaggeredPairOps::prepare_staggered_pair`] does that
//! once and returns whatever the backend needs to cache — taps on the CPU, a
//! compiled kernel and an uploaded coefficient buffer on a device.
//!
//! [`BackendOps`]: super::super::BackendOps
use ;
pub use ;
/// The staggered gradient/divergence pair at arbitrary even order.
///
/// Split from [`FiniteDifference3DOps`] because the two capabilities do not
/// arrive together: an accelerator can serve this pair — the operator an FDTD
/// leapfrog actually runs — long before it has the fixed central and Yee
/// schemes. Bundling them would oblige such a backend to supply a body for
/// what it cannot do, and a body that returns an error is a mock wearing a
/// trait impl.
///
/// Dispatch operands have matching row-major `[nx, ny, nz]` layouts with zero
/// offsets. Gradient and divergence write into caller-supplied destinations;
/// preparation derives coefficients and acquires provider resources.
/// Fixed-scheme three-dimensional first derivatives.
///
/// The central and Yee families whose coefficients are fixed by the scheme
/// rather than derived per order. A backend implements this when it has those
/// kernels; the staggered pair is [`StaggeredPairOps`], which arrives first on
/// an accelerator.