pub struct WaterSimGpu {
pub height: FluidGpuBuffer,
pub velocity: FluidGpuBuffer,
pub rest_depth: f64,
pub gravity: f64,
pub dx: f64,
pub damping: f64,
}Expand description
GPU shallow-water equation (SWE) solver for height field and ripple simulation on a 2-D grid.
Uses the linearised SWE: ∂h/∂t + H ∇·u = 0, ∂u/∂t + g ∇h = 0.
Fields§
§height: FluidGpuBufferHeight field h(x, y) — 1 component per cell (m above rest level).
velocity: FluidGpuBufferHorizontal velocity field — 2 components (u_x, u_y) per cell.
rest_depth: f64Rest water depth H (m).
gravity: f64Gravitational acceleration (m/s²).
dx: f64Grid cell size (m).
damping: f64Damping coefficient per step (fraction).
Implementations§
Source§impl WaterSimGpu
impl WaterSimGpu
Sourcepub fn new(nx: usize, ny: usize, dx: f64, rest_depth: f64, gravity: f64) -> Self
pub fn new(nx: usize, ny: usize, dx: f64, rest_depth: f64, gravity: f64) -> Self
Create a new WaterSimGpu for a nx × ny grid.
Sourcepub fn add_disturbance(&mut self, cx: usize, cy: usize, amp: f64, sigma: f64)
pub fn add_disturbance(&mut self, cx: usize, cy: usize, amp: f64, sigma: f64)
Apply a ripple disturbance at cell (cx, cy) with amplitude amp and
Gaussian radius sigma (in cells).
Sourcepub fn max_height_deviation(&self) -> f64
pub fn max_height_deviation(&self) -> f64
Compute the maximum absolute height deviation from rest.
Trait Implementations§
Source§impl Clone for WaterSimGpu
impl Clone for WaterSimGpu
Source§fn clone(&self) -> WaterSimGpu
fn clone(&self) -> WaterSimGpu
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WaterSimGpu
impl RefUnwindSafe for WaterSimGpu
impl Send for WaterSimGpu
impl Sync for WaterSimGpu
impl Unpin for WaterSimGpu
impl UnsafeUnpin for WaterSimGpu
impl UnwindSafe for WaterSimGpu
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more