Ip2_FrictMat_FrictViscoMat_FrictViscoPhys() law body assignation problem

Hi,

I was working with the Ip2_FrictMat_FrictViscoMat_FrictViscoPhys() law and I think there is a bug with it. In this little script, the two particles must be glued after contact, it is the case with the option 2 but in the option 1 it is not. The difference between the two options is only the position of the spheres (in one case the frictmat in on the top and in the other case this is the frictviscomat). I think the bug comes from this assignation of the material 1 and 2 in the C++ code but I'm not enough familiar with it to solve it.

I'm working with yadedaily : Yade 2017.01a-99-968a7593~trusty

Loïc

Here's the script:

###########################################################################################

from yade import qt, plot
from yade.gridpfacet import *
import gts, os, locale, sys
import numpy as np

O.engines=[
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor = 1)]),
    InteractionLoop([Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor = 1)],
            [Ip2_FrictMat_FrictViscoMat_FrictViscoPhys()],
            [Law2_ScGeom_FrictViscoPhys_CundallStrackVisco()]),
    NewtonIntegrator(gravity=(0,0,0),damping=0.3,label='newton'),
]

R = 0.008

##### Materiaux #####

FrictViscoMat = O.materials.append( FrictViscoMat(betan = 1,young=5e9, poisson=0.3, frictionAngle=radians(10),density = 4000))
FrictMat = O.materials.append( FrictMat(young=5e9, poisson=0.3, frictionAngle=radians(10),density = 4000))

#### Option 1 => Not Working
s1 = O.bodies.append(utils.sphere((0,0,2), radius=R,color=[1,0,0], material = FrictViscoMat))
s2 = O.bodies.append(utils.sphere((0,0,0), radius=R,color=[0,1,0], material = FrictMat))
O.bodies[s1].state.vel[2] = -5
O.bodies[s2].state.vel[2] = 5

#### Option 2 => Working
#s1 = O.bodies.append(utils.sphere((0,0,0), radius=R,color=[1,0,0], material = FrictViscoMat))
#s2 = O.bodies.append(utils.sphere((0,0,2), radius=R,color=[0,1,0], material = FrictMat))
#O.bodies[s1].state.vel[2] = 5
#O.bodies[s2].state.vel[2] = -5

#######
v=qt.Controller()
v=qt.View()
v.viewDir = (0,1,0)
v.eyePosition = Vector3( 0, -5,1)
O.run()
O.dt = 1e-7
O.saveTmp()

#########################################################################################

Original bug report by Loic Dugelas on 2017-09-22 : https://bugs.launchpad.net/yade/+bug/1718872

Edited by Janek Kozicki