1// Shared declarations, prepended to every kernel.
3struct Params {
4 nx: u32,
5 ny: u32,
6 n: u32,
7 histLen: u32,
8 hx: f32,
9 hy: f32,
10 dt: f32,
11 nu: f32,
12 D: f32, // bending stiffness [N m]
13 C: f32, // E h / (1 - nu^2) [N/m]
14 G: f32, // E h / (2 (1 + nu)) [N/m]
15 rhoh: f32, // mass per unit area [kg/m^2]
16 pushX: f32, // center of the pushed patch [m]
17 pushY: f32,
18 pushR2: f32, // squared patch radius [m^2]
19 mass: f32, // total mass [kg]
20 Ix: f32, // sum m y^2
21 Iy: f32, // sum m x^2
22 Iz: f32, // sum m (x^2 + y^2)
23 pad0: f32,
24};
26// Per-step parameters, addressed with a dynamic uniform offset.
27struct StepParams {
28 step: u32,
29 flags: u32, // bit 0: push constraint active
30 audioSlot: i32, // ring-buffer slot to record acceleration into (-1: none)
31 audioOut: i32, // output sample index within the batch
32 pushW: f32, // prescribed patch displacement [m]
33 pushV: f32, // prescribed patch velocity [m/s]
34 sigma0: f32,
35 sigma1: f32,
36};
38fn nodeX(i: i32) -> f32 { return (f32(i) - 0.5 * f32(P.nx - 1u)) * P.hx; }
39fn nodeY(j: i32) -> f32 { return (f32(j) - 0.5 * f32(P.ny - 1u)) * P.hy; }
40fn trapWeight(i: i32, j: i32) -> f32 {
41 var t = 1.0;
42 if (i == 0 || i == i32(P.nx) - 1) { t = t * 0.5; }
43 if (j == 0 || j == i32(P.ny) - 1) { t = t * 0.5; }
44 return t;
45}