← Back to team overview

yade-dev team mailing list archive

Re: Skip some geometrical calculations?

 

Hi Anton,
> Hi (Bruno?),
>
> it seems we are calculating distance between particles
> for each interaction.
Theoretically: no.
It depends on the implementation of each Ig2, which is only supposed to
return true or false.
Practically: yes. Ig2's will usually compare distances all the time, in
fact squared distances [1,2]. It is similar to LIGGGHT.
[1]  (pos2-pos1).squaredLength() < (rad1+rad2)^2 ?
[2]
https://github.com/yade/trunk/blob/master/pkg/dem/Ig2_Sphere_Sphere_ScGeom.cpp#L20

>  It looks like relatively expensive
> task. 
Note that there is no sqrt or division involved, at least.
> Can we somehow skip this step
No. Keeping virtual interactions to run the collider only each N steps
has a price: we must check at each step if a virtual becomes real.

>  and call it
> explicitly from contact law when we really need it?
Not really.
1/ If [1] returns false, we skip Ip2 and Law2 completely.
https://github.com/yade/trunk/blob/master/pkg/common/InteractionLoop.cpp#L110
Moving the same test to Law2 would need to run Ig2+Ip2+Law2 for all
virtual interactions all the time, which would be a real waste when
there are many of them.
With large Verlet dist. virtual can be 80% of the total, and most of
them will never reach the "Real" state. We better don't try to
assign+run Ip2 and Law2 for those.

2/ If [1] returns true, the distance vector defined for the initial test
is re-used for defining the normalized normal and the real distance.
There is no wasted operations (again see [2]).
A good implementation of a Law2 will not compute distance again:
https://github.com/yade/trunk/blob/master/pkg/dem/ElasticContactLaw.cpp#L49

To me it seems nearly optimal.
Cheers.

Bruno



References