# Re: [Yade-users] [Question #665540]: particles partially in the wall

Status: Open => Solved

JOHN confirmed that the question is solved:
minimal working example follows

def run(name,boundaries,r,gap,numStepsPerIteration):

facets = ymport.stl(name)

rod1 = O.bodies.append(facets)

# converts facets to gts (see the other question)

s = gts.Surface()

for facet in facets:

vs = [facet.state.pos + facet.state.ori*v for v in
facet.shape.vertices]

vs = [gts.Vertex(v[0],v[1],v[2]) for v in vs]

es = [gts.Edge(vs[i],vs[j]) for i,j in
((0,1),(1,2),(2,0))]

f = gts.Face(es[0],es[1],es[2])

print s.is_closed()

threshold = 1e-3

s.cleanup(threshold)

print s.is_closed()

assert s.is_closed()

# use gts to filter spheres

pred = inGtsSurface(s)

# remove spheres completely inside walls

for b in sp:

if pred(b.state.pos,0):

continue

O.bodies.append(b)

# remove spheres partially inside walls

O.dt = 0

O.step() # interactions are created afterwards

toErase = set()

for i in O.interactions:

b1,b2 = [O.bodies[i] for i in (i.id1,i.id2)]

if any(isinstance(b.shape,Facet) for b in (b1,b2)): #
if facet is involved, delete

toErase = [b for b in toErase if
isinstance(b.shape,Sphere)] # delete just spheres

if not restart:

for b in toErase: # delete the spheres

O.bodies.erase(b.id)

#generate the initial global index list

for b in O.bodies:

if isinstance(b.shape,Sphere):

loc2glob.append(b.id)

O.engines=[

ForceResetter(),

InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),

InteractionLoop(

# handle sphere+sphere and facet+sphere collisions

[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],

[Ip2_FrictMat_FrictMat_FrictPhys()],

[Law2_ScGeom_FrictPhys_CundallStrack()]

),

NewtonIntegrator(gravity=(0,-9.81,0),damping=0.4,
label='newtonInt'),

]

O.dt=.8*PWaveTimeStep()

O.step()

--