use crate::counters::Counters;
use crate::geometry::{self, HGrid, HGridEntry, ParticlesContacts};
use crate::math::Real;
use crate::object::Boundary;
use crate::object::Fluid;
pub struct ContactManager {
pub fluid_fluid_contacts: Vec<ParticlesContacts>,
pub fluid_boundary_contacts: Vec<ParticlesContacts>,
pub boundary_boundary_contacts: Vec<ParticlesContacts>,
}
impl ContactManager {
pub fn new() -> Self {
Self {
fluid_fluid_contacts: Vec::new(),
fluid_boundary_contacts: Vec::new(),
boundary_boundary_contacts: Vec::new(),
}
}
pub fn ncontacts(&self) -> usize {
self.fluid_fluid_contacts
.iter()
.map(|c| c.len())
.sum::<usize>()
+ self
.fluid_boundary_contacts
.iter()
.map(|c| c.len())
.sum::<usize>()
+ self
.boundary_boundary_contacts
.iter()
.map(|c| c.len())
.sum::<usize>()
}
pub fn update_contacts(
&mut self,
counters: &mut Counters,
h: Real,
fluids: &[Fluid],
boundaries: &[Boundary],
hgrid: &HGrid<HGridEntry>,
) {
geometry::compute_contacts(
counters,
h,
&fluids,
&boundaries,
&mut self.fluid_fluid_contacts,
&mut self.fluid_boundary_contacts,
&mut self.boundary_boundary_contacts,
hgrid,
);
}
}