← Back to team overview

yade-users team mailing list archive

[Question #682649]: Sphere losing interaction with PFacet after moving it to other scene

 

New question #682649 on Yade:
https://answers.launchpad.net/yade/+question/682649

Hello,
I've been trying to use two scenes to handle different stages of my simulation. When one of these stage is over, I copy the spheres from one scene to add them to the other scene. The problem I'm running into is that, despite using the same engines, the spheres interact normally with walls (made of PFacets) in their original scene , but when I delete them and add them to the other scene, they just go through the walls without interacting with them.
Here is an example script using a single sphere and two scenes:

#Import Libraries
from yade.gridpfacet import *
from yade import pack,plot
import math
import random as rand
import numpy as np

# Time step
O.dt=1e-5
Factor=10
RNode=0.01
color=[0.,1.,1.]
gravityVector = Vector3(0.,-9.81,0.)

#Creation of the materials used in the simulation
O.materials.append(FrictMat(density=2500,frictionAngle=math.radians(35.),poisson=0.2,young=1e7,label='Frict')) #Material for the debris flow
O.materials.append(FrictMat(density=2500,frictionAngle=math.radians(70.),poisson=0.2,young=1e7,label='FrictBase'))
O.materials.append( CohFrictMat( young=6e8,poisson=0.3,density=2650,frictionAngle=radians(70.),normalCohesion=3e100,shearCohesion=3e100,momentRotationLaw=True,label='gridNodeMat' ) )  # material to create the gridConnections


engines=[
    ForceResetter(),
	InsertionSortCollider(
	[
		Bo1_Sphere_Aabb(aabbEnlargeFactor=Factor, label="aabb"),
		Bo1_GridConnection_Aabb(),
		Bo1_PFacet_Aabb(),
		Bo1_Facet_Aabb(),
	],
	verletDist=-0.1,
	allowBiggerThanPeriod=False),
	InteractionLoop(
	#Geometry functors
	[
		Ig2_Sphere_Sphere_ScGeom(),
		Ig2_GridNode_GridNode_GridNodeGeom6D(),			#Gridnode-Gridnode
		Ig2_GridConnection_GridConnection_GridCoGridCoGeom(),	#Gridconnec-Gridconnec
		Ig2_Sphere_GridConnection_ScGridCoGeom(),		#Gridconnec-GridNode
		Ig2_GridConnection_PFacet_ScGeom(),			#Gridconnec-Pfacet
		Ig2_Sphere_PFacet_ScGridCoGeom(),			#Sphere-Pfacet => required for Gridnode Pfacet
		Ig2_Sphere_Sphere_ScGeom6D(interactionDetectionFactor=Factor,label="Ig2"),
		Ig2_PFacet_PFacet_ScGeom()

    ],
	#Physic functors
	[
		Ip2_FrictMat_FrictMat_LubricationPhys(eta=2,eps=0.01),
        Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()
	],
	#Law functors
	[
		Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),
		Law2_ScGeom_FrictPhys_CundallStrack(),
		Law2_ScGridCoGeom_FrictPhys_CundallStrack(),
		Law2_ScGeom_WirePhys_WirePM(label='Law_1'), #linkThresholdIteration=1,
		Law2_GridCoGridCoGeom_FrictPhys_CundallStrack(),
		Law2_ScGeom_ImplicitLubricationPhys()
	]
    ),
    NewtonIntegrator(gravity=gravityVector),
    PyRunner(command='moveSphereToScene()',iterPeriod=500,label='moveSphere',dead=False)
    ]

def addWall():
    nodes=[]
    wall=[]
    nodes.append(O.bodies.append( gridNode([-3.,-3.,-3.],RNode,wire=False,fixed=True,material='gridNodeMat',color=color) ))
    nodes.append(O.bodies.append( gridNode([3.,-3.,-3.],RNode,wire=False,fixed=True,material='gridNodeMat',color=color) ))
    nodes.append(O.bodies.append( gridNode([-3.,-3.,3.],RNode,wire=False,fixed=True,material='gridNodeMat',color=color) ))
    nodes.append(O.bodies.append( gridNode([3.,-3.,3.],RNode,wire=False,fixed=True,material='gridNodeMat',color=color) ))
    for i in nodes:
        for j in nodes:
            if j<i:
                O.bodies.append(gridConnection(i,j,RNode,color=color,material='gridNodeMat'))

    wall.append(O.bodies.append(pfacet(nodes[0],nodes[1],nodes[2],wire=True,material='FrictBase',color=color)))
    wall.append(O.bodies.append(pfacet(nodes[1],nodes[2],nodes[3],wire=True,material='FrictBase',color=color)))

O.engines=engines
addWall()
O.addScene()
O.switchToScene(1)
O.engines=engines
O.dt=1e-5
O.materials.append(FrictMat(density=2500,frictionAngle=math.radians(35.),poisson=0.2,young=1e7,label='Frict')) #Material for the debris flow
O.materials.append(FrictMat(density=2500,frictionAngle=math.radians(70.),poisson=0.2,young=1e7,label='FrictBase'))
O.materials.append( CohFrictMat( young=6e8,poisson=0.3,density=2650,frictionAngle=radians(70.),normalCohesion=3e100,shearCohesion=3e100,momentRotationLaw=True,label='gridNodeMat' ) )  # material to create the gridConnections
addWall()
s1=O.bodies.append(sphere(center=(0,0,0),radius=1,material='Frict'))

def moveSphereToScene(): #delete the sphere from scene 1 and copy it to scene 0
    global s1
    if O.iter >1000 and O.thisScene==1:
        sbody=O.bodies[s1]
        O.bodies.erase(s1)
        O.switchToScene(0)
        O.bodies.append(sbody)
        s1=sbody.id
        moveSphere.dead=True


As you can see, if you set moveSphere.dead=True, the sphere will bounce on the wall as it should. But if you set moveSphere.dead=False, it will go through the wall after being moved to the other scene.
I am using the 2019-06-20.git-5b59e90 version of Yade, but I have the same problem with older git versions of Yade.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.