← Back to team overview

yade-users team mailing list archive

Re: [Question #690010]: how to find the facet-sphere contact

 

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

    Status: Open => Answered

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

> but how can I get the specific facet----sphere contact infor.

it you know "i" is the contact you want, then
i.phys.normalForce
i.geom.normal
etc...

>for i.id1 in cylinderIDS:-----------I want to put some conditions here
to confine this is the inner cylingder, but I don't know how to do it.

if i.id1 in cylinderIDS: # if instead of for :-)

if cylinderIDS is "many" IDS, you can make it a set to look up efficiently:
cylinderIDS = set(cylinderIDS)

> besides, I have some another question about the i.id1 and i.id2. If
the contact is between the facet and sphere, I want to know which ids
belong to facet group? which ids belong to sphere group? because here is
a sentence methioned that "facet are only stored in id1 "

I am not sure if such order is strict / will be strict forever. In **my opinion** it is not a bad idea not to depend on specific order and test both id1->Facet id2->Sphere and id1->Sphere id2->Facet combinations:
###
for i in O.interactions:
   if not i.isReal: continue
   b1,b2= O.bodies[i.id1], O.bodies[i.id2]
   if isinstance(b1.shape,Facet) and isinstance(b2.shape,Sphere):
      facet = b1
      sphere = b2
   elif isinstance(b1.shape,Sphere) and isinstance(b2.shape,Facet):
      facet = b2
      sphere = b1
   else: # not facet-sphere contact
      continue
   if facet.id1 in cylinderIDS:
      ...
###

cheers
Jan

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