← Back to team overview

yade-users team mailing list archive

Re: [Question #683856]: Segmentation fault (core dumped) after erase some bodies

 

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

    Status: Open => Answered

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

after findBodiesToBeDel, some bodies BodiesToBeDel multiple times (each body may be associated with multiple interactions).
Then in findBodiesToBeDel, you erase some bodies, but then you try to erase the same ID (which would be OK), but you try to get the id as "i.id", but "i" was already erased and (probably, did not investigated it more) was deleted in C++, ending in segmentation fault.

Try it with set using ids, something like:
###
IdsToBeDel = set()
def findBodiesToBeDel():
    for i in Ids:
        for j in Ids:
            if i>=j:
                continue
            else:
                if O.interactions.has(i,j):
                    IdsToBeDel.add(i)
                    IdsToBeDel.add(j)
findBodiesToBeDel()
def eraseOverlapBodies():
    for i in IdsToBeDel:
        O.bodies.erase(i)
eraseOverlapBodies()
###

cheers
Jan

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