yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #07807
[Branch ~yade-dev/yade/trunk] Rev 2893: Fix (hopefully) simulation abort, when an interaction::erase is trying to delete an interaction, ...
------------------------------------------------------------
revno: 2893
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Wed 2011-07-20 14:42:36 +0200
message:
Fix (hopefully) simulation abort, when an interaction::erase is trying to delete an interaction, where one of bodies is already removed from simulation (id2)
modified:
core/InteractionContainer.cpp
core/InteractionContainer.hpp
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'core/InteractionContainer.cpp'
--- core/InteractionContainer.cpp 2011-07-02 17:35:29 +0000
+++ core/InteractionContainer.cpp 2011-07-20 12:42:36 +0000
@@ -6,7 +6,7 @@
#ifdef YADE_OPENMP
#include<omp.h>
#endif
-
+CREATE_LOGGER(InteractionContainer);
// begin internal functions
bool InteractionContainer::insert(const shared_ptr<Interaction>& i){
@@ -45,10 +45,14 @@
if (id1>id2) swap(id1,id2);
if(unlikely(id2>=(Body::id_t)bodies->size())) return false; // no such interaction
const shared_ptr<Body>& b1((*bodies)[id1]);
- if(unlikely(!b1)) return false; // body vanished
+ const shared_ptr<Body>& b2((*bodies)[id2]);
+ if((!b1) or (!b2)) return false; // bodies are vanished
Body::MapId2IntrT::iterator I(b1->intrs.find(id2));
// this used to return false
- if(I==b1->intrs.end()) throw std::logic_error(("InteractionContainer::erase: attempt to delete non-existent interaction ##"+lexical_cast<string>(id1)+"+"+lexical_cast<string>(id2)).c_str());
+ if(I==b1->intrs.end()) {
+ LOG_ERROR("InteractionContainer::erase: attempt to delete non-existent interaction ##"+lexical_cast<string>(id1)+"+"+lexical_cast<string>(id2));
+ return false;
+ }
// erase from body and then from linIntrs as well
int linIx=I->second->linIx;
b1->intrs.erase(I);
=== modified file 'core/InteractionContainer.hpp'
--- core/InteractionContainer.hpp 2011-02-27 13:54:43 +0000
+++ core/InteractionContainer.hpp 2011-07-20 12:42:36 +0000
@@ -163,5 +163,6 @@
REGISTER_ATTRIBUTES(Serializable,(interaction)(serializeSorted)(dirty));
REGISTER_CLASS_AND_BASE(InteractionContainer,Serializable);
+ DECLARE_LOGGER;
};
REGISTER_SERIALIZABLE(InteractionContainer);
Follow ups