← Back to team overview

yade-users team mailing list archive

Re: [Question #705744]: Divide numerical periodic microstructure box into smaller grided cubes or boxes

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hello,

deleting particles from certain region is not difficult.
As a starting point, see a MWE below.

cheers
Jan

###
from yade import pack
pred = pack.inAlignedBox((0, 0, 0), (30, 30, 8))
sphs = pack.regularHexa(pred, radius=1, gap=0)
O.bodies.append(sphs)

pores = [ # list of (center,radius) values of the spherical pores
    (Vector3(20, 20, 1), 7),
    (Vector3(6, 6, 6), 5),
]

def isInPore(body, pore):
    bpos, br = body.state.pos, body.shape.radius
    ppos,pr = pore
    dc = (bpos-ppos).norm() # center distance
    return dc + br < pr # including body radius (entire body is inside pore), could be only center-based or mixed

def makePores():
    for b in O.bodies:
        if any(isInPore(b,pore) for pore in pores):
            O.bodies.erase(b.id)

makePores()
###

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