principle of contact detection about polyhedra

Asked by lip

hello
i create many polyhedra to make them collison with each ohter, but when the numble of particles reach to 2000, the simulation become very slow. my computer have 64 cores ,the cpu is Xeon, 2.4Hz,i want to know the principle of the contact detection between polyhedra to find out how can i improve the performance. my code is as below:
from yade import polyhedra_utils,pack,plot
import random

m = PolyhedraMat()
m.density = 2600 # kg/m^3
m.young = 1E6 # Pa
m.poisson = 20000 / 1E6
m.frictionAngle = 0.6 # rad

O.bodies.append(utils.wall(-1, axis=2, sense=1, material=m))
O.bodies.append(utils.wall(20, axis=0, sense=-1, material=m))
O.bodies.append(utils.wall(0, axis=0, sense=1, material=m))
O.bodies.append(utils.wall(20, axis=1, sense=-1, material=m))
O.bodies.append(utils.wall(0, axis=1, sense=1, material=m))
# generate randomly spheres with uniform radius distribution
polyhedra_utils.fillBox((0,0,0),(20,20,20),m,seed=1)

O.engines = [
    ForceResetter(),
    InsertionSortCollider([Bo1_Polyhedra_Aabb(), Bo1_Wall_Aabb(), Bo1_Facet_Aabb()]),
    InteractionLoop(
        [Ig2_Wall_Polyhedra_PolyhedraGeom(), Ig2_Polyhedra_Polyhedra_PolyhedraGeom(),
         Ig2_Facet_Polyhedra_PolyhedraGeom()],
        [Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys()], # collision "physics"
        [Law2_PolyhedraGeom_PolyhedraPhys_Volumetric()] # contact law -- apply forces
    ),
    # GravityEngine(gravity=(0,0,-9.81)),
    NewtonIntegrator(damping=0.5, gravity=(0, 0, -9.81)),
    PyRunner(command='checkUnbalanced()', realPeriod=3, label='checker')
]
O.dt=1e-2

# enable energy tracking; any simulation parts supporting it
# can create and update arbitrary energy types, which can be
# accessed as O.energy['energyName'] subsequently
O.trackEnergy=True
# if the unbalanced forces goes below .05, the packing
# is considered stabilized, therefore we stop collected
# data history and stop
def checkUnbalanced():
   if unbalancedForce()<.05:
      O.bodies.erase(1)
      O.run()
      #plot.saveDataTxt('bbb.txt.bz2')
      # plot.saveGnuplot('bbb') is also possible

# collect history of data which will be plotted
def addPlotData():
   # each item is given a names, by which it can be the unsed in plot.plots
   # the **O.energy converts dictionary-like O.energy to plot.addData arguments
   plot.addData(i=O.iter,unbalanced=unbalancedForce(),**O.energy)

# define how to plot data: 'i' (step number) on the x-axis, unbalanced force
# on the left y-axis, all energies on the right y-axis
# (O.energy.keys is function which will be called to get all defined energies)
# None separates left and right y-axis
plot.plots={'i':('unbalanced',None,O.energy.keys)}

# show the plot on the screen, and update while the simulation runs
plot.plot()

O.saveTmp()

i would appreciate it if you can help me

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

> i create many polyhedra to make them collison with each ohter, but when the numble of particles reach to 2000, the simulation become very slow.

polyhedrons are much more complex than spheres, so also the performance is much worse just from this point of view

> i want to know the principle of the contact detection between polyhedra to find out how can i improve the performance.

Theory: [1], Elias2013, Elias2014
implementation: [2] pkg/dem/Polyedra*

The implementation could be improved (e.g. I remember a few places, where an instance of a non-trivial class is passed by value where passed by reference would be sufficient).
disclaimer: I have **NO idea** how much would be the gain.

Also I have a long time this idea in my mind: implement tetrahedrons as efficiently as possible and build generic polyhedron as a clump of these tetrahedrons. The question is if many "faster" tetrahedrons would be faster or not than one "slow" polyhedron.

cheers
Jan

[1] https://yade-dev.gitlab.io/trunk/publications.html
[2] https://gitlab.com/yade-dev/trunk/tree/master/pkg/dem

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#2

>my computer have 64 cores

The real question is more how many of them you are using. If each single interaction needs complex operations then the openmp acceleration should be better than for simple spheres.
Bruno

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#3

@Jan
>Also I have a long time this idea in my mind: implement tetrahedrons as efficiently as possible and build generic polyhedron as a clump of these tetrahedrons

Interesting. In a sense it is what PFacets are doing, except that the primitives are spheres, cylinders, and triangles.
They define a deformable truss by default but if they are clumped it becomes a rigid object. Some efficiency comparisons could be worth it.
Bruno

Can you help with this problem?

Provide an answer of your own, or ask lip for more information if necessary.

To post a message you must log in.