pub struct PySphSim { /* private fields */ }Expand description
SPH particle simulation (simplified 3-D, poly6/spiky kernels).
Implementations§
Source§impl PySphSim
impl PySphSim
Sourcepub fn new(config: PySphConfig) -> Self
pub fn new(config: PySphConfig) -> Self
Create an empty SPH simulation.
Sourcepub fn add_particle(&mut self, pos: [f64; 3])
pub fn add_particle(&mut self, pos: [f64; 3])
Add a particle at position [x, y, z] with zero velocity.
Sourcepub fn add_particle_block(
&mut self,
origin: [f64; 3],
nx: usize,
ny: usize,
nz: usize,
dx: f64,
)
pub fn add_particle_block( &mut self, origin: [f64; 3], nx: usize, ny: usize, nz: usize, dx: f64, )
Add n particles arranged in a 3-D lattice starting at origin with
spacing dx.
Sourcepub fn particle_count(&self) -> usize
pub fn particle_count(&self) -> usize
Number of particles.
Sourcepub fn position(&self, i: usize) -> Option<[f64; 3]>
pub fn position(&self, i: usize) -> Option<[f64; 3]>
Get the position of particle i, or None if out of bounds.
Sourcepub fn velocity(&self, i: usize) -> Option<[f64; 3]>
pub fn velocity(&self, i: usize) -> Option<[f64; 3]>
Get the velocity of particle i, or None if out of bounds.
Sourcepub fn density(&self, i: usize) -> Option<f64>
pub fn density(&self, i: usize) -> Option<f64>
Get the density of particle i, or None if out of bounds.
Sourcepub fn pressure(&self, i: usize) -> Option<f64>
pub fn pressure(&self, i: usize) -> Option<f64>
Get the pressure of particle i, or None if out of bounds.
Sourcepub fn velocities_mut(&mut self) -> &mut Vec<[f64; 3]>
pub fn velocities_mut(&mut self) -> &mut Vec<[f64; 3]>
Mutable access to the velocity slice (for initial-condition setup).
Sourcepub fn smoothing_length(&self) -> f64
pub fn smoothing_length(&self) -> f64
Smoothing length h.
Sourcepub fn rest_density(&self) -> f64
pub fn rest_density(&self) -> f64
Rest density ρ₀.
Sourcepub fn particle_mass(&self) -> f64
pub fn particle_mass(&self) -> f64
Particle mass.
Sourcepub fn all_positions(&self) -> Vec<f64>
pub fn all_positions(&self) -> Vec<f64>
Return all positions as a flat Vecf64of[x, y, z]` triples.
Sourcepub fn all_velocities(&self) -> Vec<f64>
pub fn all_velocities(&self) -> Vec<f64>
Return all velocities as a flat Vecf64of[vx, vy, vz]` triples.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PySphSim
impl RefUnwindSafe for PySphSim
impl Send for PySphSim
impl Sync for PySphSim
impl Unpin for PySphSim
impl UnsafeUnpin for PySphSim
impl UnwindSafe for PySphSim
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.