pub struct Fluid {
pub nonpressure_forces: Vec<Box<dyn NonPressureForce>>,
pub positions: Vec<Point<Real>>,
pub velocities: Vec<Vector<Real>>,
pub accelerations: Vec<Vector<Real>>,
pub volumes: Vec<Real>,
pub density0: Real,
/* private fields */
}
Expand description
A fluid object.
A fluid object is composed of movable particles with additional properties like viscosity.
Fields§
§nonpressure_forces: Vec<Box<dyn NonPressureForce>>
Nonpressure forces this fluid is subject to.
positions: Vec<Point<Real>>
The world-space position of the fluid particles.
velocities: Vec<Vector<Real>>
The velocities of the fluid particles.
accelerations: Vec<Vector<Real>>
The accelerations of the fluid particles.
volumes: Vec<Real>
The volume of the fluid particles.
density0: Real
The rest density of this fluid.
Implementations§
source§impl Fluid
impl Fluid
sourcepub fn new(
particle_positions: Vec<Point<Real>>,
particle_radius: Real,
density0: Real
) -> Self
pub fn new( particle_positions: Vec<Point<Real>>, particle_radius: Real, density0: Real ) -> Self
Initializes a new fluid object with the given particle positions, particle radius, density, and viscosity.
The particle radius should be the same as the radius used to initialize the liquid world.
sourcepub fn delete_particle_at_next_timestep(&mut self, particle: usize)
pub fn delete_particle_at_next_timestep(&mut self, particle: usize)
Mark the given particle to be deleted at the next timestep.
sourcepub fn num_deleted_particles(&self) -> usize
pub fn num_deleted_particles(&self) -> usize
The number of particles that will be deleted at the next timestep.
sourcepub fn deleted_particles_mask(&self) -> &[bool]
pub fn deleted_particles_mask(&self) -> &[bool]
The mask of particles that will be deleted at the next timestep.
sourcepub fn particle_radius(&self) -> Real
pub fn particle_radius(&self) -> Real
The radius of this fluid’s particles.
sourcepub fn default_particle_volume(&self) -> Real
pub fn default_particle_volume(&self) -> Real
The default volume given to each of this fluid’s particles.
sourcepub fn add_particles(
&mut self,
positions: &[Point<Real>],
velocities: Option<&[Vector<Real>]>
)
pub fn add_particles( &mut self, positions: &[Point<Real>], velocities: Option<&[Vector<Real>]> )
Add a set of particles to this fluid.
If velocities
is None
the velocity of each particle will be initialized at zero.
If it is not None
, then it must be a slice with the same length than positions
.
sourcepub fn transform_by(&mut self, t: &Isometry<Real>)
pub fn transform_by(&mut self, t: &Isometry<Real>)
Apply the given transformation to each particle of this fluid.
sourcepub fn num_particles(&self) -> usize
pub fn num_particles(&self) -> usize
The number of particles on this fluid.
sourcepub fn particle_mass(&self, i: usize) -> Real
pub fn particle_mass(&self, i: usize) -> Real
The mass of the i
-th particle of this fluid.
sourcepub fn particle_inv_mass(&self, i: usize) -> Real
pub fn particle_inv_mass(&self, i: usize) -> Real
The inverse mass of the i
-th particle of this fluid.
Returns 0 if the i
-th particle has a zero mass.
Auto Trait Implementations§
impl !RefUnwindSafe for Fluid
impl Send for Fluid
impl Sync for Fluid
impl Unpin for Fluid
impl !UnwindSafe for Fluid
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
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.