DEM Lecture0224
DEM Lecture0224
Method
Midterm Project: Option 2
Motivation
Industries:
Problem
examples:
NASA, loyalkng.com,
cowboymining.com
Mining
Food &
Pharmaceutics
Film & Game
etc.
Collapsing Silos
Mars Rover
etc.
Collision
Detection
Contact
Force
Calculation
Newtons
2nd Law
Velocity
and
Position
Analysis
Output
Data
Collision
Detection
DEM
Contact
Force
Calculation
Newtons
2nd Law
Velocity
and
Position
Analysis
Spatial Subdivision
ri , rj
2 particles:
rij = ri rj
If rij d
ij = d rij
n ij =
rij
rij
Otherwise no collision
5
DEM
Collision
Detection
Contact
Force
Calculation
Newtons
2nd Law
Velocity
and
Position
Analysis
DEM
Contact
Force
Calculation
Newtons
2nd Law
Velocity
and
Position
Analysis
Contact force
components
Collision
Detection
normal
tangential
Four different
categories:
Continuous potential
models
Linear viscoelastic models
Non-linear viscoelastic
models
Collision
Detection
DEM
Contact
Force
Calculation
Velocity
and
Position
Analysis
Newtons
2nd Law
vij = vi v j
meff =
mi m j
(mi + m j )
v n = (vij n ij )n ij
ij
Fn
Normal Force
ij
ij
=
f
computed Fas:
n ij
d
(kn ij n ij n meff vn ij )
kn spring stiffness
n damping coefficient
8
DEM
Collision
Detection
Contact
Force
Calculation
Velocity
and
Position
Analysis
Newtons
2nd Law
( )
Fitot = mi g + Fn
j
Calculation acceleration:
Fitot
= mi a i a i =
ij
Fitot
mi
DEM
Collision
Detection
Contact
Force
Calculation
Newtons
2nd Law
Velocity
and
Position
Analysis
Explicit Euler:
ri (t + t ) = ri (t ) + vi (t )t
vi (t + t ) = vi (t ) + a i (t )t
10
Parallelism
11
Example
1 million
spheres
0.5 sec long
simulation
~12,000 sec
computational
time
GPU
12
Class ParticleSystem
void initializeSim()
void performCD()
void computeForces()
void integrate()
void getGPUdata()
void outputState()
13
void initializeSim()
void performCD()
14
void computeForces()
void integrate()
void getGPUdata()
void outputState()
16
main function
int main(int argc, char* argv[])
{
float t_curr=0.0f;
float t_end=1.0f;
float h=0.00005f;
ParticleSystem *psystem = new ParticleSystem();
psystem->initializeSim();
while(t_curr<=t_end)
{
psystem->performCD();
psystem->computeForces();
psystem->integrate();
t_curr+=h;
}
delete psystem;
return 0;
}
17
2.
thrust::sort_by_key()
18
4.
thrust::reduce_by_key()
One thread per entry in output, copy to
appropriate place in net force list
19
Compute d = N (r p)
Contact if d<radius
Compute force as before, add to net force
20
Overview
Easier implementation
O(N2) Complexity
More involved
O(N) Complexity
22
Three Steps:
23
Step 1, cont.
25
Step 2.1: Define first a structure that might help (this is not the most
efficient approach, but well go along with it)
struct collisionInfo {
float3 rA;
float3 rB;
float3 normal;
unsigned int indxA;
unsigned int indxB;
}
Step 2.2: Run a parallel inclusive prefix scan on dB, which gets
overwritten during the process
Step 2.3: Based on the last entry in the dB array, which holds the total
number of contacts, allocate from the host on the device the amount of
memory required to store the desired collision information. To this end
youll have to use the size of the struct collisionInfo. Call this array
dCollisionInfo.
26
Step 3
Parallel pass on a per body basis (one thread per body similar
to step 1)
Step 3, O(N2) (checking body against the rest of the bodies, basically a
repetition of Step 1)
Not discussed here for this brute force idea, rather moving on to a different
approach altogether, called binning
28
Parallel Binning
29
Taking the bin to be small means that chances are youll not have
too many bodies inside any bin for the brute force stage
31
CD: Binning
Parallel Sorting
32
Notation Use:
N number of bodies
Nb number of bins
Na number of active bins
pi - body i
bj bin j
zmax
hz
xmin
ymin
zmin
ymax
hx
hy
xmax
33
34
Save to the side the number of bins touched by the last body, needed
later, otherwise overwritten by the scan operation. Call this value blast
In our case, if you look carefully, blast = 6
35
36
Stage 4: Sort
37
38
39
The Value
C-array
10
...
The Key
...
A1
A2
A3
A4
A5
B1
...
40
41
In order to carry out this stage you need to keep in mind how C is
organized, which is a reflection of how B is organized
42
In order to carry out this stage you need to keep in mind how C is
organized, which is a reflection of how B is organized
43
Zoom
in...
44
Easy to define the CMCV for two spheres, two ellipsoids, and a couple of other
simple geometries
Finding the CMCV is the subject of the so called narrow phase collision detection
Itll be simple in our case since we are going to work with simple geometry primitives
45
46
Array E stores the required collision information: normal, two tangents, etc.
Number of entries in the array: Nc (see previous slide)
Not discussed in greater detail, this is just like Stage 7, but now you have to
generate actual collision info (stage 7 was the rehearsal)
47
Based on info in C you pick up from B the bin id and bodies touching this bin
You run brute force CD for as long as necessary to find the number of
collisions specified by array D
Note that in some cases there are no collisions, so you exit without doing
anything
Stage 1: Find number of bins touched by each body, populate T (body parallel)
50
Stage 12: Run collision detection and populate E with required info (bin parallel)
51
Can you eliminate stage 5 (the binary search) and use info from the sort
of stage 4?
Does it make sense to have a second sort for load balancing (as we
have right now)?
52
At the cornerstone of the proposed approach is the fact that one can very
easily find the bins that a simple geometry intersects