yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #10418
Make Law2's return bool?
Hi there,
I would like feedback on a possible change in interactions handling.
Years ago, the collider in yade was supposed to create and delete
interactions.
It didn't last long before problems of this design emerge. If a contact
has tensile strength, for instance, the interaction is supposed to
persist even when the geometrical contact is lost, which the collider
has no clue about. The problem is the same when capillary forces are
superimposed with contact forces.
So, we progressively moved to a situation where the Law2 functors have
to declare (requestErase) when an interaction is really lost (then the
collider may erase it immediatly or not depending its own logic). Yet
the move is incomplete and traces of the old logic remain here and there.
I realize that this requirement is an additional difficulty in the
implementation of contact laws, which is easily overlooked. If someone
forget to erase in his contact law, it will result in memory leak (maybe
the case in [1], though still to be investigated).
I think the requestErase could be moved outside Law2 functors, in
InteractionLoop, and based on the return value of Law2 (true/false). The
need to define the return value would make the requirement more visible
for future devs, and it will let us inherit Law2's more easily.
Something like this would be ok:
bool ChildLaw2::go() {
bool parentErase = ParentLaw2::go();
// do additional stuff, not possible now since parent may have
erased already
if (parentErase and childErase) return false;
else return true;
}
The change is relatively easy to implement. Feel free to comment on this
solution before I (or somebody else) implement it.
Bruno
[1] https://answers.launchpad.net/yade/+question/242890
--
_______________
Bruno Chareyre
Associate Professor
ENSE³ - Grenoble INP
Lab. 3SR
BP 53
38041 Grenoble cedex 9
Tél : +33 4 56 52 86 21
Fax : +33 4 76 82 70 43
________________
Follow ups