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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hi guys,

sorry for coming late to the discussion.

what is "full interaction", "full no interaction" and "ful or zero
interactions"?

also, next time please try to make your script minimal and easily
understandable. E.g. here 1st, 5th, top, bottom... is ambiguous
according to view orientation..

For example:
###
# mask values, "colors"
mb,mg,mr = 0b10, 0b01, 0b11
# mask to string dict
m2c = {mb:"b", mg:"g", mr:"r"}
# testing spheres, 2 of each color
sb1 = sphere((0,0,0),1,mask=mb)
sb2 = sphere((0,0,0),1,mask=mb)
sg1 = sphere((0,0,0),1,mask=mg)
sg2 = sphere((0,0,0),1,mask=mg)
sr1 = sphere((0,0,0),1,mask=mr)
sr2 = sphere((0,0,0),1,mask=mr)
O.bodies.append((sb1,sb2,sg1,sg2,sr1,sr2))
#
collider.avoidSelfInteractionMask = 0b00
O.step()
#
idss = [(i.id1,i.id2) for i in O.interactions] # id couples for each interaction
bss = [[O.bodies[i] for i in ids] for ids in idss] # body couple of each 
interaction
mss = [[b.mask for b in bs] for bs in bss] # mask couple of each interaction
mss = [tuple(sorted(ms)) for ms in mss] # make the mask couple of type tuple 
(needs by set below). Also sort it for proper deletion of duplicates
mss = set(mss) # make the entries unique (i.e. deleting duplicates)
css = ["".join(m2c[m] for m in ms) for ms in mss] # convert mask couples to 
strings
css.sort() # sort the result
css = " ".join(css) # make it one string
print css # print interacting color couples
###

Please, provide your output for different avoidSelfInteractionMask
values such that we can test if your installation does wrong bit
operations or there is some misunderstanding.

For my case:
0b00: bb br gg gr rr
0b01: bb br gr
0b10: br gg gr
0b11: br gr

cheers
Jan

PS: a note
In your code, you first modify 'collider' and then in O.engines creates a new 
collider.
Setting avoidSelfInteractionMask works only "by luck" because 
avoidSelfInteractionMask is defined as static (for other values it could cause 
problems).
A cleaner way would be:
##
O.engines = [
   ...
   InsertionSortCollider(...,label="collider")
   ...
]
collider.avoidSelfInteractionMask = ...
##

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

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to