pub struct GpuSphPressureSolver {
pub n_particles: usize,
pub pressure: Vec<f64>,
pub density: Vec<f64>,
pub positions: Vec<[f64; 3]>,
pub masses: Vec<f64>,
pub smoothing_h: f64,
pub rest_density: f64,
pub stiffness: f64,
}Expand description
GPU SPH pressure solver holding all per-particle state.
Fields§
§n_particles: usizeTotal number of simulated particles.
pressure: Vec<f64>Per-particle pressure values (Pa).
density: Vec<f64>Per-particle density values (kg/m³).
positions: Vec<[f64; 3]>Per-particle positions [x, y, z] in metres.
masses: Vec<f64>Per-particle masses (kg).
smoothing_h: f64Smoothing length h (m).
rest_density: f64Rest density ρ₀ (kg/m³).
stiffness: f64Stiffness constant k for the linearised EOS.
Implementations§
Source§impl GpuSphPressureSolver
impl GpuSphPressureSolver
Sourcepub fn new(n: usize, h: f64, rho0: f64, k: f64) -> Self
pub fn new(n: usize, h: f64, rho0: f64, k: f64) -> Self
Create a new solver with n particles, smoothing length h,
rest density rho0, and stiffness k.
Sourcepub fn particle_count(&self) -> usize
pub fn particle_count(&self) -> usize
Return the number of particles in this solver.
Sourcepub fn set_position(&mut self, i: usize, pos: [f64; 3])
pub fn set_position(&mut self, i: usize, pos: [f64; 3])
Set the position of particle i.
Sourcepub fn total_mass(&self) -> f64
pub fn total_mass(&self) -> f64
Compute total mass of all particles.
Sourcepub fn density_error(&self) -> f64
pub fn density_error(&self) -> f64
Compute the maximum relative density error: max |ρᵢ − ρ₀| / ρ₀.
Sourcepub fn compute_stats(&self) -> GpuSphStats
pub fn compute_stats(&self) -> GpuSphStats
Compute density statistics.
Sourcepub fn gpu_compute_density(&mut self)
pub fn gpu_compute_density(&mut self)
Mock GPU density computation: ρᵢ = Σⱼ mⱼ · W_poly6(|rᵢ − rⱼ|, h).
Sourcepub fn gpu_compute_pressure(&mut self)
pub fn gpu_compute_pressure(&mut self)
Mock GPU pressure computation: pᵢ = k · (ρᵢ − ρ₀).
Sourcepub fn gpu_pressure_force(&self, i: usize) -> [f64; 3]
pub fn gpu_pressure_force(&self, i: usize) -> [f64; 3]
Compute pressure force on particle i:
F_press_i = −Σⱼ mⱼ (pᵢ/ρᵢ² + pⱼ/ρⱼ²) ∇W_spiky.
Trait Implementations§
Source§impl Clone for GpuSphPressureSolver
impl Clone for GpuSphPressureSolver
Source§fn clone(&self) -> GpuSphPressureSolver
fn clone(&self) -> GpuSphPressureSolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for GpuSphPressureSolver
impl RefUnwindSafe for GpuSphPressureSolver
impl Send for GpuSphPressureSolver
impl Sync for GpuSphPressureSolver
impl Unpin for GpuSphPressureSolver
impl UnsafeUnpin for GpuSphPressureSolver
impl UnwindSafe for GpuSphPressureSolver
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
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>
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>
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