How to exclude sphere-facet interaction data

Asked by Sina Jafari

hi all,
I have recorded interaction data successfully into a file but I don't want interaction data type of facet-sphere to be recorded. I don't know how to exclude these data so that they are not written in the output file. thanks for your help!

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jérôme Duriez
Solved:
Last query:
Last reply:
Revision history for this message
Best Jérôme Duriez (jduriez) said :
#1

Hello,

This is in fact quite easy with python tests about the shape of the two interacting bodies, using python function isinstance() to know if they are Facet.

For ex :
for i in O.interactions: # then i.id1 and i.id2 are the IDs of the 2 interacting bodies

   if not (isinstance(O.bodies[i.id1].shape,Facet) or isinstance(O.bodies[i.id2].shape,Facet) ): #isinstance(Object,Class) is true when the "Object" is an instance of the "Class", i.e. here if the shape of body i.id1 or i.id2 is a Facet
         # do your task with the output file

Jérôme

Revision history for this message
Hien Nguyen (giahien) said :
#2

Jerome's answer is more general and totally right.

Alternatively, for fast coding, if you know exactly the Id of the facet you can do like this, for example id of the facet is 0,1,2:

for i in O.interactions:
  if i.id1<3 or i.id2<3: continue
  your-record-function()

Revision history for this message
Sina Jafari (sinajafari88) said :
#3

Thanks jduriez, that solved my question.

Revision history for this message
Sina Jafari (sinajafari88) said :
#4

Thanks Hien Nguyen