1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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,
);
}
}