Skip to main content

SphLiquidSolver3D

Struct SphLiquidSolver3D 

Source
pub struct SphLiquidSolver3D { /* private fields */ }
Expand description

Production Position-Based Fluids (PBF/SPH) 2D & 3D particle liquid engine with zero steady-state allocations.

Implementations§

Source§

impl SphLiquidSolver3D

Simulation, spawner, collider, emitter, drain, and diagnostics API for SphLiquidSolver3D.

Source

pub fn from_config(config: SphSolverConfig) -> Self

Constructs a pre-allocated SphLiquidSolver3D from config so step(dt) performs zero heap allocations.

§Arguments
  • SphSolverConfig - Desired 2D or 3D PBF/SPH solver configuration.
§Returns
  • Self - Ready pre-allocated solver.
Source

pub fn clear_particles(&mut self)

Removes all active particles and resets step counters while preserving colliders and pre-allocated capacity.

Source

pub fn add_collider(&mut self, collider: SphSolidCollider)

Registers a composable solid collider (Box, Sphere, Capsule, Cylinder, Plane, or MovingContainer).

§Arguments
  • SphSolidCollider - Collider to append to the active simulation.
Source

pub fn add_emitter(&mut self, emitter: SphFluidEmitter)

Registers a continuous fluid particle emitter.

§Arguments
  • SphFluidEmitter - Emitter configuration to append.
Source

pub fn add_drain(&mut self, drain: SphFluidDrain)

Registers a spherical particle drain sink.

§Arguments
  • SphFluidDrain - Drain sink configuration to append.
Source

pub fn spawn_particle(&mut self, position: Vec3, velocity: Vec3) -> bool

Spawns a single liquid particle if active capacity permits.

§Arguments
  • Vec3 - Initial world-space particle position.
  • Vec3 - Initial world-space particle velocity.
§Returns
  • bool - true if the particle was spawned, false when at capacity.
Source

pub fn spawn_box_block( &mut self, min_corner: Vec3, max_corner: Vec3, spacing: f32, ) -> usize

Spawns a packed 2D or 3D rectangular block of liquid particles with tiny deterministic jitter.

§Arguments
  • Vec3 - Minimum corner of the liquid block.
  • Vec3 - Maximum corner of the liquid block.
  • f32 - Nominal lattice spacing in meters (<= 0.0 defaults to h / 2.5).
§Returns
  • usize - Number of newly spawned particles.
Source

pub fn spawn_sphere_cluster( &mut self, center: Vec3, radius: f32, spacing: f32, ) -> usize

Spawns a spherical (or circular in Dim2) cluster of liquid particles.

§Arguments
  • Vec3 - Cluster center position in world space.
  • f32 - Cluster radius in meters.
  • f32 - Nominal lattice spacing in meters (<= 0.0 defaults to h / 2.5).
§Returns
  • usize - Number of newly spawned particles.
Source

pub fn step(&mut self, dt_secs: f32)

Advances the PBF/SPH liquid simulation by dt_secs with zero steady-state heap allocations.

§Arguments
  • f32 - Frame step duration in seconds.
Source

pub fn stats(&self) -> SphSolverStats

Computes live density convergence, kinetic energy, and total mass diagnostics across all active particles.

§Returns
  • SphSolverStats - Aggregate particle statistics snapshot.
Source§

impl SphLiquidSolver3D

Implements impl #impl_generics #name #ty_generics #where_clause.

Source

pub fn get_config(&self) -> SphSolverConfig

Source

pub fn get_mut_config(&mut self) -> &mut SphSolverConfig

Source

pub fn set_config(&mut self, val: SphSolverConfig) -> &mut Self

Source

pub fn get_particles(&self) -> &Vec<SphParticle>

Source

pub fn get_mut_particles(&mut self) -> &mut Vec<SphParticle>

Source

pub fn set_particles(&mut self, val: Vec<SphParticle>) -> &mut Self

Source

pub fn get_colliders(&self) -> &Vec<SphSolidCollider>

Source

pub fn get_mut_colliders(&mut self) -> &mut Vec<SphSolidCollider>

Source

pub fn set_colliders(&mut self, val: Vec<SphSolidCollider>) -> &mut Self

Source

pub fn get_emitters(&self) -> &Vec<SphFluidEmitter>

Source

pub fn get_mut_emitters(&mut self) -> &mut Vec<SphFluidEmitter>

Source

pub fn set_emitters(&mut self, val: Vec<SphFluidEmitter>) -> &mut Self

Source

pub fn get_drains(&self) -> &Vec<SphFluidDrain>

Source

pub fn get_mut_drains(&mut self) -> &mut Vec<SphFluidDrain>

Source

pub fn set_drains(&mut self, val: Vec<SphFluidDrain>) -> &mut Self

Source

pub fn get_scratch(&self) -> &SphScratchBuffers

Source

pub fn get_mut_scratch(&mut self) -> &mut SphScratchBuffers

Source

pub fn set_scratch(&mut self, val: SphScratchBuffers) -> &mut Self

Source

pub fn get_rng_state(&self) -> u64

Source

pub fn get_mut_rng_state(&mut self) -> &mut u64

Source

pub fn set_rng_state(&mut self, val: u64) -> &mut Self

Source

pub fn get_step_count(&self) -> u64

Source

pub fn get_mut_step_count(&mut self) -> &mut u64

Source

pub fn set_step_count(&mut self, val: u64) -> &mut Self

Source

pub fn get_sim_time_secs(&self) -> f32

Source

pub fn get_mut_sim_time_secs(&mut self) -> &mut f32

Source

pub fn set_sim_time_secs(&mut self, val: f32) -> &mut Self

Trait Implementations§

Source§

impl Clone for SphLiquidSolver3D

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SphLiquidSolver3D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SphLiquidSolver3D

Default empty 3D SphLiquidSolver3D.

Source§

fn default() -> Self

Creates a pre-allocated 3D SphLiquidSolver3D with default physical parameters.

§Returns
  • Self - Pre-allocated PBF/SPH solver.
Source§

impl PartialEq for SphLiquidSolver3D

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SphLiquidSolver3D

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.