pub struct SphSystemData3 { /* private fields */ }Expand description
§3-D SPH particle system data.
This class extends ParticleSystemData3 to specialize the data model for SPH. It includes density and pressure array as a default particle attribute, and it also contains SPH utilities such as interpolation operator.
Implementations§
Source§impl SphSystemData3
impl SphSystemData3
Sourcepub fn new_default() -> SphSystemData3
pub fn new_default() -> SphSystemData3
Constructs empty SPH system.
Sourcepub fn new(number_of_particles: usize) -> SphSystemData3
pub fn new(number_of_particles: usize) -> SphSystemData3
Constructs SPH system data with given number of particles.
Source§impl SphSystemData3
impl SphSystemData3
Sourcepub fn set_radius(&mut self, new_radius: f64)
pub fn set_radius(&mut self, new_radius: f64)
\brief Sets the radius.
Sets the radius of the particle system. The radius will be interpreted as target spacing.
Sourcepub fn set_mass(&mut self, new_mass: f64)
pub fn set_mass(&mut self, new_mass: f64)
\brief Sets the mass of a particle.
Setting the mass of a particle will change the target density.
- parameter: new_mass The new mass.
Sourcepub fn densities_mut(&mut self) -> &mut Vec<f64>
pub fn densities_mut(&mut self) -> &mut Vec<f64>
Returns the density array accessor (mutable).
Sourcepub fn pressures_mut(&mut self) -> &mut Vec<f64>
pub fn pressures_mut(&mut self) -> &mut Vec<f64>
Returns the pressure array accessor (mutable).
Sourcepub fn update_densities(&mut self)
pub fn update_densities(&mut self)
\brief Updates the density array with the latest particle positions.
This function updates the density array by recalculating each particle’s latest nearby particles’ position.
\warning You must update the neighbor searcher (SphSystemData3::build_neighbor_searcher) before calling this function.
Sourcepub fn set_target_density(&mut self, target_density: f64)
pub fn set_target_density(&mut self, target_density: f64)
Sets the target density of this particle system.
Sourcepub fn target_density(&self) -> f64
pub fn target_density(&self) -> f64
Returns the target density of this particle system.
Sourcepub fn set_target_spacing(&mut self, spacing: f64)
pub fn set_target_spacing(&mut self, spacing: f64)
\brief Sets the target particle spacing in meters.
Once this function is called, hash grid and density should be updated using updateHashGrid() and update_densities).
Sourcepub fn target_spacing(&self) -> f64
pub fn target_spacing(&self) -> f64
Returns the target particle spacing in meters.
Sourcepub fn set_relative_kernel_radius(&mut self, relative_radius: f64)
pub fn set_relative_kernel_radius(&mut self, relative_radius: f64)
\brief Sets the relative kernel radius.
Sets the relative kernel radius compared to the target particle spacing (i.e. kernel radius / target spacing). Once this function is called, hash grid and density should be updated using updateHashGrid() and update_densities).
Sourcepub fn relative_kernel_radius(&self) -> f64
pub fn relative_kernel_radius(&self) -> f64
\brief Returns the relative kernel radius.
Returns the relative kernel radius compared to the target particle spacing (i.e. kernel radius / target spacing).
Sourcepub fn set_kernel_radius(&mut self, kernel_radius: f64)
pub fn set_kernel_radius(&mut self, kernel_radius: f64)
\brief Sets the absolute kernel radius.
Sets the absolute kernel radius compared to the target particle spacing (i.e. relative kernel radius * target spacing). Once this function is called, hash grid and density should be updated using updateHashGrid() and update_densities).
Sourcepub fn kernel_radius(&self) -> f64
pub fn kernel_radius(&self) -> f64
Returns the kernel radius in meters unit.
Sourcepub fn sum_of_kernel_nearby(&self, origin: &Vector3D) -> f64
pub fn sum_of_kernel_nearby(&self, origin: &Vector3D) -> f64
Returns sum of kernel function evaluation for each nearby particle.
Sourcepub fn interpolate_scalar(&self, origin: &Vector3D, values: &Vec<f64>) -> f64
pub fn interpolate_scalar(&self, origin: &Vector3D, values: &Vec<f64>) -> f64
\brief Returns interpolated value at given origin point.
Returns interpolated scalar data from the given position using standard SPH weighted average. The data array should match the particle layout. For example, density or pressure arrays can be used.
\warning You must update the neighbor searcher (SphSystemData3::build_neighbor_searcher) before calling this function.
Sourcepub fn interpolate_vec(
&self,
origin: &Vector3D,
values: &Vec<Vector3D>,
) -> Vector3D
pub fn interpolate_vec( &self, origin: &Vector3D, values: &Vec<Vector3D>, ) -> Vector3D
\brief Returns interpolated vector value at given origin point.
Returns interpolated vector data from the given position using standard SPH weighted average. The data array should match the particle layout. For example, velocity or acceleration arrays can be used.
\warning You must update the neighbor searcher (SphSystemData3::build_neighbor_searcher) before calling this function.
Sourcepub fn gradient_at(&self, i: usize, values: &Vec<f64>) -> Vector3D
pub fn gradient_at(&self, i: usize, values: &Vec<f64>) -> Vector3D
Returns the gradient of the given values at i-th particle.
\warning You must update the neighbor lists (SphSystemData3::build_neighbor_lists) before calling this function.
Sourcepub fn laplacian_at_scalar(&self, i: usize, values: &Vec<f64>) -> f64
pub fn laplacian_at_scalar(&self, i: usize, values: &Vec<f64>) -> f64
Returns the laplacian of the given values at i-th particle.
\warning You must update the neighbor lists (SphSystemData3::build_neighbor_lists) before calling this function.
Sourcepub fn laplacian_at_vec(&self, i: usize, values: &Vec<Vector3D>) -> Vector3D
pub fn laplacian_at_vec(&self, i: usize, values: &Vec<Vector3D>) -> Vector3D
Returns the laplacian of the given values at i-th particle.
\warning You must update the neighbor lists (SphSystemData3::build_neighbor_lists) before calling this function.
Sourcepub fn build_neighbor_searcher(&mut self)
pub fn build_neighbor_searcher(&mut self)
Builds neighbor searcher with kernel radius.
Sourcepub fn build_neighbor_lists(&mut self)
pub fn build_neighbor_lists(&mut self)
Builds neighbor lists with kernel radius.
Source§impl SphSystemData3
impl SphSystemData3
Sourcepub fn positions_mut(&mut self) -> &mut Vec<Vector3D> ⓘ
pub fn positions_mut(&mut self) -> &mut Vec<Vector3D> ⓘ
Returns the position array (mutable).
Sourcepub fn velocities(&self) -> &Vec<Vector3D> ⓘ
pub fn velocities(&self) -> &Vec<Vector3D> ⓘ
Returns the velocity array (immutable).
Sourcepub fn velocities_mut(&mut self) -> &mut Vec<Vector3D> ⓘ
pub fn velocities_mut(&mut self) -> &mut Vec<Vector3D> ⓘ
Returns the velocity array (mutable).
Sourcepub fn forces_mut(&mut self) -> &mut Vec<Vector3D> ⓘ
pub fn forces_mut(&mut self) -> &mut Vec<Vector3D> ⓘ
Returns the force array (mutable).
Sourcepub fn number_of_particles(&self) -> usize
pub fn number_of_particles(&self) -> usize
Returns the number of particles.
Sourcepub fn neighbor_lists(&self) -> &Vec<Vec<usize>>
pub fn neighbor_lists(&self) -> &Vec<Vec<usize>>
\brief Returns neighbor lists.
This function returns neighbor lists which is available after calling PointParallelHashGridSearcher2::build_neighbor_lists. Each list stores indices of the neighbors.
\return Neighbor lists.
Auto Trait Implementations§
impl Freeze for SphSystemData3
impl RefUnwindSafe for SphSystemData3
impl Send for SphSystemData3
impl Sync for SphSystemData3
impl Unpin for SphSystemData3
impl UnwindSafe for SphSystemData3
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> 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