← Back to team overview

yade-users team mailing list archive

Re: [Question #632960]: How to erase GridConnection

 

Question #632960 on Yade changed:
https://answers.launchpad.net/yade/+question/632960

Klaus Thoeni proposed the following answer:
Hi Loic,

I played a bit with it myself and the trick is to also delete the non
real interaction. Also, I would first delete the body and then the
interaction because in theory erasing the body should also erase the
interaction. The latter is however not implemented yet but I will
probably do it in the future. Anyway, here my MWE. You can delete the
cylinder and create one as many times as you want. This works for me.

# encoding: utf-8
from yade.gridpfacet import *

#### Parameters ####
L=2. # minimum length
r=0.5		# radius of the cylinder element
phi=30. # friction angle
E=1e6   # Young's modulus

#### Engines ####
O.engines=[
	ForceResetter(),
	InsertionSortCollider([
		Bo1_GridConnection_Aabb(),
		Bo1_Sphere_Aabb(),
		Bo1_Wall_Aabb(),
	]),
	InteractionLoop([
		Ig2_GridNode_GridNode_GridNodeGeom6D(),
		Ig2_GridConnection_GridConnection_GridCoGridCoGeom(),
		Ig2_Wall_Sphere_ScGeom(),
	],
	[
		Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=False),
		Ip2_FrictMat_FrictMat_FrictPhys()
	],
	[
		Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),	# contact law for "internal" cylider forces
		Law2_ScGridCoGeom_FrictPhys_CundallStrack(),	# contact law for Cylinder-pFacet interaction
		Law2_GridCoGridCoGeom_FrictPhys_CundallStrack()	# contact law for cylinder-cylinder interaction
	]
	),
	GlobalStiffnessTimeStepper(timestepSafetyCoefficient=0.1,label='ts'), 
	NewtonIntegrator(gravity=(0.,0,-10),damping=0.5,label='newton'),
]

#### Creat materials ####
O.materials.append( CohFrictMat( young=E,poisson=0.3,density=1000,frictionAngle=radians(phi),normalCohesion=1e10,shearCohesion=1e10,momentRotationLaw=True,label='cMat' ) )  # material to create the gridConnections
O.materials.append( FrictMat( young=E,poisson=0.3,density=1000,frictionAngle=radians(phi),label='fMat' ) )  # material for general interactions

#### Create cylinders ####
nodesIds=[]
cylIds=[]
cylinder((0,0,2*r),(0,0,L+2*r),radius=r,nodesIds=nodesIds,cylIds=cylIds,fixed=False,intMaterial='cMat',extMaterial='fMat')

#### For viewing ####
from yade import qt
qt.View()
Gl1_Sphere.stripes=True

#### Delete and create cylinder/gridConnection ####
def delcylinder():
	O.bodies.erase(cylIds[0])  # first delete the cylinder
	O.interactions.erase(nodesIds[0],nodesIds[1]) # then delete the real interaction between the gridNodes
	O.interactions.eraseNonReal() # finally delete non real interactions

def createcylinder():
	O.bodies.append(gridConnection(nodesIds[0],nodesIds[1],r,wire=False, material = 'cMat') )


HTH
Klaus

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